29.05.2012, 15:09
I am having a slight issue with a timer and some stuff :P
I am trying to create a zone by using
That gives me a quick and easy circle around Fort Carson, I made it as a positive check instead of a negative (!) just in case I wanted to add another zone by using an "else if" with other coordinates.
So what I want is that when a player is not inside one of these zones, their health will slowly drain (its quite quick for debugging)
Here is the full code for my function:
Now this works perfectly fine for 1 player, but with more players it only drains for the first player.
I tried to do some other things, but that made everyone loose health even if they were not outside.
I also want it to display a message once when the player enters and leaves the area, they way I tried ended up spaming every second, so I though I probably needed some type of trigger and check to see if the message plays, and if it has, don't play it again, unless the player enters again.
I hope you understand where I want to go with this, and if you can help it would be very appreciated!
I am trying to create a zone by using
pawn Code:
if(IsPlayerInRangeOfPoint(playerid, 700.0, -118.3844, 1151.4380, 19.5938))
So what I want is that when a player is not inside one of these zones, their health will slowly drain (its quite quick for debugging)
Here is the full code for my function:
pawn Code:
public OnGameModeInit()
{
SetTimer("isPlayerInArea", 1000, true);
}
pawn Code:
public isPlayerInArea(playerid) // has "forward isPlayerInArea(playerid);"
{
if(IsPlayerInRangeOfPoint(playerid, 700.0, -118.3844, 1151.4380, 19.5938)) // center of Fort Carson
{
return 1; // does nothing if player is in area
}
else
{
new Float:dhealth;
GetPlayerHealth(playerid, dhealth);
SetPlayerHealth(playerid, dhealth - 1.0);
}
return 1;
}
I tried to do some other things, but that made everyone loose health even if they were not outside.
I also want it to display a message once when the player enters and leaves the area, they way I tried ended up spaming every second, so I though I probably needed some type of trigger and check to see if the message plays, and if it has, don't play it again, unless the player enters again.
I hope you understand where I want to go with this, and if you can help it would be very appreciated!