Doubt with per player variable system (PVar) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Doubt with per player variable system (PVar) (
/showthread.php?tid=409392)
Doubt with per player variable system (PVar) -
Gryphus One - 21.01.2013
In the wiki article about this (
https://sampwiki.blast.hk/wiki/Per-player_variable_system) you can see that PVars are shared by the gamemode and all the filterscripts running in your server. This can be an advantage when you want them to work together intentionally, but I also see a risk in this:
Imagine two scripters, scripter A and scripter B, who have absolutely no relationship with each other. Scripter A releases a gamemode which uses a PVar (for example, SetPVarInt "LastVehicle"), and scripter B releases a filterscript which, by pure coincidence, uses another PVar that has the very same name. Now we have a random user who coincidentally downloads both that gamemode and that filterscript, without knowing at all that they both have a PVar with the same name, and he puts both together in his server.
Obviously there would be an interference. However, if you use the old MAX_PLAYERS sized arrays method, even if they have the very same name in gamemode and filterscripts, they will be completely independent.
So my question is: is there any way to isolate PVars so they affect only the gamemode or filterscript in which they are used? Or the only option I have to avoid interference is to give my PVars some very strange names that nobody else will ever give to his?
Re: Doubt with per player variable system (PVar) -
azzerking - 21.01.2013
Wrong Section, This should be in the discussion part of the forum and not the scripting help.
Re: Doubt with per player variable system (PVar) -
leong124 - 21.01.2013
Then in most cases PVars are unnecessary if you only use it for one script.
Maybe reading this can help you:
https://sampforum.blast.hk/showthread.php?tid=268499
Respuesta: Re: Doubt with per player variable system (PVar) -
Gryphus One - 21.01.2013
Quote:
Originally Posted by leong124
|
Wow, that was really useful!!
Thank you a lot.