How can i make a anti spawn kill and teamkill
#1

Spawn kill:

Iv tried using a timer but it effects everyone :S so how can i get it to only work for the player who died :S, i cant figure out how to make this work ... Help please

Teamkill:
well i just dont know how to approach this :S
Reply
#2

You need to use a timer with SetTimerEx under OnPlayerSpawn. Try this out.

pawn Код:
forward FixHealth(playerid);
#define SPAWN_PROTECTION_TIME 8 //In seconds

//OnPlayerSpawn
SetPlayerHealth(playerid,1000.0);
SetTimerEx("FixHealth",SPAWN_PROTECTION_TIME*1000,0,"d",playerid);

//Elsewhere in your script
public FixHealth(playerid)
{
    SetPlayerHealth(playerid,100.0);
    return 1;
}
As far as team kill goes, you could use the default SetPlayerTeam functions in sa-mp. They have a built in anti-team kill. Other than that, you could just punish those who team kill.
Reply
#3

but how do i use it?? give me an example
Reply
#4

Quote:
Originally Posted by backwardsman97
Посмотреть сообщение
You need to use a timer with SetTimerEx under OnPlayerDeath. Try this out.

pawn Код:
forward FixHealth(playerid);
#define SPAWN_PROTECTION_TIME 8 //In seconds


//OnPlayerDeath
SetTimerEx("FixHealth",SPAWN_PROTECTION_TIME*1000,0,"d",playerid);

//OnPlayerSpawn
SetPlayerHealth(playerid,1000.0);

//Elsewhere in your script
public FixHealth(playerid)
{
    SetPlayerHealth(playerid,100.0);
    return 1;
}
As far as team kill goes, you could use the default SetPlayerTeam functions in sa-mp. They have a built in anti-team kill. Other than that, you could just punish those who team kill.
That protects from NOTHING lol, you think they spawn killers give up once 100.0 health was taken away lol? Besides, a hunter/minigun can take that in a second easily.

What you could try for spawn protection: create an area using incognito's plugin (this has a callback for entering/exiting areas of any shape). Once players enter the area set their health to infinite

which can be done using a define from ******

Код:
#define FLOAT_INFINITY   (Float:0x7F800000)
Once they leave the area, set their health back to 100.0 :P. Im not sure if the enter callback s called when a player TELEPORTS into an area, so you would have to test that; if its not called, you can simply use the OnPlayerSpawn callback, and do it there.
Reply
#5

Well you can set the health however high you want it to. When we did tests with our health at infinity, like you just posted, it caused de-sync issues. Also, an area of infinite health could easily be abused. You could just stand in the area and kill people around you. You could also just run into it and leave it whenever you wanted your health back to 100.
Reply
#6

how do i use the SetPlayerTeam(); function? and can i just do an area check for ur suggestion? (Kyosaur)
Reply
#7

Quote:
Originally Posted by CSMajor
Посмотреть сообщение
how do i use the SetPlayerTeam(); function? and can i just do an area check for ur suggestion? (Kyosaur)
Hmmm if you dont want to use the plugin (i REALLY suggest you do, it streams EVERYTHING, and supports area checks. It is second to none- literally) you CAN use IsPlayerInRangeOfPoint, sure. You're way requires a timer with a player loop, or using OnPlayerUpdate though :\.
Reply
#8

I dont use plugins because they are difficult to setup at times :S
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)