PDA

View Full Version : PVar or Variables?


Admigo
14/08/2012, 03:44 PM
Heey all,

My whole script is bugged so i am debugging it.
I am using much variables.
Whats better to use: Variables or Pvar?

Thanks Admigo

Gumica
14/08/2012, 03:46 PM
Variables of course
Reason is here:
http://forum.sa-mp.com/showthread.php?t=268499

Babul
14/08/2012, 03:56 PM
i have to admit: i was (still am indeed) using PVars for almost every variable. they are "slower", we ALL know that, but is listing 100 variables once per 4 seconds worth a /cry? it will not harm your server performance if you load a debug filterscript, handle some checks (your admin level==16? interior set properly?) with pvars.
if you script each single variable like

if(GotShit#1[playerid]>0) blablaa
if(GotShit#2[playerid]<4)blabla else something else blabla
if(GotEvenMoreAwesomeShit[playerid] equals blabla2 etcetcetc

this list could go on for 200 variables, its a fucking hazzle to manage all of them,
OR:
one single loop using GetPVarsUpperIndex(), maybe a proper dialog input+response.if you are done debugging, unload the filterscript which handles pvars. done.

to all who are complaining about the bad performance of PVars: try to script your own system which enables all scripts to access them. no file operations allowed = you'll fail.
i sometimes wonder why theyre got invented. to be ignored, i guess...

playbox12
14/08/2012, 04:10 PM
It really depends on the situation, you can script some very neat things while combining pvars and gvars, properties. I use pvars in situations where I don't know how much of something there will be and don't really want a set limit.

Admigo
14/08/2012, 04:13 PM
Okay and what about my script? Should i place all codes in gamemode or make filterscripts to?

Babul
14/08/2012, 06:49 PM
start with the gamemode itself. as soon you see "oh, this command/skill should be placed in the adminscript", then do that. tbh, i did it this way: move all shit from gamemode to a filterscript, then you are forced to use G/P vars. if that works, you may move some code which unlikely will be changed, back to the gamemode.