What am I doing wrong? -
Scarred - 17.12.2011
pawn Код:
forward UpdateBans(playerid);
public UpdateBans(playerid)
{
if(strcmp(UserInfo[playerid][AccountLocked], "No", false) == 0)
{
if(LoggedIn[playerid] == 1) {
new string[128];
SendClientMessage(playerid, COLOR_ERROR, "This account is locked!");
format(string, sizeof(string), "< Reason: %s", UserInfo[playerid][AccountLocked]);
SendClientMessage(playerid, COLOR_ERROR, string);
Kick(playerid);
}
}
return 1;
}
The userfile reads as following:
Therefore I know it's setting it correctly, but i'm assuming I did something wrong with the string compare. Can anyone tell me what I did incorrectly?
Re: What am I doing wrong? -
Scenario - 17.12.2011
strcmp returns 0 if true
pawn Код:
if(!strcmp(UserInfo[playerid][AccountLocked], "No", false) == 0)
Also, I don't think you need this:
pawn Код:
if(!strcmp(UserInfo[playerid][AccountLocked], "No", false))
Re: What am I doing wrong? -
Scarred - 18.12.2011
Still not working. I want it so if AccountLocked = "No" then it will allow the login and let them continue playing, however, this is not working..
pawn Код:
forward UpdateBans(playerid);
public UpdateBans(playerid)
{
if(!strcmp(UserInfo[playerid][AccountLocked], "No", false))
{
if(LoggedIn[playerid] == 1) {
new string[128];
SendClientMessage(playerid, COLOR_ERROR, "This account is locked!");
format(string, sizeof(string), "< Reason: %s", UserInfo[playerid][AccountLocked]);
SendClientMessage(playerid, COLOR_ERROR, string);
Kick(playerid);
}
}
return 1;
}
The timer is called OnGameModeInit if that piece of information is needed..
Re: What am I doing wrong? -
Scenario - 18.12.2011
Okay, so the value of this variable is currently "No" according to the user file?
pawn Код:
UserInfo[playerid][AccountLocked]
Re: What am I doing wrong? -
admantis - 18.12.2011
What I don't see logical, is that if the account is /not/ locked, it will say it is locked? shouldn't it be like..
pawn Код:
if(strcmp(UserInfo[playerid][AccountLocked], "Yes", false) == 0)
Re: What am I doing wrong? -
Scarred - 18.12.2011
Quote:
Originally Posted by admantis
What I don't see logical, is that if the account is /not/ locked, it will say it is locked? shouldn't it be like..
pawn Код:
if(strcmp(UserInfo[playerid][AccountLocked], "Yes", false) == 0)
|
I'm sorry, half asleep... and yeah, that does seem more logical. Your code appears to be working. Thank you +rep.
Quote:
Originally Posted by RealCop228
Okay, so the value of this variable is currently "No" according to the user file?
pawn Код:
UserInfo[playerid][AccountLocked]
|
It was, yes, and it's been fixed due to Admantis, but thank you for your attempt.
Re: What am I doing wrong? -
Calgon - 18.12.2011
Despite your problem being fixed, I think it's worth pointing out that using integers (normal whole numbers), 0 and 1 is more widely used in userfiles, 0 usually means no and 1 usually means yes, having to deal with strings is more problematic, which is why I'd advise that you consider using integers, not only will you avoid the whole strcmp deal, but you'll just be able to have a simple if [operator] statement.