SA-MP Forums Archive
/ban command help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /ban command help (/showthread.php?tid=440235)



/ban command help - SilencedPistol - 28.05.2013

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.");
}



Re: /ban command help - Emmet_ - 28.05.2013

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);
}



Re: /ban command help - SilencedPistol - 28.05.2013

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


Re: /ban command help - Emmet_ - 29.05.2013

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);
}



Re: /ban command help - SilencedPistol - 29.05.2013

Thanks.