Alright, let's start with creating the gates, preferably create them closed:
Код:
#include <a_samp>
#include <Streamer>
#include <zcmd>
new Gate[2]; // Let's get straight to an array, an array can have multiple layers of data storage, depending on how much you need. In this case we need 2.
new bool:GateStatus[2]; // A bool(ean) can only be true or false, with this boolean we can see if the gate is open or not.
public OnGameModeInit()
{
Gate[0] = CreateDynamicObject(19859, 1294.623168, -1862.670776, 13.796877, 0.000000, 0.000000, 0.000000); // We create the first gate, notice that the counting always starts from 0
Gate[1] = CreateDynamicObject(19859, 1297.616333, -1862.673706, 13.796883, 0.000000, 0.000000, 180.000000); // Second gate
return 1;
}
// Now lets open te gates with a simple command
CMD:gate(playerid)
{
if(IsPlayerInRangeOfPoint(playerid,2.0,1296.8699,-1862.1085,13.7969))
{
if(GateStatus[0] == false) // To see if the gate is closed
{
GateStatus[0] = true; // Gate status is set to open
MoveDynamicObject(Gate[0],1294.0632, -1862.6708, 13.7969,1.0,0.0000, 0.0000, 0.0000);
}
else
{
GateStatus[0] = false;
MoveDynamicObject(Gate[0], 1294.623168,-1862.670776,13.796877,1.0,0.000000,0.000000,0.000000);
}
// The problem with having local variables to see if the gate is open or not is that local variables don't get to keep their value outside
}
}
I will let you open and close the second gate yourself, see if you can get it working.