/ban command help
#1

I've pieced together a /ban command using a few commands I've found on the forums and reflecting on my own system, I would like somebody to simply fix a few strings for me.

I would like to edit the command to make it so that when I ban the person, it sends a message to the whole server:

"Admin ADMINNAME banned PLAYERNAME. [Reason: CUSTOM REASON]"

Help please guys, much appreciated.

pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >=1)
    {
            new string[200];
            new banner[24];
            if(isnull(params)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /ban [playername]");
            format(string,sizeof(string), "INFO: You have banned %s's account.", GetName(banner));
            SendClientMessage(playerid, COLOR_INFO, string);
            new INI:File = INI_Open(UserPath(playerid));
            INI_WriteInt(File,"Banned",1);
            INI_Close(File);
            Ban(playerid);
            return 1;
            }
            else return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are unauthorized to use this command.");
}
Reply
#2

pawn Код:
CMD:ban(playerid, params[])
{
    if (PlayerEnum[playerid][pAdminLevel] < 1)
    {
        SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are unauthorized to use this command.");
        return 1;
    }
    new targetid, reason[128], string[145];
    if (sscanf(params, "us[128]", targetid, reason))
    {
        SendClientMessage(playerid, COLOR_USAGE, "USAGE: /ban [playerid] [reason]");
        return 1;
    }
    format(string, sizeof(string), "INFO: You have banned %s's account.", GetName(targetid));
    SendClientMessage(playerid, COLOR_INFO, string);

    format(string, sizeof(string), "** Admin %s banned %s. [Reason: %s]", GetName(playerid), GetName(targetid), reason);
    SendClientMessageToAll(COLOR_INFO, string);
   
    new INI:file = INI_Open(UserPath(targetid));
    INI_WriteInt(file, "Banned", 1);
    INI_Close(file);

    return Ban(targetid);
}
Reply
#3

Whenever I type /ban 0 Test to test the command it just returns the SCM.
Reply
#4

Quote:
Originally Posted by SilencedPistol
Посмотреть сообщение
Whenever I type /ban 0 Test to test the command it just returns the SCM.
You must be using a older version of sscanf. Try this:

pawn Код:
CMD:ban(playerid, params[])
{
    if (PlayerEnum[playerid][pAdminLevel] < 1)
    {
        SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are unauthorized to use this command.");
        return 1;
    }
    new targetid, reason[128], string[145];
    if (sscanf(params, "us", targetid, reason))
    {
        SendClientMessage(playerid, COLOR_USAGE, "USAGE: /ban [playerid] [reason]");
        return 1;
    }
    format(string, sizeof(string), "INFO: You have banned %s's account.", GetName(targetid));
    SendClientMessage(playerid, COLOR_INFO, string);

    format(string, sizeof(string), "** Admin %s banned %s. [Reason: %s]", GetName(playerid), GetName(targetid), reason);
    SendClientMessageToAll(COLOR_INFO, string);
   
    new INI:file = INI_Open(UserPath(targetid));
    INI_WriteInt(file, "Banned", 1);
    INI_Close(file);

    return Ban(targetid);
}
Reply
#5

Thanks.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)