Problem with Ban Dialog -
FunnyBear - 13.02.2015
Hey,
I made a function checking if the player is banned, and if they are, a dialog with their ban details will come up. However, I came across a problem which I can't seem to solve.
Problem explanation
If the player is banned, the ban dialog will come up for a split second but after the login dialog will appear.
Under OnPlayerConnect:
pawn Код:
if(CheckBan(playerid) == 0)
{
mysql_format(mysql, query, sizeof(query),"SELECT `password` FROM `"PlayerTable"` WHERE `user` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
}
CheckBan function:
pawn Код:
stock CheckBan(playerid)
{
new
query[100];
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `"BanTable"` WHERE (`Name` = '%e' OR `IP` = '%s') AND `Status` = '1'", Name[playerid]);
mysql_tquery(mysql, query, "OnBanLoad", "i", playerid);
return 0;
}
OnBanLoad:
pawn Код:
public OnBanLoad(playerid)
{
new rows, fields, temp[66];
new
bReason,
bannedBy,
bName,
Dialog[403],
bIP,
bExpiration,
bID;
cache_get_data(rows, fields, mysql);
if(rows != 0)
{
cache_get_field_content(0, "Name", temp), bName = strval(temp);
cache_get_field_content(0, "Reason", temp), bReason = strval(temp);
cache_get_field_content(0, "BannedBy", temp), bannedBy = strval(temp);
cache_get_field_content(0, "IP", temp), bIP = strval(temp);
cache_get_field_content(0, "BanID", temp), bID = strval(temp);
cache_get_field_content(0, "Expiration", temp), bExpiration = strval(temp);
if(bExpiration > 0)
{
if(gettime() >= bExpiration)
{
new query[74];
mysql_format(mysql, query, sizeof(query), "UPDATE `bans` SET `Status`=0 WHERE `BanID` = '%d'", bID);
mysql_tquery(mysql, query, "", "");
}
else
{
format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}You will be unbanned in %d day(s)!\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", bName, bIP, bReason, bannedBy, (bExpiration-gettime()+86400)/86400);
ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
SetTimerEx( "KickPlayer",1, false, "i", playerid);
}
}
else
{
format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}You are banned forever!\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", bName, bIP, bReason, bannedBy);
ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
SetTimerEx( "KickPlayer",1, false, "i", playerid);
}
}
return 1;
}
Thanks
Re: Problem with Ban Dialog -
scout322 - 14.02.2015
Код:
if(!CheckBan(playerid))
{
mysql_format(mysql, query, sizeof(query),"SELECT `password` FROM `"PlayerTable"` WHERE `user` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
}else{
mysql_tquery(mysql, query, "OnBanLoad", "i", playerid);
}
Код:
stock CheckBan(playerid)
{
new
query[100];
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `"BanTable"` WHERE (`Name` = '%e' OR `IP` = '%s') AND `Status` = '1'", Name[playerid]);
return 0;
}
Re: Problem with Ban Dialog -
Maximus0 - 14.02.2015
So you like farming?
https://sampforum.blast.hk/showthread.php?tid=563090