13.02.2015, 22:32
Hey,
I've created a function to check whether a player is banned. If they are, a dialog will show up giving them their ban details then kicking them. However, the information from the database isn't there in the dialog.
For example, it should say:
Ban Reason: Hacks
Banned By: Anti - Cheat
But it will come out as
Ban Reason:
Banned By:
Here is the code,
How am I able to fix this problem?
Thanks
I've created a function to check whether a player is banned. If they are, a dialog will show up giving them their ban details then kicking them. However, the information from the database isn't there in the dialog.
For example, it should say:
Ban Reason: Hacks
Banned By: Anti - Cheat
But it will come out as
Ban Reason:
Banned By:
Here is the code,
pawn Code:
forward OnBanLoad(playerid);
public OnBanLoad(playerid)
{
new rows, fields, temp[120];
new
bReason,
bannedBy,
bName,
Dialog[403],
bIP,
bExpiration,
bID;
cache_get_data(rows, fields, mysql);
if(rows != 0)
{
cache_get_field_content(1, "Name", temp), bName = strval(temp);
cache_get_field_content(3, "Reason", temp), bReason = strval(temp);
cache_get_field_content(4, "BannedBy", temp), bannedBy = strval(temp);
cache_get_field_content(2, "IP", temp), bIP = strval(temp);
cache_get_field_content(0, "BanID", temp), bID = strval(temp);
cache_get_field_content(7, "Expiration", temp), bExpiration = strval(temp);
/*bName = cache_get_field_content_int(1, "Name");
bReason = cache_get_field_content_int(3, "Reason");
bannedBy = cache_get_field_content_int(4, "BannedBy");
bIP = cache_get_field_content_int(2, "IP");
bID = cache_get_field_content_int(0, "BanID");
bExpiration = cache_get_field_content_int(7, "Expiration");
#pragma unused 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",100, 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",100, false, "i", playerid);
}
}
return 1;
}
Thanks