Lord Ganja 5 Posted April 16, 2015 (edited) 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. Edited April 16, 2015 by Lord Ganja Quote Share this post Link to post Share on other sites
0 Garr 117 Posted April 16, 2015 (edited) 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 April 16, 2015 by Garr Quote Share this post Link to post Share on other sites
0 Lord Ganja 5 Posted April 16, 2015 @@Garr Thanks! anyway are permanent variables stored at sql? Quote Share this post Link to post Share on other sites
0 Dastgir 1246 Posted April 16, 2015 @@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. Quote Share this post Link to post Share on other sites
0 Lord Ganja 5 Posted April 16, 2015 @@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 Quote Share this post Link to post Share on other sites
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.
Share this post
Link to post
Share on other sites