Jump to content
  • 0
Lord Ganja

When does variables resets?

Question

As the title says, when does variable resets?

 

Like, if we use '@' variable, it resets whenever the attached player logged out. 

 

How about the others? 

 

Thanks for those who can explain.  :no1:

 

post-1008-0-34735600-1429190660_thumb.png

 

 

 

Edited by Lord Ganja

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Permanent variables, with no prefixes, or prefixes of $,# and ##  never reset unless you null them by yourself, that includes string variables ($ postfix).

 

There's no real difference between just variable and arrays, as normal variables are treated as array with index[0]. You can check that out yourself, for example TestVar and TestVar[0] will yeild same result if you set only one of them.

 

Temporary character variables are reset when character logs out. Temporary server variables ($@ prefix) reset during map server reset. Until that they're stored safely. NPC variables (. prefix) are also reset during server reset. Most interesting are scope variables (.@ prefix). They are reset whenever script hits an end (that includes close). They are very useful as a temporary variables you can use to count something, like if you need to rand a number and use it in 2 different parts of code, or for looping.

 

Also, Hercules has instance variables (' prefix), I believe those are nulled out once instance is destroyed, but can't be sure.

 

And some interesting fact about NPC variables: they are shared between duplicates of one NPC. I once hit that wall quite hard trying to figure out why it didn't go as planned at first with duplicate NPCs (And I'm quite lazy so I try to do almost everything with duplicates if it's possible. Using names of NPCs to store needed info to be able to duplicate easily is fun ^_^)

Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

@@Garr Thanks! anyway are permanent variables stored at sql? 

All variables are stored at SQL(except scope , since it is erased quickly (as soon as script ends))

There are 6 tables char_reg_num_db char_reg_str_db and 2-2 more for login and global variables.

Share this post


Link to post
Share on other sites
  • 0

 

@@Garr Thanks! anyway are permanent variables stored at sql? 

All variables are stored at SQL(except scope , since it is erased quickly (as soon as script ends))

There are 6 tables char_reg_num_db char_reg_str_db and 2-2 more for login and global variables.

Gotcha! Thanks@@Dastgir

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.