SA-MP Forums Archive
Gate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Gate (/showthread.php?tid=363518)



Gate - olari9 - 27.07.2012

public CheckGate()
{
new gate_status;
for(new i;i<MAX_PLAYERS;i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsPlayerInRangeOfPoint(i,10.0,-1898.22, 238.45, 35.82))gate_status=1;
else if(gPlayer[i][TEAM_1])gate_status=0;
}
if(gate_status)MoveObject(gate, -1898.22, 238.45, 35.82, 2), MoveObject(gate1, -1918.10, 238.45, 35.82, 2);
else MoveObject(gate, -1903.41, 238.47, 35.82, 2), MoveObject(gate1, -1912.25, 238.47, 35.82, 2);
}
Hi guys, what am i doing wrong here? Thanks for your answer.
BTW, it is compiling but the problem is that if TEAM_1 member is close then the gate doesn't work at all.


Re: Gate - Ranama - 28.07.2012

Where did you created the gate object? and did you made a variable that is named gate that holds the object id of the gate object?

You can't use else if becuse this only gets called if the if statement before is not true, so if the player is in range of the point the else if statement to check if the player is in right gang never gets called.


Re: Gate - Dan. - 28.07.2012

Jou, Olari. Use [pawn] tags, so it's easier to read for us. You are trying to make a gate, so if any player is near it it would open? And are you sure, that the timer is running?


Re: Gate - olari9 - 28.07.2012

the next lines are in:
public OnGameModeInit()
SetTimer("CheckGate",1000,true);
gate = CreateObject(975, -1903.41, 238.47, 35.82, 0.00, 0.00, 0.00); //gate left
gate1 = CreateObject(975, -1912.25, 238.47, 35.82, 0.00, 0.00, 0.00); //gate right
BTW dan, what do you mean [pawn] tags?