SA-MP Forums Archive
Which one is the best? PlayerInfo or GetPVarInt - 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)
+---- Forum: Discussion (https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: Which one is the best? PlayerInfo or GetPVarInt (/showthread.php?tid=645788)



Which one is the best? PlayerInfo or GetPVarInt - DavidGravelli - 04.12.2017

Which one is the best? PlayerInfo or GetPVarInt ?
Comment.


Re: Which one is the best? PlayerInfo or GetPVarInt - beckzy - 04.12.2017

GetPVarInt is certainly slower, but uses less memory I guess

Edit: PVars are also reset to 0 when then player disconnects, so no need to reset them in OnPlayerConnect (unless they need to be set to something other than 0)


Re: Which one is the best? PlayerInfo or GetPVarInt - Mauzen - 04.12.2017

PVars store the value AND the identifier, so they actually use more memory. Only reason I can think of right now is to use them for cross-script variables, or maybe for stuff that gets accessed just very rarely. Whenever you can use just normal variables.


Re: Which one is the best? PlayerInfo or GetPVarInt - NaS - 04.12.2017

PVars are, like Mauzen said, only really useful for adding new variables run-time and for cross-script variables.
There's literally no advantage over regular variables in other scenarios (except that you can index PVars by a name, although that is rarely a requirement).


Re: Which one is the best? PlayerInfo or GetPVarInt - Kaperstone - 04.12.2017

If you're asking this, then you probably don't need (G/S/P)Var.


Re: Which one is the best? PlayerInfo or GetPVarInt - Mobtiesgangsa - 04.12.2017

pVars for me is good to know it can be very important sometimes down the line but for me its easy to put few variables in an enumeration than adding a new variable for the maximum amounts of players MAX_PLAYERS i usual learn'd quite well and i'm practical using it.