SetPVarInt/SetPVarString vs Enum - 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: SetPVarInt/SetPVarString vs Enum (
/showthread.php?tid=255512)
SetPVarInt/SetPVarString vs Enum -
NRJ53 - 15.05.2011
Hello,
I don't know if there is another scripting discussion thread about it or even a tutorial about it, I just want to know FAST.
pawn Code:
SetPVarInt
SetPVarString
SetPVarFloat
or
pawn Code:
enum SomethingE {
}
new Something[SomethingE];
Thanks
Re: SetPVarInt/SetPVarString vs Enum -
linuxthefish - 15.05.2011
enum's are faster, and PVars use less ram. (I Think)
Re: SetPVarInt/SetPVarString vs Enum -
NRJ53 - 15.05.2011
Well as I got a dedicated server (6gb RAM) I will use Enum's if they are faster, and it's MySQL so
Respuesta: SetPVarInt/SetPVarString vs Enum -
admantis - 15.05.2011
PVar is superior, easier to use, supports global connection with other scripts and more advanced.
Re: SetPVarInt/SetPVarString vs Enum -
iggy1 - 15.05.2011
Using normal vars/enums can also reduce the amount of code you write like when incrementing a variable.
PVars
pawn Code:
SetPVarInt(playerid, "SomethingE", GetPVarInt(playerid, "SomethingE") +1);
Normal
pawn Code:
Something[playerid][SomethingE]++;
Also a good reason i only use a few PVars is you wont get a warning if you misspell the var somewhere (thats not good). And incase i forget a name of a var (imagine you have 100s of vars), i like being able to look at the top of the code for declarations and not have to look inside functions for variable names. They are my personal prefereces but normal vars also use less CPU, which IMO makes normal vars superior to PVars. But PVars have they're uses/advantages like adamantis said they can be used cross script (you could create functions to do that with normal vars too).
Re: SetPVarInt/SetPVarString vs Enum -
NRJ53 - 15.05.2011
Could you make a function eg IsUserAdmin(playerid, level) and use CallLocalFunction/CallRemoteFunction (i think thats what they are) for filterscripts?
Re: SetPVarInt/SetPVarString vs Enum -
iggy1 - 15.05.2011
Yes "CallRemoteFunction" for cross script. The function must be public too.
Re: SetPVarInt/SetPVarString vs Enum -
NRJ53 - 15.05.2011
Thought so, eg,
Gamemode:
pawn Code:
public IsUserAdmin(playerid, level){
if(player[playerid][AdmLvl] >= level) return 1;
return 0;
}
Filterscript:
What would I do?
Re: SetPVarInt/SetPVarString vs Enum -
Vince - 16.05.2011
That's bullshit. If you want to increment a single PVar, you'll have to call two functions, which are incredibly slow in comparison to regular variables. The only time you should rely on PVars is if you want to do cross code scripting (e.g. fetching a user variable in your gamemode via a filterscript or vice versa).