Quote:
Originally Posted by scriptless
Curiosity, why do we need savevarstoarray(false)? And no need for TStaticVar(); except after clientside triggered..? Interesting.
|
triggerclient doesn't support objects, so it converts the object into the string representation of itself (often it's .name value).
PHP Code:
function onCreated() {
temp.example = new TStaticVar("a silly test object");
temp.example.a = "hello ";
temp.example.b = "world";
temp.example.c = "!";
temp.example.b.a = " <3";
findplayer("fowlplay4").triggerclient(this.name, "data", temp.example);
temp.example.destroy();
}
//#CLIENTSIDE
function onActionClientside() {
if (params[0] == "data") {
temp.data = params[1];
echo("data: " @ temp.data); // echos "a silly test object"
}
}
So you have to package the object up and send it as an array/string then rebuild it on the client-side which those two built-in functions do nicely.
Also the new TStaticVar() on the server-side wasn't necessary because you weren't passing it between two functions so when you call savevarsintoarray it's able to find the a, b, c, and b.a vars.