SA-MP Forums Archive
Command Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Command Help (/showthread.php?tid=260817)



Command Help - Vero - 10.06.2011

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?


Re: Command Help - Mike Garber - 10.06.2011

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).


Re: Command Help - SpiderWalk - 10.06.2011

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;
}



Re: Command Help - Vero - 10.06.2011

Thanks


Re: Command Help - xRyder - 10.06.2011

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)" );