SA-MP Forums Archive
Kick Command - 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)
+--- Thread: Kick Command (/showthread.php?tid=440334)



Kick Command - Dare Devil..... - 29.05.2013

For some reason I want that if player is near to admin only then he can be kicked otherwise it should give an error any sort of help?

pawn Код:
CMD:kick(playerid,params[])
{
    new id,name1[MAX_PLAYER_NAME], reason[35],name2[MAX_PLAYER_NAME], string[128];
    if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
    if(sscanf(params,"uz",id,reason)) return SCM(playerid, COLOR_WHITE,"USAGE: /kick [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_GREY,"Invalid player id");
    else
    {
        GetPlayerName(playerid,name1,sizeof(name1));
        GetPlayerName(id,name2,sizeof(name2));
        format(string, sizeof(string),"AdmCmd: %s was kicked by %s, reason: %s",name2,name1,reason);
        SendClientMessageToAll(COLOR_LIGHTRED,string);
        Kick(id);
    }
    return 1;
}



Re: Kick Command - Konewka - 29.05.2013

Use that: https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint

pawn Код:
CMD:kick(playerid,params[])
{
    new id,name1[MAX_PLAYER_NAME], reason[35],name2[MAX_PLAYER_NAME], string[128];
    new Float:posx, Float:posy, Float:posz;
    if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
    if(sscanf(params,"uz",id,reason)) return SCM(playerid, COLOR_WHITE,"USAGE: /kick [playerid/partofname] [reason]");
    if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_GREY,"Invalid player id");
    GetPlayerPos(playerid, posx, posy, posz);
    if(!IsPlayerInRangeOfPoint(id, 5.0, posx, posy, posz) return SCM(playerid, COLOR_GREY, "Player is not in your range.");
    else
    {
        GetPlayerName(playerid,name1,sizeof(name1));
        GetPlayerName(id,name2,sizeof(name2));
        format(string, sizeof(string),"AdmCmd: %s was kicked by %s, reason: %s",name2,name1,reason);
        SendClientMessageToAll(COLOR_LIGHTRED,string);
        Kick(id);
    }
    return 1;
}