SA-MP Forums Archive
Which ? (gVar and 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: Which ? (gVar and pVar) (/showthread.php?tid=607669)



Which ? (gVar and pVar) - ProRakNet - 22.05.2016

Which should I use for small things

+ Global Var:
Код:
new fcontrol[MAX_PLAYERS];

stock fblabla(playerid){
if(ftest == 0){
fcontrol[playerid] = 1;
}else{
fcontrol[playerid] = 0;
}
+ Player Var:
Код:
stock sblabla(playerid){
if(stest == 1){
SetPVarInt(playerid, "scontrol", 1);
}else{
SetPVarInt(playerid, "scontrol", 0);
}



Re: Which ? (gVar and pVar) - luke49 - 22.05.2016

For smaller things I suggest using pVar - it also use less memory, but are slower than gVar.


Re: Which ? (gVar and pVar) - PT - 22.05.2016

PVars are slower than normal variables...


Re: Which ? (gVar and pVar) - iKevin - 22.05.2016

Use normal variables.


Re: Which ? (gVar and pVar) - Gammix - 22.05.2016

What's the point here in making a choice between PVar or variables ?

You only use PVars when you want to access the value of that specific variable in other scripts.
(e.g. My admin level is 5, so i need to check if i am admin as well in a seperate filterscript, so i'll make use of PVars).


Re: Which ? (gVar and pVar) - ProRakNet - 22.05.2016

Quote:
Originally Posted by Gammix
Посмотреть сообщение
What's the point here in making a choice between PVar or variables ?

You only use PVars when you want to access the value of that specific variable in other scripts.
(e.g. My admin level is 5, so i need to check if i am admin as well in a seperate filterscript, so i'll make use of PVars).
Example :
Код:
if(GetPVarInt(playerid,"spawncmd") == 1) return SendClientMessage(playerid,-1,"You did not spawn");
OR
Код:
if(spawncmd[playerid] == 1) return SendClientMessage(playerid,-1,"You did not spawn");
Which makes sense here


Re: Which ? (gVar and pVar) - Konstantinos - 22.05.2016

https://sampforum.blast.hk/showthread.php?tid=571043


Re: Which ? (gVar and pVar) - ProRakNet - 22.05.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I was looking for it somewhere about, thanks.