Quote:
Originally Posted by scriptless
Hmm, I know I have used this before. But I think I lacked some understanding. Is there anyone that can explain any differences between using a TStaticVar() vs something like savevarstoarray() and loadvarsfromarray() ? In the past I have used both of them to preserve variables such as temp.obj.var.
|
loadvarsfromarray and savevarstoarray is used for serialization. Useful for when you want to send an object over a method that doesn't support them or save it to a file.
e.g. triggers
PHP Code:
function onCreated() {
temp.ex.a = 123;
temp.ex.b = 234;
temp.ex.c = 345;
temp.data = temp.ex.savevarstoarray(false);
findplayer("fowlplay4").triggerclient("weapon", this.name, "data", temp.data);
}
//#CLIENTSIDE
function onActionClientSide() {
if (params[0] == "data") {
temp.data = params[1];
temp.ex.loadvarsfromarray(temp.data);
echo(temp.ex.a SPC temp.ex.b SPC temp.ex.c); // echos 123 234 345
}
}