/ban help
#2

Here you go:

pawn Код:
if(strcmp(cmd, "/ban", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/PartOfName] [reason]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerNPC(giveplayerid)) return 1;
            if(PlayerInfo[playerid][pAdmin] >= 1)
            {
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        new length = strlen(cmdtext);
                        while ((idx < length) && (cmdtext[idx] <= ' '))
                        {
                            idx++;
                        }
                        new offset = idx;
                        new result[96];
                        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                        {
                            result[idx - offset] = cmdtext[idx];
                            idx++;
                        }
                        result[idx - offset] = EOS;
                        if(!strlen(result))
                        {
                            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/PartOfName] [reason]");
                            return 1;
                        }
                        new logstring[256];
                        new year, month, day;
                        getdate(year, month, day);
                        if(AdmCmdProtection[playerid] > 4)
                        {
                            RemovePlayerAdmin(playerid);
                            format(logstring, sizeof(logstring), "[ADMIN][IP]:[%s] [DATE]:[%d/%d/%d] [Admin]:[%s]:[Command Spam (/ban)].", GetPlayerIpEx(playerid),day,month,year,PlayerName(playerid));
                            Log("Logs/admin.log", logstring);
                            return 1;
                        }
                        if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
                        {
                            RemovePlayerAdmin(playerid);
                            format(logstring, sizeof(logstring), "[ADMIN][IP]:[%s] [DATE]:[%d/%d/%d] [Admin]:[%s]:[Attempting to ban a higher Admin].", GetPlayerIpEx(playerid),day,month,year,PlayerName(playerid));
                            Log("Logs/admin.log", logstring);
                            return 1;
                        }
                        if(AdminOnDuty[playerid] == false)
                        {
                            format(string, sizeof(string), "AdmCmd: %s was banned by an Admin, reason: %s", GetPlayerNameEx(giveplayerid), result);
                        }
                        else if(AdminOnDuty[playerid] == true)
                        {
                            format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid),GetPlayerNameEx(playerid), result);
                        }
                        SendClientMessageToAll(COLOR_LIGHTRED, string);
                        AdmCmdProtection[playerid]++;
                        BanPlayer(playerid, giveplayerid, result, 1);
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "The player you are looking for is Offline.");
                }
            }
            else
            {
                InvalidCommandAcces(playerid);
                return 1;
            }
        }
        return 1;
    }
Reply


Messages In This Thread
/ban help - by Chiao - 31.05.2013, 14:06
Re: /ban help - by Stanford - 31.05.2013, 15:25
Re: /ban help - by Konstantinos - 31.05.2013, 15:30
Re: /ban help - by Stanford - 31.05.2013, 15:36

Forum Jump:


Users browsing this thread: 1 Guest(s)