.:[Help]:. /kick Command.
#1

Hello Guys , I'm Here Because I Want To Ask Your Help , Okay Let's Start Now.
I Got A Problem , Why I Type /kick It Just Kick Myself , But I'm Sure I Type Other's ID , Everytime It Just Keep Myself , I Can't Figure It Out , Guys Can You Help Me?

PHP код:
CMD:kick(playeridparams[])
{
    new 
targetid;
    new 
pID;
    new 
reason[128];
    new 
string27[256];
    new 
string28[256];
    if(
pInfo[playerid][Adminlevel] <= 0) return SendClientMessage(playeridCOLOR_RED"* You Have No Permission To Use This Command !");
    if(
sscanf(params"us"targetidreason))return SendClientMessage(playeridCOLOR_RED"[Usage]: /kick [PlayerID] [Reason]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_RED"* Player Is Not Connected !");
    
format(string27sizeof(string27), "%s {A8FFA8}%s {FF0000}Has Kicked {A8FFA8}%s. {FFFFFF}[Reason: %s]",ALevel(playerid), GetName(playerid), GetName(targetid), reason);
    
SendClientMessageToAll(COLOR_REDstring27);
    
format(string28sizeof(string28), "You Got Kicked By %s %s. {FFFFFF}[Reason: %s]",ALevel(playerid), GetName(playerid), reason);
    
SendClientMessage(pIDCOLOR_REDstring28);
    
SetTimerEx("DelayKick",1000,0,"i",pID);
    return 
1;
}
forward DelayKick(targetid);
public 
DelayKick(targetid)
{
    
Kick(targetid);
    return 
1;

Everytime I Just Kick Myself ... But I'm Not Type My ID On It Lol , I'm Sure I Type Another ID.

Sorry About My Bad/Poor English.
Reply
#2

Write it like this:

PHP код:
CMD:kick(playeridparams[])
{
    if(
pInfo[playerid][Adminlevel] <= 0) return SendClientMessage(playeridCOLOR_RED"* You Have No Permission To Use This Command !");
    new 
targetid,string[145],reason[128];
    if(
sscanf(params"us"targetidreason))return SendClientMessage(playeridCOLOR_RED"[Usage]: /kick [PlayerID] [Reason]");
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playeridCOLOR_RED"* Player Is Not Connected !");
    
format(stringsizeof(string), "%s {A8FFA8}%s {FF0000}Has Kicked {A8FFA8}%s. {FFFFFF}[Reason: %s]",ALevel(playerid), GetName(playerid), GetName(targetid), reason);
    
SendClientMessageToAll(COLOR_REDstring);
    
format(stringsizeof(string), "You Got Kicked By %s %s. {FFFFFF}[Reason: %s]",ALevel(playerid), GetName(playerid), reason);
    
SendClientMessage(targetidCOLOR_REDstring);
    
SetTimerEx("DelayKick",1000,0,"i",targetid);
    return 
1;

The mistake you made was, that pID = 0...u must use targetid
Reply
#3

Thanks Dude ! :3
Reply
#4

You should also add:

PHP код:
if(targetid == playerid) return SendClientMessage(playerid,-1,"You cannot kick yourself"); 
Because in the future you are going to kick someone,and you lets say "do mistake with id" (you will put your id) and you will kick yourself instead of that man
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)