Hi guys, I'm having a little problem with my BanCheck Function in my gamemode, I can't get it to return the values from the database to the dialog, here's the code:
Код:
stock BanCheck(playerid)
{
new query[256], PIP[20];
GetPlayerIp(playerid, PIP, sizeof(PIP));
format(query, sizeof(query), "SELECT * FROM `banlog` WHERE (`name` = '%s' OR `ip` = '%s') AND `banned` = 1 LIMIT 0,1", PlayerName(playerid), PIP);
mysql_function_query(Connection, query, true, "OnPlayerBanned", "i", playerid);
return 1;
}
forward OnPlayerBanned(playerid);
public OnPlayerBanned(playerid)
{
new Name2, estring, largestring[400];
new Rows, Field, string, Pname, PIP;
cache_get_data(Rows, Field);
if(Rows == 1)
{
PlayerInfo[playerid][pBanned] = 1;
new content[5];
cache_get_field_content(0, "time", content); estring = strval(content);
cache_get_field_content(0, "name", content); Name2 = strval(content);
cache_get_field_content(0, "ip", content); PIP = strval(content);
cache_get_field_content(0, "reason", content); string = strval(content);
cache_get_field_content(0, "admin", content); Pname = strval(content);
format(largestring, sizeof(largestring), "{00FF00}You are currently banned from this server. \r\n{FF0000}User: {FFFFFF}%s \r\n{FF0000}IP: {FFFFFF}%s \r\n{FF0000}Time: {FFFFFF}%s \r\n{FF0000}Admin: {FFFFFF}%s \r\n{FF0000}Reason: {FFFFFF}%s", Name2, PIP, estring, Pname, string);
ShowPlayerDialog(playerid, DIALOG_BANNED, DIALOG_STYLE_MSGBOX, "{FF0000}You are banned from this server", largestring, "Ok", "");
SendClientMessage(playerid, 0x66FF33, "You are banned from the server!");
new constring[44];//Console String
format(constring, sizeof(constring), "Kicked %s Banned Player.", PlayerName(playerid));
print(constring);
//I did this to test if my dialog was bug but in the server console it doesn't show nothing.
printf("%s", estring);
printf("%s", Name2);
printf("%s", PIP);
printf("%s", string);
printf("%s", Pname);
SetTimerEx("KickPlayer",5000,false,"d", playerid);
}
else if(!Rows)
{
PlayerInfo[playerid][pBanned] = 0;
SetTimerEx("OnPlayerConnectEx",2000,false,"d", playerid);
}
return 1;
}
The function BanCheck is called when the player connects.
My banlog table format from the database is: |time|name|ip|reason|admin|banned|
Do not use strval for strings.. also, load them straight into the variables.