05.03.2013, 13:03
Hi. Today I'm gonna learn you how to protect your server against drive-by. First, open your gamemode and search(CTRL+F) "public OnPlayerDeath". This callback is called everytime someone dies. You must find something like this:
We see 3 arguments there :
We will use the IsPlayerInAnyVehicle function to check if the killer was in any vehicle when he killed the player. Like this:
Done, now let's do something about that. We will kick the player and inform him about why he's been kicked:
Done. If you have any problem just tell me.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
Код:
•playerid - the id of the one that just died. •killerid - the id of the killer •reason - we don't need this now
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerInAnyVehicle(killerid))
{
}
return 1;
}
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerInAnyVehicle(killerid))
{
SendClientMessage(killerid, 0xFF0000FF, "You have been kicked because you killed someone from the car(drive-by)");
Kick(killerid);
}
return 1;
}