22.03.2017, 12:46
Okay, so I made this
If I change "UPDATE `accounts` SET `isBanned` = 1 WHERE `Name` = %e" to "UPDATE `accounts` SET `isBanned` = 1", all the accounts get banned, so I don't know why I have a SELECT in the cmd: oban
Here's the output:
Also, how can I make a check if the return is 0 from the callback so I could do something? Like: If(isReturned(0)) return 1;
PHP код:
CMD:oban(playerid, params[])// Banning offline players
{
new banned, AdminName[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], str[128], reason[32], query[128];
GetPlayerRPName(playerid, AdminName, sizeof(AdminName));
GetPlayerName(banned, PlayerName, sizeof(PlayerName));
if(PlayerInfo[playerid][Admin] > 3)
{
if(sscanf(params, "s[24] s[24]", PlayerName, reason)) return SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}USAGE: /o(ffline)ban [Player NAME] [Reason]");
mysql_format(g_Sql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1", PlayerName);
mysql_tquery(g_Sql, query, "OffBan", "is", playerid, PlayerName);
printf(query);
format(str, sizeof(str), "[BS] {AA3333} %s has offline banned %s. Reason: %s", AdminName, PlayerName, reason);
SendClientMessageToAll(COLOR_DARKCORAL, str);
}
else
{
SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}You cannot use this command!");
}
return 1;
}
PHP код:
forward OffBan(playerid, Banned);
PHP код:
public OffBan(playerid, Banned)
{
new rows, fields, query[128], isOBanned = 0;
cache_get_row_count(rows);
cache_get_field_count(fields);
if(rows)
{
cache_get_value_name_int(0, "isBanned", isOBanned);
if(isOBanned == 1)
{
SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}That player is already banned!");
return 1;
}
mysql_format(g_Sql, query, sizeof(query), "UPDATE `accounts` SET `isBanned` = 1 WHERE `Name` = %e", Banned);
mysql_tquery(g_Sql, query, "", "");
printf(query);
}
else if(!rows)
{
SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}That player doesn't exist!");
return 1;
}
return 1;
}
Here's the output:
Also, how can I make a check if the return is 0 from the callback so I could do something? Like: If(isReturned(0)) return 1;