what is use the setPvarint Benefit?
#1

what is use the setPvarint Benefit?
Reply
#2

I never use pvars, so I can't say there's a very good one.
Reply
#3

For first... Is 'SetPVarInt':
  • You don't need to create it.
  • You can use it in the FS and in the GM with the same goal.
  • Set by hisself to 0 at OnPlayerDisconnect.
Reply
#4

Quote:
Originally Posted by aRoach
Посмотреть сообщение
For first... Is 'SetPVarInt':
  • You don't need to create it.
  • You can use it in the FS and in the GM with the same goal.
  • Set by hisself to 0 at OnPlayerDisconnect.
so,this is the benefit?
Reply
#5

yes, you dont need to "care" for any aspect when using PVars. no array size needed, no initializations, no clearing up. PVars act dynamically, therefore they use less memory in most cases (10 of 500 players with some (lets say 10) variables instead of a huge array[500][20]).
there is another sweet trick for using them: you may set up a string for the variables "name" to identify a certain index.
pawn Код:
new VarString[16];
format(VarString,sizeof(VarString),"RaceCP%d",RaceCheckpoint[playerid]);
SetPVarInt(playerid,VarString,GetTickCount());
if the race checkpoint is 0 (start), then the variable name is "Babul0", the next logical PVar wold be like "Babul1".
you also can format a VarString like "RaceCP%03", this gives a name with leading zeros: "RaceCP001".

in short: sometimes you can even save cpu time, by not needing to loop through arrays in order to clean them up. PVars are definetly worth a look at.
Reply
#6

Quote:
Originally Posted by ******
the number of variables required at any given moment relative to the possible maximum was low
and thats the case in my race script, so your "some" is my "most" scenario
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)