How to kick a player if he kills a player?
#1

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..
Reply
#2

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
Reply
#3

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);
Reply
#4

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.
Reply
#5

1 bug, when i do /kill it says "has been kick for killing someone" :S
Reply
#6

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
Reply
#7

bug again, /kill bug fixed ..

..but when i kill the messege displayed says the the guy killed name not the killers name
Reply
#8

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
Reply
#9

oops didnt see that, silly mistake..

also found another bug, if a player punches me and then i do /kill he gets kicked :/
Reply
#10

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?
Reply
#11

Quote:
Originally Posted by Pinguinn
View Post
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?
not at all, atleast they will get kick if they kill with guns
Reply
#12

I simply added a deathreason check. 0 = unarmed, '>' = anything above

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(reason > 0 && 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;
}
Reply
#13

what about to add " >= " instead of your " > " ?

simple
pawn Code:
if(reason >= 0 && killerid != // rest is same....
will that work?
Reply
#14

'>=' means equal and anything above
That means that reason '0' also counts.
And reason '0' = unarmed/fist
Reply
#15

so people will not be able to kill even with fists
isnt that what he wants?

EDIT: i very well know what that is used for
Reply
#16

Quote:
Originally Posted by emokidx111
View Post
so people will not be able to kill even with fists
isnt that what he wants?

EDIT: i very well know what that is used for
People might use /kill to get the other player kicked

Quote:
Originally Posted by [EDT]AmanSingh123
View Post
not at all, atleast they will get kick if they kill with guns
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)