View Single Post
  #1  
Old 12-14-2009, 02:33 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
Offline Player Manipulation

Allows you to view and edit variables and the values of offline players while providing compatibility methods to edit them if they're already online.

PHP Code:
function findplayer2(acct) {
  
// Check if Player Online
  
temp.obj findplayer(acct);
  if (
temp.obj.level == NULL) {
    
// Create Player Object
    
temp.obj = new TServerPlayer(@acct);
  }
  return 
temp.obj;
}

function 
getPlayerVar(acct, var) {
  
// Get Player Object
  
temp.obj findplayer2(acct);
  
temp.val makevar("temp.obj." @ var);
  
// Destroy Player Object
  
if (temp.obj.level == NULLtemp.obj.destroy();
  
// Return Value
  
return temp.val;
}

function 
editPlayerVar(acct, var, value) {
  
// Get Player Object
  
temp.obj findplayer2(acct);
  
// Check for Array of Variables and Values
  
if (var.type() == && var.size() == value.size()) {
    
// Change Values
    
for (temp.v: var) {
      
makevar("temp.obj." @ var) = value[0+temp.i];
      
temp.i++;
    }
  } else {
    
// Change Single Value
    
makevar("temp.obj." @ var) = value;
  }
  
// Save Account File
  
if (temp.obj.level == NULL) {
    
temp.obj.saveaccount();
    
temp.obj.destroy();
  }

Some example usage..

PHP Code:
function onCreated() {
  
// Accessing Player Variables
  
echo(findplayer2("fowlplay4").account); // Echos fowlplay4
  
echo(getPlayerVar("fowlplay4""account")); // Echos -2144485044 on Zodiac
  // Multiple Variable Value Edit
  
editPlayerVar("fowlplay4", {"client.a""client.b"}, {12});
  
// Single Variable Value Edit
  
editPlayerVar("fowlplay4""client.c"3);

Important Note when using findplayer2:

Quote:
Originally Posted by Stefan View Post
You need to call destroy() on the player object after you have used it, when you do new TServerPlayer() it is not automatically destroyed like TStaticVars()
Enjoy!
__________________
Quote:

Last edited by fowlplay4; 12-14-2009 at 04:00 AM..
Reply With Quote