SA-MP Forums Archive
Settings permissions MySQL - 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: Settings permissions MySQL (/showthread.php?tid=298915)



Settings permissions MySQL - DJ123 - 23.11.2011

Hello,

When I try to block serveral things for donators I'm failing. Normally I can use:
pawn Код:
if(PlayerInfo[playerid][Donator] == 1)
{

}
Ain't a problem, right now I'm saving things in my MySQL database VARCHAR(24). Let's say I'm saving Donator: Gold.
Then I try:
pawn Код:
if(PlayerInfo[playerid][Donator] == Gold)
{

}
That's not working, someone has a solution?


Re: Settings permissions MySQL - AndreT - 23.11.2011

In that case (you're storing the variable as a string), you'd need to use string comparison for checking.
pawn Код:
if(strcmp(PlayerInfo[playerid][Donator], "Gold", true) == 0)
// or, shorter
if(!strcmp(PlayerInfo[playerid][Donator], "Gold", true))
Alternatively, I suggest you to store your donator statuses (lets say you have 3 of them - Bronze, Silver, Gold) as a tinyint (field type: TINYINT (2)).
Then load it as an integer and you can run checks like:
pawn Код:
#define BRONZE 1
#define SILVER 2
#define GOLD 3
// ...
if(PlayerInfo[playerid][Donator] <= GOLD)



Re: Settings permissions MySQL - GhoulSlayeR - 23.11.2011

Well you're trying to treat a string (Gold) as an int, it's doesn't really work that way in pawn.

https://sampwiki.blast.hk/wiki/Strcmp