[HELP] Automatic Gates
#3

I've repeated this many times, the wiki page on Automatic Gates is wrong! And stupid!

Here's all that's needed, it can run on it's own as a filterscript/gamemode, but it's best merged with your current gamemode
pawn Код:
#include <a_samp>//Not needed if you're merging
forward GateCheck();
new mygate; //One per gate
public OnGameModeInit() //Change to OnFilterscriptInit if this is a filterscript --This will already exist if you're merging to your gamemode/filterscript, Don't make more than one of the same function!!!
{
  mygate=CreateObject(1337,0.0,0.0,0.0,0.0,0.0,0.0); //Example object being created, you should set it to be your own modelid and coordinates
  SetTimer("GateCheck",1000,1); //1000 milliseconds (1 second) is a good amount of time, any less would mean unneccessary lag
}
public GateCheck() //Your gate check function HAS to be a public, otherwise the timer will not run correctly
{
  new openmygate; //One per gate corresponding with your already made variables
  for(new playerid;playerid<MAX_PLAYERS;playerid++) //Standard player loop, if you're using foreach then I suggest you switch to that
  {
    if(IsPlayerInRangeOfPoint(playerid,10.0,X,Y,Z)openmygate=1; //Change X,Y,Z to the coordinates of your gate, change the 10.0 if it's too much or too little for range
  }
  if(openmygate)MoveObject(mygate,X,Y,Z); //This X,Y,Z will be the coordinates of your gate if it were open
  else MoveObject(mygate,X,Y,Z); //This X,Y,Z Will be the coorinates of your gate if it were closed
}
Reply


Messages In This Thread
[HELP] Automatic Gates - by Coltt29 - 03.12.2009, 16:51
Re: [HELP] Automatic Gates - by Rzzr - 03.12.2009, 17:40
Re: [HELP] Automatic Gates - by Joe Staff - 03.12.2009, 22:41
Re: [HELP] Automatic Gates - by Coltt29 - 04.12.2009, 13:23
Re: [HELP] Automatic Gates - by Joe Staff - 04.12.2009, 17:59
Re: [HELP] Automatic Gates - by Coltt29 - 04.12.2009, 18:16
Re: [HELP] Automatic Gates - by Joe Staff - 04.12.2009, 19:17
Re: [HELP] Automatic Gates - by Coltt29 - 05.12.2009, 12:58

Forum Jump:


Users browsing this thread: 1 Guest(s)