Gate1 = CreateDynamicObject(19859, 1294.623168, -1862.670776, 13.796877, 0.000000, 0.000000, 0.000000); SetTimer("Close", 1000, 1); Gate2 = CreateDynamicObject(19859, 1297.616333, -1862.673706, 13.796883, 0.000000, 0.000000, 180.000000); SetTimer("Close", 1000, 1);
Код:
Gate1 = CreateDynamicObject(19859, 1294.623168, -1862.670776, 13.796877, 0.000000, 0.000000, 0.000000); SetTimer("Close", 1000, 1); Gate2 = CreateDynamicObject(19859, 1297.616333, -1862.673706, 13.796883, 0.000000, 0.000000, 180.000000); SetTimer("Close", 1000, 1); |
#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 don't have much time for now, hope this tutorial will do for you: https://sampforum.blast.hk/showthread.php?tid=279757
It explains everything about automating a gate |