/ban [id] [REASON]
#1

pawn Код:
if(strcmp("/ban", cmd, true) == 0)
    {
        if(PlayerInfo[playerid][pAdminLevel] > 0)
        {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp)) SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /ban [id]");
            new id = strval(tmp);
            new pid = playerid;
            if(!IsPlayerConnected(id))
            {
                return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: This player is not online!");
            }
            if (id == pid) SendClientMessage(playerid,COLOR_GRAY,"[ADMIN]: You can not do this on yourself!");
            new globalmsg[100];
            new adminid[MAX_PLAYERS], victimid[MAX_PLAYERS];
            GetPlayerName(pid, adminid, sizeof(victimid));
            GetPlayerName(id, victimid, sizeof(victimid));
           
            format(globalmsg,sizeof(globalmsg),"[ADMIN]: Administrator %s has banned player %s for breaking the server rules.",adminid,victimid);
            SendClientMessageToAll(COLOR_LIGHTBLUE,globalmsg);
            PlayerInfo[id][pAccountLocked] = 1;
            Ban(id);
            return 1;
        }
        else
        {
            SendClientMessage(playerid,COLOR_GRAY,"You don't have authorization.");
            return 1;
        }
    }
I need to make a command like /ban [id][reason]. I already have /ban [id] but I dont know how to use more than 2 parameters, so any help is helpful further.
P.S: I'm thankful if you dont make it messy and bad identation.
Thanks to everyone.
Reply
#2

You can use https://sampwiki.blast.hk/wiki/Strmid for that

pawn Код:
new reason[128];
reason = "No Reason Given";
strmid(reason,cmdtext,6,strlen(cmdtext));
You might need to mess around with start/stop though.. testing it in your own script ftw

Ive added it as an example below

pawn Код:
format(globalmsg,sizeof(globalmsg),"[ADMIN]: Administrator %s has banned player %s for breaking the server rules. %s",adminid,victimid,reason);
SendClientMessageToAll(COLOR_LIGHTBLUE,globalmsg);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)