Global Variables
From ScapeFX Wiki
Global variables can be used by plugins, triggers, aliases and scripts.
To see a list of your defined global variable you can use the the following command from the commandline:
/varlist
To set a global variable from the commandline you can use the following command:
/setvar myvar=value
To remove a global variable you simply set it to nothing.
/setvar myvar=
From the commandline:
Anything starting with @ will be search/replaced with a global. Example: > kill @target
From plugins/scripts:
The ScapeFXAPI_GUIManager class has a method to access a ScapeFXAPI_GlobalManager. The GlobalManager has two methods which can be used to access and modify globals: public void set(String name, String value); public String get(String name);
Example PLUGIN (receiving a message from server to set a global):
@Override
public void receiveMessage(String message){
// Lets suppose that the message consist of "name:value"
String[] split = message.split(":");
this.getGUIManager().getGlobalManager().set(split[0], split[1]);
}
Example script
SCRIPT_NAME = "testvar";
void run(){
String var = globalManager.get("testvar");
gui.printText("default", "testvar is: "+var+"\n", true);
}
