SetPVarInt/SetPVarString vs Enum
#1

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
Reply
#2

enum's are faster, and PVars use less ram. (I Think)
Reply
#3

Well as I got a dedicated server (6gb RAM) I will use Enum's if they are faster, and it's MySQL so
Reply
#4

PVar is superior, easier to use, supports global connection with other scripts and more advanced.
Reply
#5

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

Could you make a function eg IsUserAdmin(playerid, level) and use CallLocalFunction/CallRemoteFunction (i think thats what they are) for filterscripts?
Reply
#7

Yes "CallRemoteFunction" for cross script. The function must be public too.
Reply
#8

Thought so, eg,

Gamemode:
pawn Code:
public IsUserAdmin(playerid, level){
if(player[playerid][AdmLvl] >= level) return 1;
return 0;
}
Filterscript:
What would I do?
Reply
#9

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


Forum Jump:


Users browsing this thread: 2 Guest(s)