Settings permissions MySQL
#1

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

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)
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)