Aller au contenu

Photo

The deal with the local stuff


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Xardex

Xardex
  • Members
  • 217 messages
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 .


#2
ffbj

ffbj
  • Members
  • 593 messages
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.

#3
Shadooow

Shadooow
  • Members
  • 4 471 messages
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.

#4
Xardex

Xardex
  • Members
  • 217 messages
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 .


#5
Khuzadrepa

Khuzadrepa
  • Members
  • 188 messages

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.

#6
Xardex

Xardex
  • Members
  • 217 messages
Ah, thats how I have done it up until now. (and will continue, I guess)

I just dont call them database objects... :P

#7
Shadooow

Shadooow
  • Members
  • 4 471 messages

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