03.12.2009, 22:41
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
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
}