Command Help
#1

pawn Код:
command(kick, playerid, params[])
{
    new string[128];
    new ID;
    new pname[24];
    new aname[24];
    new explan[128];
    GetPlayerName(ID, pname, sizeof(pname));
    GetPlayerName(playerid,aname,24);

    if( PlayerInfo[playerid][Admin] >= 1)
    {
        if(sscanf(params, "i", ID, explan))
        {
            SendClientMessage(playerid, COLOUR_ORANGE, "Hint: /kick (playerid)(reason)" );
            return 1;
        }
        if(!IsPlayerConnected(ID))
        {
            SendClientMessage(playerid, COLOUR_ORANGE, "Hint: Invalid Player ID");
            return 1;
        }
        format(string, sizeof(string), "%s (%d) has been kicked by Admin %s", pname, ID, aname, explan);
        SendClientMessageToAll(ADMIN_WARNING, string);
        Kick(ID);
    }
    return 1;
}
I've tried to make this command so that there needs to be a reason for the kick, but it isn't working. Is there anyone that could help me?
Reply
#2

pawn Код:
if(sscanf(params, "i", ID, explan)) return SendClientMessage(playerid, COLOUR_ORANGE, "Hint: /kick (playerid)(reason)" );
return cuts the code below (it doesn't execute anymore code after this).
Reply
#3

hmm
i use this one
pawn Код:
dcmd_kick(playerid,params[])
{
        new id,n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
        new tmp[256], Index, str[49];
        tmp = strtok(params,Index), id = strval(tmp);
        GetPlayerName(id,on,sizeof(on));
        GetPlayerName(playerid,n,sizeof(n));
        if(PInfo[playerid][Level] < 1) return SendClientMessage(playerid,ORANGE,"You need to be level 1 to use this command!");
        if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /kick <ID> [reason] ");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
        format(str,sizeof(str),"<<Admin>>%s has kicked %s<<>>Reason: %d",n,on);
        SendClientMessageToAll(LIGHTBLUE,str);
        Kick(id);
        return 1;
}
Reply
#4

Thanks
Reply
#5

Quote:
Originally Posted by Mike Garber
Посмотреть сообщение
pawn Код:
if(sscanf(params, "i", ID, explan)) return SendClientMessage(playerid, COLOUR_ORANGE, "Hint: /kick (playerid)(reason)" );
return cuts the code below (it doesn't execute anymore code after this).
No, you need to define string to sscanf like:

pawn Код:
if(sscanf(params, "is[128]", ID, explan)) return SendClientMessage(playerid, COLOUR_ORANGE, "Hint: /kick (playerid)(reason)" );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)