SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 30/12/2013, 01:35 PM   #1
Bost
Little Clucker
 
Join Date: Oct 2011
Posts: 47
Reputation: 0
Question Kick Command

Here is my /kick command.

Code:
//---------------------------------------------[Kick]-----------------------------------------------------
    if(strcmp(cmd, "/kick", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /kick [playerid/PartOfName] <reason>");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(giveplayerid != playerid && Untouchable[giveplayerid]) return SendClientMessage(playerid, COLOR_GREY, "* You Can't Do this on This player!");
      		new targetlevel = PlayerInfo[giveplayerid][pAdmin];
			new playerlevel = PlayerInfo[playerid][pAdmin];
			if(targetlevel > playerlevel) return SendClientMessage(playerid, COLOR_GREY, "* You can not Kick People that is higher Than You!");
			if (PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid))
			{
				if(IsPlayerConnected(giveplayerid))
				{
				    if(giveplayerid != INVALID_PLAYER_ID)
				    {
					    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
						new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[128];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							new y, m, d;
							new h,mi,s;
							getdate(y,m,d);
							gettime(h,mi,s);
							format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has been kicked by %s, No Reason Given",d,m,y,h,mi,s,giveplayer,sendername);
							KickLog(string);
							format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Kicked by %s - No Reason Given.",d,m,y,h,mi,s,sendername);
							AddPunishment(giveplayerid, string);
							format(string, sizeof(string), "%s (%d), Has been kicked by Administrator %s, No Reason Given", giveplayer, giveplayerid, sendername);
							SendClientMessageToAll(COLOR_NICERED, string);
							format(string, sizeof(string), "You have Been Kicked by Administrator %s, No Reason Given", sendername);
							SendClientMessage(giveplayerid,COLOR_LIGHTBLUE, string);
	 						SafeSetPlayerPos(giveplayerid,264.6288,77.5742,1001.0391);
			                SafeSetPlayerInterior(giveplayerid, 6);
							GameTextForPlayer(giveplayerid, "~r~~h~Admin Kicked: ~n~~r~No Reason Given", 6000, 3);
							//SetTimerEx("KickPlayer", 1000, false, "i", playerid);
							Kick(giveplayerid);
							return 1;
						}
						new y, m, d;
						new h,mi,s;
						getdate(y,m,d);
						gettime(h,mi,s);
						format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has been kicked by %s for: %s",d,m,y,h,mi,s,giveplayer,sendername, (result));
						KickLog(string);
						format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] Kicked by %s - Reason: %s",d,m,y,h,mi,s,sendername,(result));
						AddPunishment(giveplayerid, string);
						format(string, sizeof(string), "%s (%d), Has been kicked by Administrator %s for: %s", giveplayer, giveplayerid, sendername, (result));
						SendClientMessageToAll(COLOR_NICERED, string);
						format(string, sizeof(string), "You have Been Kicked by Administrator %s for: %s", sendername, (result));
						SendClientMessage(giveplayerid,COLOR_LIGHTBLUE, string);
 						SafeSetPlayerPos(giveplayerid,264.6288,77.5742,1001.0391);
		                SafeSetPlayerInterior(giveplayerid, 6);
 						format(string, sizeof(string), "~r~~h~Admin Kicked: ~n~~r~%s",(result));
						GameTextForPlayer(giveplayerid, string, 6000, 3);
						//SetTimerEx("KickPlayer", 1000, false, "i", playerid);
						Kick(giveplayerid);
						return 1;
					}
				}
			}
			else
			{
				format(string, sizeof(string), "** %d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
So..
When I kick someone I want him to get the reason why he is kicked.
How to do it?
__________________
Boooooooooooooooooooooooooo
Bost is offline   Reply With Quote
Old 30/12/2013, 01:52 PM   #2
Hansrutger
Gangsta
 
Hansrutger's Avatar
 
Join Date: May 2011
Location: Sweden
Posts: 761
Reputation: 161
Default Re: Kick Command

Set a timer dear! :P

I recommend:
- Use anything faster than normal string compere, for your own sake and for the users experiences as well!
- You can use any timer but a normal SetTimerEx would do, no need for an "accurate" timer when doing this.

What you want to do:
- Make the player get the message.
- Let them wait like 2 seconds or 1 second (this is where the timer comes in).
- Kick them once the timer is over.

Example of a timer that would do this:
SetTimerEx("kickFunc", 2000, false, "i", giveplayerid);

OR! If you want to use _Emmets newest and hotest invention of timers that would solve your problem check it out here: http://forum.sa-mp.com/showthread.ph...ighlight=emmet (recommended!)

And yes I won't post the actual code because I believe that is your job!
__________________


Hansrutger is offline   Reply With Quote
Old 30/12/2013, 02:01 PM   #3
Bost
Little Clucker
 
Join Date: Oct 2011
Posts: 47
Reputation: 0
Default Re: Kick Command

Can you make the command for me please?
__________________
Boooooooooooooooooooooooooo
Bost is offline   Reply With Quote
Old 30/12/2013, 02:15 PM   #4
Hansrutger
Gangsta
 
Hansrutger's Avatar
 
Join Date: May 2011
Location: Sweden
Posts: 761
Reputation: 161
Default Re: Kick Command

Lol you even already have a timer in your command, just higher its seconds and it should work. ^^
__________________


Hansrutger is offline   Reply With Quote
Old 30/12/2013, 02:30 PM   #5
newbie scripter
Gangsta
 
newbie scripter's Avatar
 
Join Date: Apr 2012
Location: Heaven <3
Posts: 798
Reputation: 34
Default Re: Kick Command

Quote:
Originally Posted by Hansrutger View Post
Lol you even already have a timer in your command, just higher its seconds and it should work. ^^
No need to higher it, just uncomment it.

Change all
pawn Code:
//SetTimerEx("KickPlayer", 1000, false, "i", playerid);
Into
pawn Code:
SetTimerEx("KickPlayer", 1000, false, "i", playerid);
__________________
SUGGESTION FOR FUTURE SA-MP
pawn Code:
forward SetWeaponRange(weaponid, maxrange); // if weapon is fist and 100 range, it may give a warn or super punch xD
forward SetWeaponRecoil(weapoinid, maxrecoil);
newbie scripter is offline   Reply With Quote
Old 30/12/2013, 02:37 PM   #6
Mattakil
Gangsta
 
Mattakil's Avatar
 
Join Date: Jan 2012
Location: Canada
Posts: 691
Reputation: 15
Default Re: Kick Command

Hint: Don't copy Godfather, you'll thank me later.
Mattakil is offline   Reply With Quote
Old 30/12/2013, 03:00 PM   #7
Bost
Little Clucker
 
Join Date: Oct 2011
Posts: 47
Reputation: 0
Default Re: Kick Command

Quote:
Originally Posted by newbie scripter View Post
No need to higher it, just uncomment it.

Change all
pawn Code:
//SetTimerEx("KickPlayer", 1000, false, "i", playerid);
Into
pawn Code:
SetTimerEx("KickPlayer", 1000, false, "i", playerid);
I've tried like you said and it simple close the connection to the server.
__________________
Boooooooooooooooooooooooooo
Bost is offline   Reply With Quote
Old 30/12/2013, 03:40 PM   #8
JJB562
Big Clucker
 
Join Date: Aug 2011
Posts: 186
Reputation: 22
Default Re: Kick Command

You wrote the wrong player ID in the SetTimerEx function; it should be:
pawn Code:
SetTimerEx("KickPlayer", 1000, false, "i", giveplayerid);

Then remove this line:
pawn Code:
Kick(giveplayerid);
The reason for this is because this would cause the player to get kicked before getting the message.
__________________
JJB562 is offline   Reply With Quote
Old 30/12/2013, 04:07 PM   #9
Bost
Little Clucker
 
Join Date: Oct 2011
Posts: 47
Reputation: 0
Default Re: Kick Command

Quote:
Originally Posted by JJB562 View Post
You wrote the wrong player ID in the SetTimerEx function; it should be:
pawn Code:
SetTimerEx("KickPlayer", 1000, false, "i", giveplayerid);

Then remove this line:
pawn Code:
Kick(giveplayerid);
The reason for this is because this would cause the player to get kicked before getting the message.
If I do like this it only gives me the reason but dosen't close the server connection.
__________________
Boooooooooooooooooooooooooo
Bost is offline   Reply With Quote
Old 30/12/2013, 05:42 PM   #10
Kyance
Gangsta
 
Kyance's Avatar
 
Join Date: Mar 2013
Posts: 817
Reputation: 92
Default Re: Kick Command

Quote:
Originally Posted by Bost View Post
If I do like this it only gives me the reason but dosen't close the server connection.
pawn Code:
forward KickTimer(playerid); //local(Before any callback)
pawn Code:
public KickTimer(playerid)
{
    Kick(playerid);
    return 1;
}
pawn Code:
//At the kick command:
SetTimerEx("KickTimer", 1000, false, "i", id); //the id(targetid) will be kicked after 1 second
Try the kick command now.
__________________
I'm amazed how you people are still wasting your time on a decade old game.
Kyance is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Made /kick Command to Kick Player from Virtual World... MAFIAWARS Scripting Help 11 28/09/2013 03:39 PM
Kick Command Dare Devil..... Scripting Help 1 29/05/2013 11:49 AM
[Help]: Kick command! Areax Scripting Help 7 25/05/2013 01:37 PM
/Kick Command. KolleMan Scripting Help 9 09/11/2012 04:13 PM
Help with /kick command. Vic1990 Scripting Help 3 27/11/2011 04:56 AM


All times are GMT. The time now is 04:07 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.