Help With Gate Timers
#7

Quote:
Originally Posted by raydrezack
Well, I honestly wasn't exactly sure how to do such a thing with "AddAutoGate", so I just used the typical auto gate method:

Код:
#include <a_samp>

new gate;
new gate2;
new OpenGate[MAX_PLAYERS];

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Auto Gates ");
	print("--------------------------------------\n");
	gate = CreateObject(10841, 2207.830322, -3391.702148, 15.105540, 0.0,0.0,90.00);
	gate2 = CreateObject(2634, 2322.646484, -3393.401855, 18.768494, 0.0, 0.0, 00.00);
	SetTimerEx("GateCheck", 100, 1, "i");
	return 1;
}

forward GateCheck();
public GateCheck()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
		{
			if(PlayerToPoint(5.0, i, 2207.830322, -3391.702148, 15.105540) && OpenGate[i] == 0)
			{
				SetTimerEx("GateOn", 45000, 0, "i");
	  	}
	  	else if(!PlayerToPoint(5.0, i, 2207.830322, -3391.702148, 15.105540) && OpenGate[i] == 1)
	  	{
	  	  MoveObject(gate, 2207.830322, -3391.702148, 15.105540, 5.0);
	    	OpenGate[i] = 0;
			}
		}
	}
	for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
		{
			if(PlayerToPoint(5.0, i, 2322.646484, -3393.401855, 18.768494) && OpenGate[i] == 0)
			{
				SetTimerEx("GateOn2", 45000, 0, "i");
	  	}
	  	else if(!PlayerToPoint(5.0, i, 2322.646484, -3393.401855, 18.768494) && OpenGate[i] == 1)
	  	{
	  	  MoveObject(gate2, 2322.646484, -3393.401855, 18.768494, 5.0);
	    	OpenGate[i] = 0;
			}
		}
	}
	return 1;
}

forward GateOn();
public GateOn()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
		{
		  MoveObject(gate, 2207.830322, -3391.702148, 0, 5.0);
		 	OpenGate[i] = 1;
			return 1;
		}
	}
	return 0;
}

forward GateOn2();
public GateOn2()
{
  for(new i = 0; i < GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
		{
			MoveObject(gate2, 2322.646484, -3393.401855, 0, 5.0);
		 	OpenGate[i] = 1;
			return 1;
		}
	}
	return 0;
}

stock PlayerToPoint(Float:radi,playerid,Float:x,Float:y,Float:z)
{
	new Float:oldposx, Float:oldposy, Float:oldposz;
	new Float:tempposx, Float:tempposy, Float:tempposz;
	GetPlayerPos(playerid, oldposx, oldposy, oldposz);
	tempposx = (oldposx -x);
	tempposy = (oldposy -y);
	tempposz = (oldposz -z);
	if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) return 1;
	return 0;
}
NOTE: It remains untested. You'll have to test it yourself.
so, i can say that this actually works (lol had to change one coordinate actually but it was worth it at the end) now if you dont mind do you know how to actually show the coutdwon time in text? Like 45,44,43 appearing at the bottom left of your screen for gate 1 and on the upper right hand side of the screen for gate 2.

thanks in advance,

Borg245
Reply


Messages In This Thread
Help With Gate Timers - by borg245 - 30.03.2009, 19:08
Re: Help With Gate Timers - by Tannz0rz - 31.03.2009, 01:58
Re: Help With Gate Timers - by Mikep - 31.03.2009, 02:03
Re: Help With Gate Timers - by borg245 - 31.03.2009, 12:33
Re: Help With Gate Timers - by Tannz0rz - 01.04.2009, 22:05
Re: Help With Gate Timers - by Tannz0rz - 02.04.2009, 00:17
Re: Help With Gate Timers - by borg245 - 02.04.2009, 16:22
Re: Help With Gate Timers - by Tannz0rz - 02.04.2009, 21:18

Forum Jump:


Users browsing this thread: 1 Guest(s)