need help with ban and kick cmd using zcmd
#1

Can someone help me make a kick cmd for a lvl 1 admin and a ban cmd for a lvl 2?
Reply
#2

And we are supposed to do that how?

Show us some of your code.
Reply
#3

Sure, show us your attempt at making one, and we'll be glad to help.

How are we supposed to know what a lvl 1 admin is in your script without code...?
Reply
#4

What's your enums ?

pawn Код:
CMD:kick(playerid, params[])
    {
        new id, reason[128];
        if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You're not authorized to use this command!");
        else if(sscanf(params, "us", id, reason))SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /kick [id/name][reason]");
        else if(id==playerid)SendClientMessage(playerid,COLOR_LIGHTBLUE,"Error: You can not kick yourself!");
        else if(IsPlayerAdmin(id))SendClientMessage(playerid,COLOR_LIGHTBLUE,"Error: You can not kick another admin!");
        else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_LIGHTBLUE,"Error: Player is not connected!");
        else {
            new Name[MAX_PLAYER_NAME], KickMessage[128];
            new Name2[MAX_PLAYER_NAME];
            GetPlayerName(playerid, Name, sizeof(Name));
            GetPlayerName(id, Name2, sizeof(Name2));
            format(KickMessage, sizeof(KickMessage), "Administrator %s(%d) has kicked player %s(%d)| Reason: %s", Name, playerid, Name2, id);
            SendClientMessageToAll(COLOR_LIGHTBLUE, KickMessage);
            Kick(id);
        }
        return 1;
    }

    CMD:ban(playerid,params[])
    {
                        if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "You're not authorized to use this command!");
                 {
                 new id;
                 new tmp[256], tmp2[256], Index;
                 tmp = strtok(params,Index), tmp2 = strtok(params,Index);
                 if(isnull(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /ban [id/name] [reason]"); //Check If Player Does Not Added "Reason and the ID"
                 if(IsPlayerAdmin(id))SendClientMessage(playerid,COLOR_LIGHTBLUE,"Error: You can not kick another admin!");
                 if(id==playerid)SendClientMessage(playerid,COLOR_LIGHTBLUE,"Error: You can not kick yourself!");
                 new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
                 player1 = strval(tmp); // << player1 = ID of The Player
                 if(!IsPlayerConnected(player1)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Error: Player is not connected!"); //<< Check If Player Connected Or Not
                 GetPlayerName(player1, playername, sizeof(playername)); //get Selected Player Name
                 GetPlayerName(playerid, adminname, sizeof(adminname)); //get Admin Name Who Use This command
                 format(string,sizeof(string),"Administrator %s has banned %s | Reason ( %s )",adminname,playername,params[2]); //adminname = the player Who Use This command || playername = the Player who Going To Be kicked || params[2] = The Reason Of The Kick
                 SendClientMessageToAll(COLOR_LIGHTBLUE,string); // Send Message To all Players.
                 Ban(player1);
                 }
                 else return SendClientMessage(playerid,COLOR_LIGHTBLUE,"You're not authorized to use this command!"); // This Code return the Player IF he's not Login in as RCON admin
                 return 1;
    }
Show us your

pawn Код:
enum smth here,
pLevel

or smth
Reply
#5

on top of the script:
pawn Код:
enum pInfo
{
pAdmin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
kick command:
pawn Код:
CMD:kick(playerid, params[])
    {
        if(PlayerInfo[playerid][pAdmin] >= 1) {
            new PID; //define the playerid we wanna kick
            new reason[64]; //the reason, put into a string
            new str[128]; //a new message string
            new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
            GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
            GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)

            if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
                return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");

            format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
        SendClientMessageToAll(COLOR_RED, str); //send that message to all
        Kick(PID); //kick the playerid we've defined

        }
        else //if he has not got the permissions
        {
            SendClientMessage(playerid, COLOR_GREY, "You have to be level 1 to use that command!"); //return this message
        }
        return 1;
    }
ban command:
pawn Код:
CMD:ban(playerid, params[])
    {
        if(PlayerInfo[playerid][pAdmin] >= 2) {
            new PID; //define the playerid we wanna ban
            new reason[64]; //the reason, put into a string
            new str[128]; //a new message string
            new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
            GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
            GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)

            if(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
                return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");

            format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
        SendClientMessageToAll(COLOR_RED, str); //send that message to all
        Ban(PID); //Ban the playerid we've defined

        }
        else //if he has not got the permissions
        {
            SendClientMessage(playerid, COLOR_GREY, "You have to be level 2 to use that command!"); //return this message
        }
        return 1;
    }
copied from: http://forum.sa-mp.com/showpost.php?...41&postcount=1

Next time search before asking any question
Reply
#6

My enums are

Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#7

Ok cmds made thank you all
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)