Help with Spawnkilling
#1

Hello. How to make like, when a player kills someone on the spawn, that player who killed, gets automaticly killed for killing other player on spawn?

I don't want spawn protection for seconds, I need that the killer player could be automaticly killed.
Reply
#2

PHP код:
#include a_samp
new spawn[MAX_PLAYERS];
public 
OnPlayerSpawn(playerid)
{
    
SetTimerEx("AntiSpawnkill",5000,0,"i",playerid);
    
spawn[playerid]= true;
    return 
1;
}
forward AntiSpawnkill(playerid);
public 
AntiSpawnkill(playerid)
{
    
spawn[playerid]= false;
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
spawn[playerid])
    {
        
Kick(killerid);
    }
    return 
1;

Change 5000 with the time you want in ms
Reply
#3

Sorry, but that does not work..
Reply
#4

Hello!

Do you want a NO-DM zone or that the player don't get damaged for few seconds?
Reply
#5

public OnPlayerShootPlayer(Shooter,Target,Float:HealthLos t,Float:ArmourLost)
{
if (IsPlayerInRangeOfPoint(Target, 2.0, ZombieSpawnX, ZombieSpawnY, ZombieSpawnZ))
{
new Float:health;
GetPlayerHealth(Shooter,health);
SetPlayerHealth(Shooter, health-5);
}
return 1;
}
Reply
#6

public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
SetPlayerHealth(killerid,0);
}
return 1;
}
Reply
#7

Why

This not work ?
PHP код:
#include a_samp
new bool:spawn[MAX_PLAYERS];
public 
OnPlayerSpawn(playerid)
{
    
SetTimerEx("AntiSpawnkill",40000,0,"i",playerid);
    
spawn[playerid]= true;
    return 
1;
}
forward AntiSpawnkill(playerid);
public 
AntiSpawnkill(playerid)
{
    
spawn[playerid]= false;
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
spawn[playerid] == true)
    {
        
SetPlayerHealth(killerid,0.0); 
    }
    return 
1;

Reply
#8

PHP код:
public OnPlayerDeath(playerid,killerid,reason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
        if(
IsPlayerInArea(playerid,XX,XX,XX,XX))
        {
            
SetPlayerHealth(killerid,0.0);
        }
    }
    return 
1;
}
/* Notes:
- The XX,XX,XX,XX are the coordinates
(1. XX => MinX)
(2. XX => MinY)
(3. XX => MaxX)
(4. XX => MaxY)
- Use this function at the end of this codes
*/
//This is the function which you need:
IsPlayerInArea(playeridFloat:MinXFloat:MinYFloat:MaxXFloat:MaxY)
{
    new 
Float:XFloat:YFloat:Z;
    
GetPlayerPos(playeridXYZ);
    if(
>= MinX && <= MaxX && >= MinY && <= MaxY) {
        return 
1;
    }
    return 
0;

https://sampforum.blast.hk/showthread.php?tid=222283 => This is the function with a good tutorial.
If you need help, you can ask here.
Reply
#9

Nothing worked.. I just saw this kind of feature in one zombie server, where for example, team human kills a team zombie on their spawn, team human gets auto-killed for doing that. There is mapchange system, after when every certain time ends, the new round starts and map changes, so as the team spawns.
Reply
#10

Take my code.
PHP код:
public OnPlayerDeath(playerid,killerid,reason

    if(
killerid != INVALID_PLAYER_ID
    { 
        if(
IsPlayerInArea(playerid,XX,XX,XX,XX)) 
        { 
            
SetPlayerHealth(killerid,0.0); 
        } 
    } 
    return 
1

/* Notes: 
- The XX,XX,XX,XX are the coordinates 
(1. XX => MinX) 
(2. XX => MinY) 
(3. XX => MaxX) 
(4. XX => MaxY) 
- Use this function at the end of this codes 
*/ 
//This is the function which you need: 
IsPlayerInArea(playeridFloat:MinXFloat:MinYFloat:MaxXFloat:MaxY

    new 
Float:XFloat:YFloat:Z
    
GetPlayerPos(playeridXYZ); 
    if(
>= MinX && <= MaxX && >= MinY && <= MaxY) { 
        return 
1
    } 
    return 
0

IsPlayerInArea is the function to check if the players are in the area of the spawn.
Try this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)