Why does it kick myself? -
saffierr - 31.03.2015
The cmd works fine except one thing;
When I type /kick 0, it kicks me... whilst I scripted not to kick my self, lol.
PHP код:
CMD:kick(playerid, params[])
{
new targetplayer;
if(IsPlayerAdmin(playerid))
{
if(sscanf(params, "u", targetplayer))
return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /kick [ID] [REASON]");
if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected!");
if(targetplayer == playerid)
SendClientMessage(playerid, COLOR_RED, "You cannot kick yourself!");
new string[64];
format(string, sizeof string, "%s has been kicked by an admin!", Kick(targetplayer));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
}
else
{
SendClientMessage(playerid, -1, "SERVER: Unknown command.");
}
return 1;
}
Re: Why does it kick myself? -
CalvinC - 31.03.2015
First, you should use GetPlayerName to display the name in the format.
Second, you should use a timer of about 100 ms before you kick the player, otherwise the message wont get displayed to the kicked player.
Re: Why does it kick myself? -
ATGOggy - 31.03.2015
Try this:
PHP код:
CMD:kick(playerid, params[])
{
new targetplayer;
if(IsPlayerAdmin(playerid))
{
if(sscanf(params, "u", targetplayer))
return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /kick [ID] [REASON]");
if(!IsPlayerConnected(targetplayer)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected!");
if(targetplayer == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot kick yourself!");
new string[64];
format(string, sizeof string, "%s has been kicked by an admin!", Kick(targetplayer));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
}
else
{
SendClientMessage(playerid, -1, "SERVER: Unknown command.");
}
return 1;
}
Re: Why does it kick myself? -
NoDi522 - 31.03.2015
PHP код:
#include <a_samp>
#include <zcmd> // need this
#include <sscanf> // need this
CMD:kick(playerid,params[])
{
new targetid,name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],msg[128],msg2[128],msg3[128];
{
if(sscanf(params,"u",targetid)) return SendCLientMessage(playerid,-1,"syntax: /kick [ID/name]");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You are not admin");
if(IsPlayerAdmin(ID)) return SendClientMessage(playerid,-1,"You cannot kick other administrators");
else if(targetid == playerid) return SendClientMessage(playerid,-1,"You cannot kick yourself");
else
{
GetPlayerName(ID,name,sizeof(name)); // We take targetid's name
format(msg,sizeof(poruka),"You kicked %s from the server",name); // formating messages which will be sent to you
SendClientMessage(playerid,-1,poruka); // sent
GetPlayerName(playerid,name2,sizeof(name2)); //we take your name
format(msg2,sizeof(poruka2),"%s just kicked you from the server",name); // we send message to target
SendClientMessage(ID,-1,poruka2); // sent
format(msg3,sizeof(msg3),"%s kicked %s from the server",name2,name); // formating message to send for all
SendClientMessageToAll(-1,msg3); // sent
{
Kick(ID);
}
}
return 1;
}
}
Here is an example. If you give me your enum i can make it more complicate.
Re: Why does it kick myself? -
saffierr - 31.03.2015
This has been fixed!