Ban command
#10

To me it seems that the problem is here:
pawn Код:
GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SCM(playerid, red, "[U]: /ban playerid) reason)");
You are using GetPlayerName(PID...); before you actually assign a value to PID. So basically when you use GetPlayerName it is most likely getting the name of playerid 0 instead of the target player.

I would restructure your command like below and give it another try:
pawn Код:
CMD:ban(playerid, params[])
{
    if(pInfo[playerid][AL] < 2) return SCM(playerid, red, "[ERROR] No allow!");
    {
        if(sscanf(params, "us[64]", PID,reason)) return SCM(playerid, red, "[U]: /ban playerid) reason)");
        if(!IsPlayerConnected(PID))
        return SCM(playerid, -1, "[ERROR]: no player!");
        new PID;
        new reason[64];
        new str[128];
        new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Adminname, sizeof(Adminname));
        GetPlayerName(PID, Playername, sizeof(Playername));          
        format(str, sizeof(str), "%s has been banned by Administrator %s Reason: %s", Playername, Adminname, reason);
        SCMToAll(-1, str);
        Ban(PID);
    }
    return 1;
}
Reply


Messages In This Thread
Ban command - by Hunud - 30.09.2016, 13:55
Re: Ban command - by oMa37 - 30.09.2016, 13:59
Re: Ban command - by Hunud - 30.09.2016, 14:02
Re: Ban command - by oMa37 - 30.09.2016, 14:04
Re: Ban command - by Hunud - 30.09.2016, 14:06
Re: Ban command - by oMa37 - 30.09.2016, 14:13
Re: Ban command - by Gotham - 30.09.2016, 14:18
Re: Ban command - by Hunud - 30.09.2016, 14:22
Re: Ban command - by SyS - 30.09.2016, 15:26
Re: Ban command - by MEW273 - 30.09.2016, 15:29

Forum Jump:


Users browsing this thread: 3 Guest(s)