Problem with /KICK system
#1

Hey!

My /kick cmd doesn't work. Actually, working with ID 0 only. Can someone repair it? THANKS!
And reason doesn't work too. ;/

This is Admin and VIP player (Mod) code:
pawn Код:
CMD:kick(playerid, params[])
    {
        if(Donator[playerid]) {
            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(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
                return SendClientMessage(playerid, RAUDONA, "Ћaidėjas neprisijungęs!");

            format(str, sizeof(str), "%s buvo iљmestas iљ serverio administratoriaus %s. Prieћastis: %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(RAUDONA, str); //send that message to all
        Kick(PID); //kick the playerid we've defined

        }
        else //if he has not got the permissions

        if(Moderas[playerid]) {
            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(!IsPlayerConnected(PID)) // if the ID is wrong or not connected, return a message! (PID used here)
                return SendClientMessage(playerid, RAUDONA, "Ћaidėjas neprisijungęs!");

            format(str, sizeof(str), "%s buvo iљmestas iљ serverio VIP ћaidėjo %s. Prieћastis: %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(RAUDONA, str); //send that message to all
        Kick(PID); //kick the playerid we've defined

        }
        return 1;
    }
Reply
#2

Basic concept of the KICK command....change the enums to whatever you like (admins, VIPs can kick or whatever)
pawn Код:
COMMAND:kick(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(PlayerInfo[playerid][pAdminDuty] == 1)
        {
            new pID, reason[64];
            if(!sscanf(params, "us", pID, reason))
            {
                new string[128];
                new adminname[MAX_PLAYER_NAME];
                new playername[MAX_PLAYER_NAME];

                GetPlayerName(playerid, adminname, sizeof(adminname));
                GetPlayerName(pID, playername, sizeof(playername));
                format(string, sizeof(string), "AdmCmd: %s has been kicked by %s, Reason:%s", playername, adminname, reason);
                SendClientMessageToAll(COLOR_RED, string);
                Kick(pID);
            }
            else return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [PlayerID/PartOfName] [Reason]");
        }
        else return SendClientMessage(playerid, COLOR_GREY, "You need to be on admin duty in order to use this feature (/aduty)");
    }
    else return SendClientMessage(playerid, COLOR_GREY, ".:: You are not authorised to use this command ::.");
    return 1;
}
Reply
#3

Have some errors in line number 3 (in your code)

error 001: expected token: ")", but found "["
error 029: invalid expression, assumed zero
error 017: undefined symbol "pAdmin"
fatal error 107: too many error messages on one line


It's possible to repair my code?
Reply
#4

Quote:
Originally Posted by kliukas
Посмотреть сообщение
Have some errors in line number 3 (in your code)

error 001: expected token: ")", but found "["
error 029: invalid expression, assumed zero
error 017: undefined symbol "pAdmin"
fatal error 107: too many error messages on one line


It's possible to repair my code?
On top of your code....place this:
pawn Код:
enum pInfo
{
    pAdmin
}

new PlayerInfo[MAX_PLAYERS][pInfo];
This is called an enum, a very good method/system to store variables...****** it for more explanation (I'd recommend wikipedia)
Reply
#5

Dude, I know, this annoying, but I'm green in pawno.. Can you give me a normal/working code? Or edit my old one.
Reply
#6

Quote:
Originally Posted by kliukas
Посмотреть сообщение
Dude, I know, this annoying, but I'm green in pawno.. Can you give me a normal/working code? Or edit my old one.
What do you mean you're green?
are the codes green colored? if so, you have made a comment on all the script or something..
If you mean you're NEW to pawn...well then, the code I gave you works fine.
Reply
#7

Hmm.. something wrong. Can you give me your skype or e-mail? I will sent you my .pwn file, because I tried anything but it's still don't work for my.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)