SA-MP Forums Archive
Pvars question? - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Pvars question? (/showthread.php?tid=136774)



Pvars question? - Torran - 26.03.2010

What exactly are they
What do they do?


Re: Pvars question? - Kyosaur - 26.03.2010

They're pretty much just global variables that are declared by the sa-mp server, i guess you could say.

They seem useless for people who know their way around pawn. I personally wont be switching everything over to this new system, as i dont see a gain. The only thing that really appeals to me about them is that they can be accessed from other scripts (i normally use callremotefunction, this isnt a bad method, but it is slower. Its not noticeable unless you have your function call in a loop tho).


Re: Pvars question? - Kyosaur - 26.03.2010

Quote:
Originally Posted by Seif_
Quote:
Originally Posted by Kyosaur!!
They're pretty much just global variables that are declared by the sa-mp server, i guess you could say.

They seem useless for people who know their way around pawn. I personally wont be switching everything over to this new system, as i dont see a gain. The only thing that really appeals to me about them is that they can be accessed from other scripts (i normally use callremotefunction, this isnt a bad method, but it is slower. Its not noticeable unless you have your function call in a loop tho).
It's a tiny bit slower. You will not notice any difference unless your loop is looping thousands. Regardless, this new system is definitely a gain and even prevents you from declaring the variable on your script. It also prevents you from using enums.
Enum variable:
PlayerInfo[playerid][pStats]
PVar:
GetPVarInt(playerid, "stats");
Simple as is.
I wouldnt say prevents, you can still use enums with the pvars (Dont really know why you would want to/need to tho...).


EDIT: I still dont see whats wrong with declaring MAX_PLAYER arrays, im fine losing 2kb of ram. The only thing im NOT content about is looping through them.


Can alter the a_samp include, or even do something like:

Code:
for(new a=0,b=GetMaxPlayers(); a<b; a++)
but still not very efficient for releases.


Re: Pvars question? - Kyosaur - 26.03.2010

Quote:
Originally Posted by Seif_
I always do:
for(new playerid, m = GetMaxPlayers(); playerid < m; playerid++)
This is faster than doing:
for(new playerid; playerid < GetMaxPlayers(); playerid++)
because you find GetMaxPlayers value and use it in the whole loop instead of finding it in every loop.
I also redefined MAX_PLAYERS to my max players slot. I do think we need a SetVVar(Int/Float/String) as well for vehicles.
I REALLY agree with that lol. Maybe just a better variable system all together (instead of pvar,vvar,ovar ... just have a single system).


Hmmm subject got a little offtopic... sorry lol.


Re: Pvars question? - playbox12 - 26.03.2010

Quote:

Hmmm subject got a little offtopic... sorry lol.

Indeed, but he defintley has his anwser now!