Network Variables
Network variables are values that every server behind your proxy shares, such as a boss kill counter, an event flag or a player's quest progress. The proxy stores them, so by default they survive restarts.
Network variables require MythicMobs Premium! The profile scopes also need MythicRPG Premium.
Working With Network Variables
| To | Use |
|---|---|
| Set a variable | networkVariableSet |
| Add to a number | networkVariableAdd |
| Remove a variable | networkVariableUnset |
| Check a variable | networkVariableEquals, networkVariableIsSet, networkVariableInRange |
| Show a variable | Placeholders such as <global.netvar.NAME> |
Network variables are separate from MythicMobs variables: setVariable and <global.var.NAME> never see them, and the mechanics, conditions and placeholders on this wiki never see MythicMobs variables. How the servers load and share network variables is explained in Reading and Writing.
Variable Types
The type attribute decides how a value is read and printed. Letter case does not matter.
| Type | Value to set | Prints as |
|---|---|---|
| INTEGER | Whole number from -2147483648 to 2147483647 | 42 |
| LONG | Whole number with a much larger range | 42 |
| FLOAT | Number with decimals | 1.5 |
| DOUBLE | Number with decimals, more precise than FLOAT | 1.5 |
| BOOLEAN | true, yes or 1 (any letter case) is true, anything else is false |
true or false |
| STRING | Any text | The text |
| LOCATION | world,x,y,z. Yaw and pitch are dropped |
world,12.5,64.0,-3.5 |
| VECTOR | x,y,z. Anything else becomes 0,0,0 |
1.0,2.5,3.0 |
| LIST | Entries separated by commas: a,b,c. A space after a comma becomes part of the entry |
a,b,c |
| SET | Like LIST, without duplicates and in no fixed order | a,b,c |
| MAP | key=value pairs separated by semicolons, in double quotes: value="gold=5;silver=12". A pair without exactly one = is dropped, and the order is not kept |
gold=5;silver=12 |
| TIME | Milliseconds since the epoch | 1700000000000 |
- FLOAT and DOUBLE always print a decimal point (
100.0). Very large and very small numbers print with an exponent, such as1.0E7. - If a value does not fit its type, for example
5.5or20.0for an INTEGER, nothing is stored and the console logs a warning.valueis not calculated, so a placeholder that prints a decimal needs FLOAT or DOUBLE. - A LOCATION's world must exist on every server that uses the variable. If it is missing on the server that sets it, the skill stops with an error.
- Other MythicMobs types, such as METASKILL and ITEM, cannot be stored. A
typethat is not in the table makes the line invalid. - Values have a size limit, see Limits.
Variable Scopes
The scope attribute decides who a variable belongs to. Letter case does not matter.
| Scope | Aliases | The variable belongs to |
|---|---|---|
global |
g |
The whole network. Works with any caster or target, or none |
caster |
c, player, p |
The player who casts the skill |
target |
t |
The player the mechanic targets |
profile |
The active MythicRPG profile of the player who casts the skill | |
targetprofile |
The active MythicRPG profile of the player the mechanic targets |
- A global, a player and a profile variable with the same name are three different variables. A player variable follows the player to every server, and a profile variable follows the profile.
playerandpmean the caster, not the target.casterandtargetneed a player,profileandtargetprofilea player with an active MythicRPG profile. Otherwise a mechanic does nothing and a condition is false, without a message.- A mob is the caster of its own skills, so in mob skills use
targetortargetprofileand aim the mechanic at the player, see Targets. - Any other scope makes the line invalid.
Variable Names
- Names are case-sensitive:
Killsandkillsare two variables. With MySQL storage the database may treat them as one, so pick one spelling. - Use letters, numbers and underscores. A name with a dot or a pipe (
|) can be set, but a placeholder cannot read it. - Do not put the scope in the name:
var=caster.killsis a global variable namedcaster.kills. Usescope=casterinstead. - With MySQL storage, a name can be at most 191 characters long.
Persistence and Expiry
The duration and save attributes of networkVariableSet and networkVariableAdd decide how long a variable lives.
| You set | The variable |
|---|---|
| Neither | Stays until you unset it. The proxy saves it and gives it to every server that needs it, also after restarts |
duration (in ticks, 20 per second) |
Expires after that time. save is ignored |
save=false |
Reaches the running servers at once, but the proxy never gives it out again: a server that starts or reconnects, or a player who joins a server, does not get it. The proxy deletes it about 24 hours after its last change |
- An expired variable counts as not set.
- Expiry depends on the clocks of your servers, see Conflicts and Clocks.
networkVariableSetreplaces the expiry every time, so a set withoutdurationmakes the variable permanent again.networkVariableAddwith adurationrestarts the countdown. An add with neitherdurationnorsave=falsekeeps the expiry the variable already has.- A player or profile variable with
save=falseis gone as soon as the player leaves the server, also when they move to another server. - Player and profile variables stay on the proxy after the player leaves the network. Give them a
durationif they should not stay forever. - Use
save=falsefor values that should not come back after a restart, such as a boss's live health.
MythicRPG Profile Variables
A MythicRPG profile is one of a player's characters. The profile and targetprofile scopes keep a variable on the player's active profile, so each character has its own value, while caster and target keep one value per player for all of their characters.
The profile scopes and placeholders require MythicRPG Premium as well as MythicMobs Premium! MythicProxy checks for MythicRPG Premium once, when it starts. Without it,
profileandtargetprofileare invalid scopes and the profile placeholders do not exist, see MythicRPG Premium Not Detected.
Each right-click moves the clicking player's current character one quest stage further, and every character has its own stage.
QuestGiver:
Type: VILLAGER
Skills:
- networkVariableAdd{var=quest_stage;scope=targetprofile;amount=1} ~onInteract
- message{m="Your character is on quest stage <target.profilenetvar.quest_stage|0>"} @trigger ~onInteract
- Active profile. The scopes and placeholders use the profile that MythicRPG has active for the player. After a profile switch they use the new profile at once, and its variables read as not set until the proxy has sent them.
- No active profile. While a player has no active profile, for example while MythicRPG is still loading it, a mechanic does nothing, a condition is false and a placeholder prints
UNDEFINED, see Unset Variables. - Several backends. A profile has the same variables on every backend only if it has the same id there. Give the backends that share players the same MythicRPG MySQL or MariaDB database (
Storage.Driverin MythicRPG'sconfig-rpg.yml). With the default JSON storage, each backend has its own profiles. - Deleted profiles. Deleting a profile in MythicRPG does not delete its variables on the proxy.
- Joins and switches. The join and switch triggers also wait for the player's profile, see Missed Events.