Author Topic: The deal with the local stuff  (Read 297 times)

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
The deal with the local stuff
« on: May 24, 2011, 11:24:47 pm »


               I'd like to have this cleared up once and for all...

Is it OK to store local variables on players on a servervault server? And is it okay to store them on items on the same server (in players inventory)?

If not, why?
               
               

               


                     Modifié par Xardex, 24 mai 2011 - 10:25 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
The deal with the local stuff
« Reply #1 on: May 25, 2011, 12:13:51 am »


               It's ok to do it either way or both ways.  The difference is that a local stored on a PC will not persist over a sever reset.  For that reason most persistent worlds use an database object to store variables that persist on a player.  For instance I have a reputation system which increments if you do something noteworthy, this reputation is stored on a database object in the players inventory.  If it was stored on the PC it would get lost everytime the server is reset, so that particular variable would be fairly useless, and meaningless, for my purpose, which is to keep a persistent record of the PC's reputation.  Other uses of persistent variables: save location, curses, quest states, to name a few.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
The deal with the local stuff
« Reply #2 on: May 25, 2011, 01:40:19 am »


               Also you cant set/delete an variable on PC in OnClientExit, which can be problematic, however you can do it when he logs in again or you can workaround it.
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
The deal with the local stuff
« Reply #3 on: May 25, 2011, 03:03:24 pm »


               Thanks for the info, but what exactly do you mean by "database object"?

By the way, you can set variables and stuff on PC when they leave with nwnx_funcs, if someone craves for that function..
(Or was it nwnx_events? I cant remember)
               
               

               


                     Modifié par Xardex, 25 mai 2011 - 02:05 .
                     
                  


            

Legacy_Khuzadrepa

  • Sr. Member
  • ****
  • Posts: 347
  • Karma: +0/-0
The deal with the local stuff
« Reply #4 on: May 25, 2011, 04:38:07 pm »


               

Xardex wrote...
Thanks for the info, but what exactly do you mean by "database object"?

This could be any one (or more, I suppose) item in the character's inventory.  However, to make it most effective, you would want to make it undroppable.  Then, you store Local variables on the item.  These variables will remain even through server resets. It's a VERY useful tool, since from what I know it is much faster to Set and Get variables from an item than it is to use an actual database.  Just be wary not to set too many variables on an object, as it can slow things down a bit.  So far, I have set about 10 different variables this way per item, and it works fine.
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
The deal with the local stuff
« Reply #5 on: May 25, 2011, 06:04:52 pm »


               Ah, thats how I have done it up until now. (and will continue, I guess)

I just dont call them database objects... '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
The deal with the local stuff
« Reply #6 on: May 25, 2011, 08:51:47 pm »


               

Xardex wrote...

Thanks for the info, but what exactly do you mean by "database object"?

By the way, you can set variables and stuff on PC when they leave with nwnx_funcs, if someone craves for that function..
(Or was it nwnx_events? I cant remember)

oh yes sure new maxrock hook for preexit ;)its in nwnx_funcs