Thread: TStaticVar()
View Single Post
  #6  
Old 03-21-2015, 02:36 PM
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
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.123;
  
temp.ex.234;
  
temp.ex.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
  
}

__________________
Quote:
Reply With Quote