Ban Command
#9

Quote:
Originally Posted by Tass007
Посмотреть сообщение
Haha all goods thanks for offering your time.
Код:
../gamemodes/inc/admincommands.pwn(315) : error 033: array must be indexed (variable "query")
PHP код:
 query mysql_query(ServerMySQLquery); //315 
Also with removing cache when should I be doing it?

Also with my other ban commands, /oban and /unban I get "Error: That player doesn't exist"
Actually, that should be:
Код:
 cquery = mysql_query(ServerMySQL, query); //315
for /oban and /unban commands, you should use mysql_query or mysql_tquery with callback to get cache_affected_rows()
for /unban command, you must fetch banned player's IP first, before unban their IP.
Here are /oban and /unban commands, hope it will work
Код:
CMD:oban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 3) return 0;
    {
        new name[24], query[250], reason[128], string[128];
        if(sscanf(params, "s[24]s[24]", name, reason)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /offlineban [Player Name] [Reason]");
        mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = 1, pBannedBy = '%s', pReason = '%s' WHERE Name='%s'", GetName(playerid), reason, name);
        new Cache:c = mysql_query(ServerMySQL, query);
        if (!cache_affected_rows(ServerMySQL))
        {
            cache_delete©;
            return SendClientMessage(playerid, COLOR_RED, "Error: That player doesn't exist"); 
        }
        format(string,sizeof(string), "*You have successfully banned player %s.", name);
        SendClientMessage(playerid, COLOR_ADMIN, string);
        format(amsg, sizeof(amsg), "[Admin Log]: %s has offline banned player %s [Reason: %s]", GetName(playerid), name, reason);
        ABroadCast(COLOR_ADMIN,amsg, 1);
        foreach(new i : Player)
        {
            GetPlayerName(i, string, 24);
            if(!strcmp(string, name, true))
            {
                SetTimerEx("UnsetBan", 500, 0, "i", i);
                break;
            }
        }
        cache_delete©;
    }
    return 1;
}

CMD:unban(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] <= 3) return 0;
    new name[24], query[300], cmdstring[44], string[128];
    if(sscanf(params, "s", name)) return SendClientMessage(playerid, COLOR_WHITE,"Usage: /unban [Player Name]");
    mysql_format(ServerMySQL, query, sizeof(query), "UPDATE `Users` SET pBanned = 0, pBannedBy = '%s', pReason = '' WHERE Name='%s'", GetName(playerid), name);
    new Cache:c = mysql_query(ServerMySQL, query);
    if(!cache_affected_rows(ServerMySQL)) 
    {
        cache_delete©;
        return SendClientMessage(playerid, COLOR_RED, "Error: That player doesn't exist"); 
    }
    cache_delete©;
    mysql_format(ServerMySQL, query, sizeof(query), "SELECT `IP_COLUMN_NAME_HERE` FROM `Users` WHERE Name='%s'", name); // You need to fetch player IP first
    c = mysql_query(ServerMySQL, query);
    if(cache_num_rows())
    {
        new playerip[16];
        cache_get_field_content(0, 'IP_COLUMN_NAME_HERE', playerip, ServerMySQL, 16);
        format(cmdstring, sizeof(cmdstring), "unbanip %s", playerip);
        SendRconCommand(cmdstring);
        SendRconCommand("reloadbans");
    }
    format(string,sizeof(string), "*You have successfully unbanned %s.", name);
    SendClientMessage(playerid, COLOR_ADMIN, string);
    format(amsg, sizeof(amsg), "[Admin Log]: %s has unbanned player %s", GetName(playerid), name);
    ABroadCast(COLOR_ADMIN,amsg, 1);
    cache_delete©;
    return 1;
}
Reply


Messages In This Thread
Ban Command - by Tass007 - 24.09.2016, 08:06
Re: Ban Command - by X337 - 24.09.2016, 08:54
Re: Ban Command - by Konstantinos - 24.09.2016, 09:01
Re: Ban Command - by Tass007 - 24.09.2016, 09:23
Re: Ban Command - by X337 - 24.09.2016, 09:28
Re: Ban Command - by Tass007 - 24.09.2016, 09:34
Re: Ban Command - by X337 - 24.09.2016, 09:35
Re: Ban Command - by Tass007 - 24.09.2016, 09:40
Re: Ban Command - by X337 - 24.09.2016, 10:12
Re: Ban Command - by Tass007 - 24.09.2016, 11:00

Forum Jump:


Users browsing this thread: 1 Guest(s)