.:[Help]:. /kick Command. -
TuSheng - 23.03.2015
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(playerid, params[])
{
new targetid;
new pID;
new reason[128];
new string27[256];
new string28[256];
if(pInfo[playerid][Adminlevel] <= 0) return SendClientMessage(playerid, COLOR_RED, "* You Have No Permission To Use This Command !");
if(sscanf(params, "us", targetid, reason))return SendClientMessage(playerid, COLOR_RED, "[Usage]: /kick [PlayerID] [Reason]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "* Player Is Not Connected !");
format(string27, sizeof(string27), "%s {A8FFA8}%s {FF0000}Has Kicked {A8FFA8}%s. {FFFFFF}[Reason: %s]",ALevel(playerid), GetName(playerid), GetName(targetid), reason);
SendClientMessageToAll(COLOR_RED, string27);
format(string28, sizeof(string28), "You Got Kicked By %s %s. {FFFFFF}[Reason: %s]",ALevel(playerid), GetName(playerid), reason);
SendClientMessage(pID, COLOR_RED, string28);
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.
AW: .:[Help]:. /kick Command. -
Kaliber - 23.03.2015
Write it like this:
PHP код:
CMD:kick(playerid, params[])
{
if(pInfo[playerid][Adminlevel] <= 0) return SendClientMessage(playerid, COLOR_RED, "* You Have No Permission To Use This Command !");
new targetid,string[145],reason[128];
if(sscanf(params, "us", targetid, reason))return SendClientMessage(playerid, COLOR_RED, "[Usage]: /kick [PlayerID] [Reason]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "* Player Is Not Connected !");
format(string, sizeof(string), "%s {A8FFA8}%s {FF0000}Has Kicked {A8FFA8}%s. {FFFFFF}[Reason: %s]",ALevel(playerid), GetName(playerid), GetName(targetid), reason);
SendClientMessageToAll(COLOR_RED, string);
format(string, sizeof(string), "You Got Kicked By %s %s. {FFFFFF}[Reason: %s]",ALevel(playerid), GetName(playerid), reason);
SendClientMessage(targetid, COLOR_RED, string);
SetTimerEx("DelayKick",1000,0,"i",targetid);
return 1;
}
The mistake you made was, that pID = 0...u must use targetid
Re: .:[Help]:. /kick Command. -
TuSheng - 23.03.2015
Thanks Dude ! :3
Re: .:[Help]:. /kick Command. -
NoDi522 - 23.03.2015
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