Ban and Kick
#4

move on with zcmd and sscanf2 much better ,

/kick /ban
pawn Код:
CMD:kick(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
    {
        new reason[24];
        new id;
        if(sscanf(params, "us[24]", id, reason)) return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}/kick (playerid/partofname) (reason)");
        else
        {
            new str[256];
            new Admin[MAX_PLAYER_NAME];
            new Target[MAX_PLAYER_NAME];

            GetPlayerName(id, Target, sizeof(Target));
            GetPlayerName(playerid, Admin, sizeof(Admin));

            format(str, sizeof(str), "[{B4B5B7}Admin{FF6347}]{B4B5B7}'%s has kick {FF6347}[{B4B5B7}Player{FF6347}]{B4B5B7}'%s. {FF6347}Reason; {B4B5B7}%s .", Admin, Target, reason);
            SendClientMessageToAll(lightred, str);

            Kick(id);
        }
    }
    else return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}You aren't authorized to use this command.");
    return 1;
}

#define grey        0xB4B5B7FF
#define lightred    0xFF6347AA

CMD:ban(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))
    {
        new id;
        new reason[128];
        if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}/ban (playerid/partofname) (reason)");
        if(PlayerInfo[playerid][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, lightred,"[{B4B5B7}System{FF6347}]: {B4B5B7}You cant ban an Administrator!");
        if(id == playerid) return SendClientMessage(playerid, lightred,"[{B4B5B7}System{FF6347}]: {B4B5B7}You cant ban yourself!");
        if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}Player not found!");
        else
        {
            new year;
            new month;
            new day;

            new hour;
            new minuite;
            new second;

            new str[1000];

            new Admin[MAX_PLAYER_NAME];
            new Target[MAX_PLAYER_NAME];

            getdate(year, month, day);
            gettime(hour,minuite,second);
            GetPlayerName(playerid, Admin, sizeof(Admin));
            GetPlayerName(id, Target, sizeof(Target));

            format(str, sizeof(str), "[{B4B5B7}Admin{FF6347}]{B4B5B7}'%s has ban {FF6347}[{B4B5B7}Player{FF6347}]{B4B5B7}'%s. {FF6347}Reason; {B4B5B7}%s .", Admin, Target, reason);
            SendClientMessageToAll(lightred, str);

            #define DIALOG_BAN  9706
            format(str, sizeof(str), "{FF6347}Admin Name: {B4B5B7}%s .\n{FF6347}Date: {B4B5B7}%d{FF6347}/{B4B5B7}%d{FF6347}/{B4B5B7}%d .\n{FF6347}Time: {B4B5B7}%d{FF6347}:{B4B5B7}%d .\n{FF6347}Reason: {B4B5B7}%s .", Admin, day, month, year, hour, minuite, reason);
            ShowPlayerDialog(id, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "Ban Notice", str, "OK", "");

            Ban(id);
        }
    }
    else return SendClientMessage(playerid, lightred, "[{B4B5B7}System{FF6347}]: {B4B5B7}You aren't authorized to use this command.");
    return 1;
}
Reply


Messages In This Thread
Ban and Kick - by nicholas1 - 09.12.2012, 22:26
Re: Ban and Kick - by HireMe - 09.12.2012, 22:52
Re: Ban and Kick - by nicholas1 - 10.12.2012, 00:11
Re: Ban and Kick - by Devilxz97 - 10.12.2012, 02:28
Re: Ban and Kick - by GoldZoroGrab - 10.12.2012, 10:26
Re: Ban and Kick - by Konstantinos - 10.12.2012, 10:36
Re: Ban and Kick - by nicholas1 - 11.12.2012, 00:57

Forum Jump:


Users browsing this thread: 1 Guest(s)