Help with Spawnkilling -
D1am0nd - 25.10.2015
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.
Re : Help with Spawnkilling -
StreetRP - 25.10.2015
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(playerid, killerid, reason)
{
if(spawn[playerid])
{
Kick(killerid);
}
return 1;
}
Change 5000 with the time you want in ms
Re: Help with Spawnkilling -
D1am0nd - 26.10.2015
Sorry, but that does not work..
Re: Help with Spawnkilling -
Mencent - 26.10.2015
Hello!
Do you want a NO-DM zone or that the player don't get damaged for few seconds?
Re: Help with Spawnkilling -
sanamalik400 - 26.10.2015
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;
}
Re: Help with Spawnkilling -
LovelySoomro - 26.10.2015
public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
SetPlayerHealth(killerid,0);
}
return 1;
}
Re : Help with Spawnkilling -
StreetRP - 26.10.2015
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(playerid, killerid, reason)
{
if(spawn[playerid] == true)
{
SetPlayerHealth(killerid,0.0);
}
return 1;
}
Re: Help with Spawnkilling -
Mencent - 27.10.2015
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(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X >= MinX && X <= MaxX && Y >= MinY && Y <= 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.
Re: Help with Spawnkilling -
D1am0nd - 27.10.2015
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.
Re: Help with Spawnkilling -
Mencent - 27.10.2015
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(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY) {
return 1;
}
return 0;
}
IsPlayerInArea is the function to check if the players are in the area of the spawn.
Try this.