|
I have the script rewritten for determining if a song is unlocked so I'm aware, but it fits better under the definition of what a bit variable is.
- - - Updated - - -
For those of you who MAY want to know the mapping of song ids to their file, since this discussion tapered into it a bit. You can grab it from the CS2 enumerations in the cache.
https://github.com/Hadyn/mopar/blob/...ng_config.json
That is for err. 530.
That's exactly what I've done on the last server I worked on. In fact, you don't even need external variables to keep track of player information between game cycles; there are generally varps which you can use for these too (the only exception I found was trade, which must use a very old legacy system).
For systems which work on a timer (such as farming), you can simply save the current time in the player file when you log out, then on the next login you can work out the difference between the last login and the current time and process anything you missed.
Besides varps, invs, friends/ignores, and stats, the only things you should need in the player file are run energy, current coordinates, name(s) and password, idk data (colours, styles, and gender), exchange offers, clan hash and last friends chat, and the timestamp of the last login.
Note that client variables (varc, varcstr) shouldn't need to be stored persistently on the server. They should only need to be sent to the client (most values are copies of global server variables anyways)
Updated thx to velocity for a suggestion that removed the need for a shit ton of values(int key, string value...) methods:
Code:Variable.stringBuilder("prayer_list").id(1584).type(VariableType.VARP).persist() .defaultValue(0, "normal") .value(1, "curses") .register();
It wouldn't even work as varc/varcstr can't be tracked properly; the client changes these where it wants to without any guaranteed hey-we-changed-it packet, thus making it untrackable, where (almost) all varps are altered either only by the server and then letting the client know (e.g. after buttons) or internal but immediately dispatching a message which indicates that the server should act. The sending of varc and varcstr is solely used to hint or instruct at moments but they're mainly used by scripts internally.
Also idk data has associated varps too, same with skin col and gender (change appearance on makeover mage on rs, notice varps).
Good read, thank you for the information I will definitely try to make good use of it.
Not Scu's code but this is the idea:
Code:import java.util.Map; import java.util.HashMap; import com.google.common.collect.ImmutableMap; import com.google.common.base.Preconditions; public final class Variable<T> { public static class Builder<T> { private final String name; public Builder(String name) { this.name = name; } private int id = -1; private Type type; private Persistence persistence = Persistence.TRANSIENT; private Map<Integer, String> values = new HashMap<>(); private String defaultValue; public void id(int id) { this.id = id; } public void type(Type type) { this.type = type; } public void persist() { persistence = Persistence.PERSISTENT; } public void value(int index, String value) { values.put(index, value); } public void defaultValue(String defaultValue) { this.defaultValue = defaultValue; } public void register() { Preconditions.checkNonNull(type, "Variable.Type must be set before registering.";) return new Variable(id, defaultValue, type, persistence, ImmutableMap.copyOf(values)); } } public enum Persistence { PERSISTENT, TRANSIENT, } public enum Type { VARBIT, VARP, /* more here */ } public static Builder<String> stringBuilder(String name) { return new Builder<>(name); } public static Builder<Integer> intBuilder(String name) { return new Builder<>(name); } private final T defaultValue; private final int id; private final Persistence persistence; private final Type type; private final ImmutableMap<Integer, String> values; public Variable(int id, T defaultValue, Type type, Persistence persistence, ImmutableMap<Integer, String> values) { this.id = id; this.defaultValue = defaultValue; this.type = type; this.persistence = persistence; this.values = values; } public T getDefaultValue() { return defaultValue; } public int getId() { return id; } public Persistence getPersistence() { return persistence; } public Type getType() { return type; } public String getValue(int index) { return values.get(index); } }
Last edited by Major; 07-30-2015 at 04:36 PM. Reason: Add missing import statements.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |