Pvars question?
#1

What exactly are they
What do they do?
Reply
#2

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).
Reply
#3

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.
Reply
#4

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.
Reply
#5

Quote:

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

Indeed, but he defintley has his anwser now!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)