27.06.2013, 23:53
Hello. I'm trying to create a spawn kill protection with the function "IsPlayerInRangeOfPoint".
Here is what I have:
At the top:
OnPlayerSpawn:
What it should do is start a repeative timer after player spawn, that checks every 1.5 sec if the player is in specified range, if not >>(if(!IsPlayerInRangeOfPoint(i, 7.0, 1415.2137,2773.7051,14.8135))<<,, then it kills the repeative timer and starts another timer, that will set players health back to 100. BUT somehow the first repeative timer is getting killed, even if the player IS InRangeOfPoint, so it doesn't start the other timer, neither is sends the client message. I'd appreciate any help!
Here is what I have:
At the top:
pawn Код:
new gatetimer[MAX_PLAYERS];
forward GateTimer(playerid);
public GateTimer(playerid)
{
for(new i = 1; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(!IsPlayerInRangeOfPoint(i, 7.0, 1415.2137,2773.7051,14.8135))
{
SendClientMessage(i, COLOR_RED, "Spawn protection countdown has started. You have 10 seconds.");
SetTimerEx("AntiSpawnkill",10000,0,"i",i);
KillTimer(gatetimer[playerid]);
}
}
}
return 1;
}
forward AntiSpawnkill(playerid);
public AntiSpawnkill(playerid)
{
SetPlayerHealth(playerid, 100.0);
SendClientMessage(playerid, 0xFF8000C8, "Spawn protection over.");
timer1 = false;
return 1;
}
pawn Код:
SetPlayerHealth(playerid, 99999.0);
SendClientMessage(playerid, COLOR_RED, "Spawn protection countdown will start on your movement.");
gatetimer[playerid] = SetTimerEx("GateTimer", 1500, true, "i", playerid);