Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-25-2007, 01:18 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Overwriting Object Variables?

PHP Code:
public function saveCharcharID )
{
  
temp.filePath = ( "mud/playerdata/data/" this.account "_" temp.charID ".arc" );

  if ( 
temp.charID in |13| )
  {
    if ( 
this.charExiststemp.filePath ) )
    {
    for ( 
temp.var: this.clientr.getDynamicVarNames() )
      {
        if ( !
temp.var.ends"ID" ) )
        {
          
temp.clientVars.addtemp.var );
        }
      }
      
temp.savedChar = new TStaticVar();
      
temp.savedChar.loadVarsFromArraytemp.clientVars );

      for ( 
temp.theseVarstemp.savedChar.getDynamicVarNames() )
      {
          
temp.savedChar.( @ temp.theseVars ) = makevar"temp.savedChar." temp.theseVars );
      }
    
      
temp.savedChar.charLevel this.level.name;
      
temp.savedChar.charXPos this.y;
      
temp.savedChar.charYPos this.x;

      
temp.savedChar.saveVarstemp.filePath);
    }
    else
    {
      echo ( 
"***Mud Control: Character does not exist! Character must exist before saving!" );
    }
  }
  else
  {
    echo ( 
"***Mud Control: Invalid character ID! Character could not be saved!" );
  }


Code's up that a-way ^ !

Now the problem I am having is this, I preset a var named "mudaccount" in a different function and it saves it into the text file perfectly fine listing the Admin-Playerworld145 account as the mudaccount (account I'm testing with ).

But, when I use the above function it seems to overwrite mudaccount and make it equal 1. I've tried using the append function as well but that doesn't help.


Anyone see an issue?
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #2  
Old 04-25-2007, 01:30 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Load the variables, change whatever needs to be changed and save it again.
Reply With Quote
  #3  
Old 04-25-2007, 01:31 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
What exactly do you think I'm doing?

E: It's not even a matter of what I need to change inside the text file but what I need to add to it. >.>
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #4  
Old 04-25-2007, 01:36 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by killerogue View Post
What exactly do you think I'm doing?
Apparently not what I told you to do.

Say I have (Apple = 1), and (Bannana = 2) saved in ("mud/food"). To edit one of them without overwriting the whole file this is what I have to do.

PHP Code:
this.newInfo.loadVars("mud/food");
this.newInfo.Bannana 3;
this.newInfo.saveVars("mud/food"false); 
That would change the bannana value to 3, and wont do anything to the apple.

Edit to respond to the post above:
Ok if you want to add something then my method will still work.

PHP Code:
this.newInfo.loadVars("mud/food");
this.newInfo.Pie 5;
this.newInfo.saveVars("mud/food"false); 
Would add 'Pie' to the file, and will leave everything else alone.

To sum it all up just add this:
PHP Code:
temp.savedChar.loadVars(temp.filepath); 
Before:
PHP Code:
temp.savedChar.loadVarsFromArraytemp.clientVars ); 
Reply With Quote
  #5  
Old 04-25-2007, 02:10 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Ah, thanks Rapid. Novo sort of made me realize it was a bit over complicated to begin with.

So I basically dumbed it down and did what you said and it works fine. :]


Edit:

Ah, a new issue arises, following what you said I then tried to save the clientr strings as well along with everything else, It works with append but not with overwrite. But that's ok.

Thanks for the help man.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.

Last edited by killerogue; 04-25-2007 at 02:34 AM..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.