I wish Stefan would enable timevar3 for non-G3D servers.
Quote:
Originally Posted by fowlplay4
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
PHP Code:
// ex: getOfflinePlayerVar("Graal123456", "x");
// returns the player's x coordinate
function getOfflinePlayerVar(temp.account, temp.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.account, temp.varname, temp.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.