View Single Post
  #12  
Old 08-25-2011, 09:57 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I wish Stefan would enable timevar3 for non-G3D servers.

Quote:
Originally Posted by fowlplay4 View Post
On the client-side timevar2 is the amount of seconds the client has been on for.
Except on Mac (and Linux?), where it's the number of seconds since the unix epoch, but may differ from the server's value due to a bad time setting on the client's computer.

Quote:
Originally Posted by 0PiX0 View Post
PHP Code:
// ex: getOfflinePlayerVar("Graal123456", "x"); 
// returns the player's x coordinate
function getOfflinePlayerVar(temp.accounttemp.varname) {
  
temp.pl = new TServerPlayer(@account);
  
temp.rtn makevar("pl." varname);
  
pl.destroy();
  return 
rtn;
}

// ex: setOfflinePlayerVar("Graal123456", "x", 30); 
// sets the player's x coordinate to 30. 
// They will login at the new position.
function setOfflinePlayerVar(temp.accounttemp.varnametemp.value) {
  
temp.pl = new TServerPlayer(@account);
  
makevar("pl." varname) = value;
  
pl.saveaccount();
  
pl.destroy();

You should try to avoid makevar as much as possible

PHP Code:
pl.(@ varname) = value
does the same thing, and doesn't make the object-orientation gods cry.

Quote:
Depending on how your script works, you might not even need to use timevar or timevar2.
When you jail someone, schedule an event to release their account in however many seconds you wish...
then in the event:
PHP Code:
temp.pl findplayer(acc);
if (
pl == NULL)
  
// edit offline
else
  
// setlevel2 
It's best not to use events for stuff like this since they're lost on server restart, and just create another point of failure (e.g. if the script is updated and you introduce a bug, events could not be received/set, ...). Using events is only a good idea if you use it in conjunction with a "release on" time which is checked periodically and/or on login.
__________________
Reply With Quote