/kick command
#1

Код:
CMD:kick(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 2)
	{
		new string[128], giveplayerid, reason[64];
		if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin] && (PlayerInfo[giveplayerid][pHelper] >= 2 || PlayerInfo[giveplayerid][pAdmin] > 0) && playerid != giveplayerid)
			{
				format(string, sizeof(string), "AdmCmd: %s has been auto-kicked, reason: Trying to /kick a higher admin.", GetPlayerNameEx(playerid));
				ABroadCast(COLOR_YELLOW,string, (PlayerInfo[playerid][pAdmin] == 1) ? (1) : (2));
				Kick(playerid);
				return 1;
			}
			else
			{
				new year, month,day;
				getdate(year, month, day);
				new playerip[32];
				GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
				format(string, sizeof(string), "AdmCmd: %s (IP:%s) was kicked by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
				Log("logs/kick.log", string);
				if(PlayerInfo[playerid][pAdmin] == 1) Log("logs/moderator.log", string);
				format(string, sizeof(string), "AdmCmd: %s was kicked by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
				SendClientMessageToAllEx(COLOR_LIGHTRED, string);
				Kick(giveplayerid);
			}
			return 1;
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
	return 1;
}
Whenever I kick someone, it just displays Server Closed Connection and I am the one who got kicked not the target. Even when I try to /kick 99 (my id is 0) it just kicks myself, help please?
Reply
#2

Change:

PHP код:
if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin] && (PlayerInfo[giveplayerid][pHelper] >= || PlayerInfo[giveplayerid][pAdmin] > 0) && playerid != giveplayerid
to

PHP код:
if(PlayerInfo[giveplayerid][pAdmin] < PlayerInfo[playerid][pAdmin] && (PlayerInfo[giveplayerid][pHelper] >= || PlayerInfo[giveplayerid][pAdmin] > 0) && playerid != giveplayerid
Reply
#3

Ikbenremco is perfectly correct.
also, if u want to display a kick message before the kick, make a separate kick function, as samp , since 0.3x, has this issue, that if it reads KICK anywhere, it directly kicks the player. so if u do

sendclientmessage("blabla bla bla bla");
Kick(giveplayerid);

it wont display the message. it will directly kick the player.
but if u make some function (example KickFunc)
then if u type

sendclientmessage("blabla bla bla bla");
KickFunc(giveplayerid);

then it displays whatever has to be displayed, and kicks the player in the end. cheers
Reply
#4

Quote:
Originally Posted by ikbenremco
Посмотреть сообщение
Change:

PHP код:
if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin] && (PlayerInfo[giveplayerid][pHelper] >= || PlayerInfo[giveplayerid][pAdmin] > 0) && playerid != giveplayerid
to

PHP код:
if(PlayerInfo[giveplayerid][pAdmin] < PlayerInfo[playerid][pAdmin] && (PlayerInfo[giveplayerid][pHelper] >= || PlayerInfo[giveplayerid][pAdmin] > 0) && playerid != giveplayerid
Thanks, I'll recompile and see if it works.

Quote:
Originally Posted by RayDcosta
Посмотреть сообщение
Ikbenremco is perfectly correct.
also, if u want to display a kick message before the kick, make a separate kick function, as samp , since 0.3x, has this issue, that if it reads KICK anywhere, it directly kicks the player. so if u do

sendclientmessage("blabla bla bla bla");
Kick(giveplayerid);

it wont display the message. it will directly kick the player.
but if u make some function (example KickFunc)
then if u type

sendclientmessage("blabla bla bla bla");
KickFunc(giveplayerid);

then it displays whatever has to be displayed, and kicks the player in the end. cheers
Thank you as well! I've been looking for this, too bad I can't give out more reps. Maybe tomorrow for you guys.
Reply
#5

Quote:
Originally Posted by RayDcosta
Посмотреть сообщение
Ikbenremco is perfectly correct.
also, if u want to display a kick message before the kick, make a separate kick function, as samp , since 0.3x, has this issue, that if it reads KICK anywhere, it directly kicks the player. so if u do

sendclientmessage("blabla bla bla bla");
Kick(giveplayerid);

it wont display the message. it will directly kick the player.
but if u make some function (example KickFunc)
then if u type

sendclientmessage("blabla bla bla bla");
KickFunc(giveplayerid);

then it displays whatever has to be displayed, and kicks the player in the end. cheers
Can you tell me how to exactly do this? Sorry for being such a noob, but can you tell me where to make the functions and stuff.
Reply
#6

Quote:
Originally Posted by FlawPaw
Посмотреть сообщение
Can you tell me how to exactly do this? Sorry for being such a noob, but can you tell me where to make the functions and stuff.
Search for it.
Reply
#7

Код:
CMD:kick(playerid,params[])
{
	new string[128];
	new ID;
	new cmdreason[100];
	if(sscanf(params,"us[100]",ID,cmdreason))
	{
	    SendClientMessage(playerid,COLOR_ERROR,"USAGE: /adkick (Player Name/ID) (Reason)");
	    return 1;
	}
	if(!IsPlayerConnected(ID))
	{
	    format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot kick them.",ID);
	    SendClientMessage(playerid,COLOR_ERROR,string);
	    return 1;
	}
	Kicking[ID] =1;
	format(string,sizeof(string),"[ADMIN] %s(%d) has kicked %s(%d) from the server. Reason: %s.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
	SendClientMessageToAll(COLOR_ADMIN,string);

	format(string,sizeof(string),"9[ADMIN] Administrator has kicked %s(%d) from the server. Reason: %s.",PlayerName(ID),ID,cmdreason);
    IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
	SetTimer("KickPlayer",700,0);
	return 1;
}
+REP If Helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)