[HELP] Automatic Gates
#1

Quote:

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);
}

------------------------------------------------------------------------

1 ERROR:

error 010: invalid function or declaration

What is problem??

please help i'm beginer!!!
Reply
#2

In what line is the error...
Reply
#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
#4

Quote:

#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



No errors , no warning and not good!
Reply
#5

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.
Reply
#6

Quote:

#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)

Reply
#7

Are you serious?

Quote:
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.
"That" is referring to #if defined FILTERSCRIPT. So delete '#if defined FILTERSCRIPT'
Reply
#8

Quote:

#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);
}

pwn(11) : warning 235: public function lacks forward declaration (symbol "OnFilterscriptInit")
pwn(23) : warning 202: number of arguments does not match definition
pwn(24) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Warnings.


No errors



not good! gate do not open!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)