Help with zcmd
#1

hi all i made my first command like /kick <playeri> <reason>
but when i type /kick server says unknown command why that ? i havent it under onplayercommandtext!

pawn Код:
CMD:kick(playerid,params[])
{
    new pID,Grund[50];
    if(Acc[playerid][Adminlevel]<2) return SendClientMessage(playerid,COLOR_RED,"You cannot use this Command");
    else if(sscanf(params,"uz",pID,Grund)) return SendClientMessage(playerid,COLOR_ORANGE,"Usage: /kick [playerid] ([reason])");
    else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"This Player is not Connected");
    else if(Acc[pID][Adminlevel] >3) return SendClientMessage(playerid,COLOR_RED,"You cannot kick this Admin");
    else
    {
        new Admin[24];
        GetPlayerName(playerid,Admin,sizeof Admin);
        new player[24];
        GetPlayerName(playerid,player,sizeof player);
        new s[100];
        format(s,sizeof s,"Server: %s (ID: %d) has kicked %s (ID: %d), reason: %s",Admin,playerid,player,pID,Grund[0] ? Grund : "No reason specified");
        SendClientMessageToAll(Color_AdmCmd,s);
        Kick(pID);
    }
    return 1;
}
Reply
#2

What is your admin system ? I can try help.
Try this :
pawn Код:
CMD:kick(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
            new kicked, reason[50];
            if(sscanf(params, "us[50]", kicked, reason)) return SendClientMessage(playerid, 0x00FF00AA, "USAGE: /kick [ID] [Reason]");
            if(kicked == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0x00FF00AA, "Invalid ID");
            new message[128];
            format(message, sizeof(message), "AdmCMD: %s was kicked by %s, reason: %s", ReturnPlayerName(kicked), ReturnPlayerName(playerid), reason);
            SendClientMessageToAll(0x00FF00AA, message);
            Kick(kicked);
    }
    return 1;
}
Reply
#3

my Admin Verrialbe are Acc[playerid][Adminlevel]
Reply
#4

try this
pawn Код:
CMD:kick(playerid,params[])
{
    new pID,Grund[50];
    if(Acc[playerid][Adminlevel]<2) return SendClientMessage(playerid,COLOR_RED,"You cannot use this Command");
    if(sscanf(params,"uz",pID,Grund)) return SendClientMessage(playerid,COLOR_ORANGE,"Usage: /kick [playerid] ([reason])");
    if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"This Player is not Connected");

        new Admin[24];
        GetPlayerName(playerid,Admin,sizeof Admin);
        new player[24];
        GetPlayerName(playerid,player,sizeof player);
        new s[100];
        format(s,sizeof s,"Server: %s (ID: %d) has kicked %s (ID: %d), reason: %s",Admin,playerid,player,pID,Grund[0] ? Grund : "No reason specified");
        SendClientMessageToAll(Color_AdmCmd,s);
        Kick(pID);
        else if(Acc[pID][Adminlevel] >3) return SendClientMessage(playerid,COLOR_RED,"You cannot kick this Admin");
   
    return 1;
}
Reply
#5

Be sure to write it under main() and OnGameModeInIt.
Reply
#6

Quote:
Originally Posted by Darnell
Посмотреть сообщение
Be sure to write it under main() and OnGameModeInIt.
ZCMD or any other command processors do not go in any callback.
Reply
#7

Don't have it within OnPlayerCommandText.. have it after it. A good way of doing CMD is putting the whole command at the end of your gamemode.
Reply
#8

Well, sorry, I'm new to scripting.
I just thought about it and you need to write it in the end of the gamemode.
EDIT:
Seems like Jack told him already :\.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)