How can i make a anti spawn kill and teamkill -
CSMajor - 23.08.2010
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
Re: How can i make a anti spawn kill and teamkill -
Backwardsman97 - 23.08.2010
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.
Re: How can i make a anti spawn kill and teamkill -
CSMajor - 23.08.2010
but how do i use it?? give me an example
Re: How can i make a anti spawn kill and teamkill -
Kyosaur - 23.08.2010
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.
Re: How can i make a anti spawn kill and teamkill -
Backwardsman97 - 23.08.2010
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.
Re: How can i make a anti spawn kill and teamkill -
CSMajor - 23.08.2010
how do i use the SetPlayerTeam(); function? and can i just do an area check for ur suggestion? (Kyosaur)
Re: How can i make a anti spawn kill and teamkill -
Kyosaur - 23.08.2010
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 :\.
Re: How can i make a anti spawn kill and teamkill -
CSMajor - 23.08.2010
I dont use plugins because they are difficult to setup at times :S