Gate Problem - 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 Problem (
/showthread.php?tid=375842)
Gate Problem -
Sanady - 08.09.2012
Hello everybody.I got problem with automaticli gate I don`t see problem but they won`t open...
pawn Код:
forward CheckGate(playerid);
SetTimer("CheckGate",1000,true);
public CheckGate(playerid)
{
if(GetPlayerTeam(playerid) == 1)
{
new mygate_status;
if(IsPlayerInRangeOfPoint(playerid,10.0,1578.8043,-1751.2802,4.3760))mygate_status = 1;
if(mygate_status == 1)
{
MoveObject(civilgate1, 1578.91369629,-1751.37561035,1.58261597,2.0);
MoveObject(civilgate2, 1578.91308594,-1751.37500000,11.43260574,2.0);
}
if(mygate_status == 0)
{
MoveObject(civilgate1, 1578.91369629,-1751.37561035,5.13261700,2.0);
MoveObject(civilgate2, 1578.91308594,-1751.37500000,8.70762062,2.0);
}
}
return 1;
}
Re: Gate Problem -
Sanady - 09.09.2012
Anyone??
Re: Gate Problem - HuSs3n - 09.09.2012
pawn Код:
public CheckGate()
{
for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
{
if(!IsPlayerConnected(playerid)) continue;
if(GetPlayerTeam(playerid) == 1)
{
new mygate_status;
if(IsPlayerInRangeOfPoint(playerid,10.0,1578.8043,-1751.2802,4.3760))mygate_status = 1;
if(mygate_status == 1)
{
MoveObject(civilgate1, 1578.91369629,-1751.37561035,1.58261597,2.0);
MoveObject(civilgate2, 1578.91308594,-1751.37500000,11.43260574,2.0);
}
if(mygate_status == 0)
{
MoveObject(civilgate1, 1578.91369629,-1751.37561035,5.13261700,2.0);
MoveObject(civilgate2, 1578.91308594,-1751.37500000,8.70762062,2.0);
}
}
}
return 1;
}
or use SetTimerEx
Re: Gate Problem -
clarencecuzz - 09.09.2012
pawn Код:
new bool:GateOpen;
public OnGameModeInit() //Or OnFilterScriptInit() if you're using a filterscript
{
SetTimer("GateCheck", 1000, true);
civilgate1 = CreateObject... //etc. etc.
civilgate2 = CreateObject... //etc. etc.
return 1;
}
forward GateCheck();
public GateCheck()
{
for(new i = 0; i < MAX_PLAYERS; i++) //Foreach is recommended
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i, 10.0, 1578.8043, -1751.2802, 4.3760))
{
if(GetPlayerTeam(i) == 1)
{
if(GateOpen == false)
{
MoveObject(civilgate1, 1578.91369629,-1751.37561035,5.13261700,2.0);
MoveObject(civilgate2, 1578.91308594,-1751.37500000,8.70762062,2.0);
GateOpen = true;
}
}
}
else
{
if(GateOpen == true)
{
MoveObject(civilgate1, 1578.91369629,-1751.37561035,1.58261597,2.0);
MoveObject(civilgate2, 1578.91308594,-1751.37500000,11.43260574,2.0);
GateOpen = false;
}
}
}
}
return 1;
}