forward GateCheck( playerid );
public GateCheck( playerid )
{
if ( gTeam[ playerid ] == TEAM_SWAT )
{
if(IsPlayerInRangeOfPoint(playerid, 22.0, 1415.0000000, -1649.9000244, 16.2999992))
{
if(SwatOpen == false)
{
MoveDynamicObject(SwatGate, 1415.0999756, -1639.5000000, 16.2999992, 2.3);
SwatOpen = true;
}
return;
}
}
if(SwatOpen == true)
{
MoveDynamicObject(SwatGate, 1415.0000000, -1649.9000244, 16.2999992, 2.3); // Change the '8.0, 3.0, 10.0' to the coordinates of your gate when it's closed. gateopen = false; //This indicates the gate is closed again. Or at least, closing.
SwatOpen = false;
}
}
The problem is most likely the place that you called that function from, if the playerid value hasn't been set it will return 0 by default and will mean it will only work for playerid 0
|
SetTimer("GateCheck", 600, true);
new pGateCheck[MAX_PLAYERS];
pGateCheck[playerid] = SetTimerEx("GateCheck", 600 , true, "i", playerid);
KillTimer(pGateCheck[playerid]);
Loop that code or change SetTimer("GateCheck", 600, true); to SetTimerEx("GateCheck", 600 , true, "i", playerid); and put it in OnPlayerConnect, and ofc delete it from OnGameModeInit. But for more optimalization do like this:
Global variable: Код:
new pGateCheck[MAX_PLAYERS]; Код:
pGateCheck[playerid] = SetTimerEx("GateCheck", 600 , true, "i", playerid); Код:
KillTimer(pGateCheck[playerid]); |