SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 23/08/2011, 03:05 PM   #1
[EDT]AmanSingh123
Big Clucker
 
Join Date: Oct 2010
Posts: 153
Reputation: 1
Default How to kick a player if he kills a player?

hey..

how do i make a script that when ever a player kills another player he gets a automatic kick and also it send all a message in chat box saying player has been kicked because of death-match and stuff you know help much appreciated..
[EDT]AmanSingh123 is offline  
Old 23/08/2011, 03:14 PM   #2
Wesley221
High-roller
 
Wesley221's Avatar
 
Join Date: Apr 2011
Posts: 1,564
Reputation: 714
Default Re: How to kick a player if he kills a player?

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendClientMessage(killerid, -1, "You have been kicked because you killed someone. ");
    Kick(killerid);
    return 1;
}
This is a quick example. Change it to the way you want
__________________
yes
Wesley221 is offline  
Old 23/08/2011, 03:25 PM   #3
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: How to kick a player if he kills a player?

Put this under OnPlayerDeath:

pawn Code:
new string[256];
new name[24];
GetPlayerName(killerid,name,24);
format(string,256,"%s has been kicked from the server for: Killing someone",name);
SendClientMessageToAll(-1,string);
Kick(killerid);
Tigerbeast11 is offline  
Old 23/08/2011, 03:28 PM   #4
Amit_B
Huge Clucker
 
Amit_B's Avatar
 
Join Date: Nov 2007
Location: Israel
Posts: 349
Reputation: 63
Default Re: How to kick a player if he kills a player?

Or with the message you asked (did you mean't to send it to everyone?):
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new str[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), " * %s has been kicked for killing someone", name);
    SendClientMessageToAll(0xFF0000FF, str);
    Kick(killerid);
    return 1;
}

Edit: Sorry, just replied at the same time of the reply above :S
The code above is good, but it's recommended to decrease the cells count of the string.
__________________
- Leading the Israeli SA-MP Community, SA-MP.co.il - SAMP-IL
- Currently working on the first anime project on SA-MP, Naruto Shippuden gamemode: #1, #2, #3

https://github.com/Amit-B/
Amit_B is offline  
Old 23/08/2011, 03:56 PM   #5
[EDT]AmanSingh123
Big Clucker
 
Join Date: Oct 2010
Posts: 153
Reputation: 1
Default Re: How to kick a player if he kills a player?

1 bug, when i do /kill it says "has been kick for killing someone" :S
[EDT]AmanSingh123 is offline  
Old 23/08/2011, 04:02 PM   #6
Tigerbeast11
Gangsta
 
Join Date: Aug 2009
Posts: 771
Reputation: 2
Default Re: How to kick a player if he kills a player?

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
    new str[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(str, sizeof(str), " * %s has been kicked for killing someone", name);
    SendClientMessageToAll(0xFF0000FF, str);
    Kick(killerid);
}
    return 1;
}

Try that, I'm not sure though
Tigerbeast11 is offline  
Old 23/08/2011, 04:16 PM   #7
[EDT]AmanSingh123
Big Clucker
 
Join Date: Oct 2010
Posts: 153
Reputation: 1
Default Re: How to kick a player if he kills a player?

bug again, /kill bug fixed ..

..but when i kill the messege displayed says the the guy killed name not the killers name
[EDT]AmanSingh123 is offline  
Old 23/08/2011, 04:19 PM   #8
Wesley221
High-roller
 
Wesley221's Avatar
 
Join Date: Apr 2011
Posts: 1,564
Reputation: 714
Default Re: How to kick a player if he kills a player?

Thats because you get your own name.
pawn Code:
GetPlayerName(killerid, name, sizeof(name));
You could have fixed it yourself i you just took a look at the code
__________________
yes
Wesley221 is offline  
Old 23/08/2011, 04:29 PM   #9
[EDT]AmanSingh123
Big Clucker
 
Join Date: Oct 2010
Posts: 153
Reputation: 1
Default Re: How to kick a player if he kills a player?

oops didnt see that, silly mistake..

also found another bug, if a player punches me and then i do /kill he gets kicked :/
[EDT]AmanSingh123 is offline  
Old 23/08/2011, 04:35 PM   #10
Pinguinn
Huge Clucker
 
Join Date: Aug 2011
Location: The Netherlands
Posts: 314
Reputation: 34
Default Re: How to kick a player if he kills a player?

Well I do have a fix for that, but then you can kill someone if you punch someting to death.
Does it bother if that happens?
Pinguinn is offline  
 

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
How can i know in the script when the player kills someone..? Ihsan_Cingisiz Help Archive 4 01/08/2010 08:55 AM
Getting The Player With The Highest Kills? GTA967 Help Archive 1 08/09/2009 10:54 PM
Getting the player with the most kills Gappy Help Archive 1 03/09/2009 10:54 AM
How to Get The Highest Kills Of The Player On the Server Bearfist Help Archive 2 10/05/2009 10:56 AM
player weapon kills / suicides dissapeared KnooL Help Archive 3 24/03/2009 04:56 PM


All times are GMT. The time now is 11:01 AM.


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