View Single Post
  #6  
Old 01-28-2012, 08:58 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by scriptless View Post
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."hello "
  
temp.example."world"
  
temp.example."!"
  
temp.example.b." <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.
__________________
Quote:
Reply With Quote