new OpenGate[MAX_PLAYERS]; new c_gate; forward CheckGate(); main() PlayerToPoint(Float:radius, playerid, Float:X, Float:Y, Float:Z) { new Floatldpos[3], Float:temppos[3]; GetPlayerPos(playerid, oldpos[0], oldpos[1], oldpos[2]); temppos[0] = (oldpos[0] -X); temppos[1] = (oldpos[1] -Y); temppos[2] = (oldpos[2] -Z); if(((temppos[0] < radius) && (temppos[0] > -radius)) && ((temppos[1] < radius) && (temppos[1] > -radius)) && ((temppos[2] < radius) && (temppos[2] > -radius))) { return true; } return false; } c_gate = CreateObject(16775, 2063.2603, -2600.1406, 16.5461, 0.0000, 0.0000, 33.5180, 500.0); public CheckGate() { for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i)) continue; if(PlayerToPoint(10.0, i, 2067.1909,-2605.8831,13.5469) && OpenGate[i] == 0) { MoveObject(c_gate, 2063.2507, -2600.1677, 8.5313); OpenGate[i] = 1; } else if(!PlayerToPoint(10.0, i, 2059.3821,-2594.8203,13.5469) && OpenGate[i] == 1) { MoveObject(c_gate, 2063.2603, -2600.1406, 16.5461); OpenGate[i] = 0; } } } public gate() { SetTimer("CheckGate", 500, true); } |
#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
}
#include <a_samp> #if defined FILTERSCRIPT forward GateCheck(); new mygate; public OnFilterscriptInit() { mygate=CreateObject(16775, 2063.2603, -2600.1406, 16.5461, 0.0000, 0.0000, 33.5180, 500.0); SetTimer("GateCheck",1000,1); } public GateCheck() { new openmygate; for(new playerid;playerid<MAX_PLAYERS;playerid++) { if(IsPlayerInRangeOfPoint(playerid,10.0,2063.2603, -2600.1406, 16.5461)openmygate=1; //object coordinate if(openmygate)MoveObject(mygate,2063.2507, -2600.1677, 8.5313); //open object coordinates else MoveObject(mygate,2063.2603, -2600.1406, 16.5461); //closed object coordinates } #endif |
#if defined FILTERSCRIPT #include <a_samp> forward GateCheck(); new mygate; public OnFilterscriptInit() { mygate=CreateObject(16775, 2063.2603, -2600.1406, 16.5461, 0.0000, 0.0000, 33.5180, 500.0); SetTimer("GateCheck",1000,1); } public GateCheck() { new openmygate; for(new playerid;playerid<MAX_PLAYERS;playerid++) { if(IsPlayerInRangeOfPoint(playerid,10.0,2063.2603, -2600.1406, 16.5461)openmygate=1; if(openmygate)MoveObject(mygate,2063.2507, -2600.1677, 8.5313); else MoveObject(mygate,2063.2603, -2600.1406, 16.5461); } error 001: expected token: "#endif", but found "-end of file-" error 013: no entry point (no public functions) |
Originally Posted by Joe Staff
Why do you have the '#if defined FILTERSCRIPT' in there? Of course it's not going to work because you haven't actually put it into the final code. Either remove that and '#endif' or atleast add '#define FILTERSCRIPT' at the very very very top.
|
#include <a_samp> forward GateCheck(); new mygate; public OnFilterscriptInit() { mygate=CreateObject(16775, 2063.260254, -2600.140625, 16.546091, 0.0000, 0.0000, 33.5180); SetTimer("GateCheck",1000,1); } public GateCheck() { new openmygate; for(new playerid;playerid<MAX_PLAYERS;playerid++) { if (IsPlayerInRangeOfPoint(playerid,10.0,2063.260254, -2600.140625, 16.546091))openmygate=1; } if(openmygate)MoveObject(mygate,2063.250732, -2600.167725, 8.531250); else MoveObject(mygate,2063.260254, -2600.140625, 16.546091); } |