Gate rotation problem
#1

Hey im trying to get the gate to be straight but it just wont move a damn cm. Help.

Its a gate that moves up and down. But added the pos for it and the rotation angle but it wont work.


Here is my code
Код:
#include <a_samp>
#define FILTERSCRIPT
#if defined FILTERSCRIPT

forward GateTimer();
new Timer; //allows killtimer

// ######################## EDIT THESE ##########################
#define TOLERANCE 20
#define OPENSPEED 2
#define CLOSESPEED 2
#define TIMERSPEED 1500 //(MILLISeconds, eg 1000 = 1, 2000 = 2, 1500 = 1.5)
const GateNum = 1; //number of gates present (defines other arrays)
// ##############################################################

const MiscObjNum = 5;
new Float:GateInfo[GateNum][9]; //stores all gate c-ords (Start, Fnish, Center)
new GateState[GateNum]; //Whether the gate is open closed (not currently in use)
new OpenGate[GateNum]; //Whether or not to open the gate when the loop finishes
new GateObject[GateNum]; //stores gate object ID's
new MiscObject[MiscObjNum];//stores misc object ID's
new Float:Tempx, Float:Tempy, Float:Tempz; //Holds player position during loops
new Float:xtol1, Float:xtol2, Float:ytol1, Float:ytol2; //Holds area bounds during loops

public OnFilterScriptInit()
{

	Timer = SetTimer("GateTimer", TIMERSPEED, true);




// ######################## ADD TO THESE ##########################
//  MakeGate(ObjectID, StartX, StarY, StartZ,  FinishX, FinishY, FinishZ,  CenterX, CenterY, CenterZ, Rotation, GateNumber);
	MakeGate(987, -51.799999237061, 1495.3000488281, 11.800000190735, -51.799999237061, 1495.3000488281, 5.5,-51.799999237061, 1495.3000488281, 9.6999998092651, 358, 0); // Ice Road Trucker gate
// ################################################################
	return 1;
}

public OnFilterScriptExit()
{
    for(new tempgate=0; tempgate<GateNum; tempgate++)
		{
		DestroyObject(GateObject[tempgate]);
		}
    for(new tempgate=0; tempgate<MiscObjNum; tempgate++)
		{
		DestroyObject(MiscObject[tempgate]);
		}
	KillTimer(Timer);
	return 1;
}

#else
#endif

public GateTimer()
{
	for(new tempgate=0; tempgate<GateNum; tempgate++)
		{
		for(new pid=0; pid<MAX_PLAYERS; pid++)
	    	{
  			if(OpenGate[tempgate] == 0/* && IsPlayerAdmin(pid) == 1*/) OpenGate[tempgate] = IsPlayerNearGate(pid, tempgate, TOLERANCE);
	    	}
        if(OpenGate[tempgate] == 1) MoveObject(GateObject[tempgate], GateInfo[tempgate][3], GateInfo[tempgate][4], GateInfo[tempgate][5], OPENSPEED), GateState[tempgate] = 1;
	    else MoveObject(GateObject[tempgate], GateInfo[tempgate][0], GateInfo[tempgate][1], GateInfo[tempgate][2], CLOSESPEED), GateState[tempgate] = 0;
	    OpenGate[tempgate] = 0;
		}
}

MakeGate(z, Float:a, Float:b, Float:c, Float:d, Float:e, Float:f, Float:g, Float:h, Float:i, Float:j, k)
{
	GateInfo[k][0] = a,	GateInfo[k][1] = b,	GateInfo[k][2] = c; //Start
	GateInfo[k][3] = d,	GateInfo[k][4] = e,	GateInfo[k][5] = f; //Finish
	GateInfo[k][6] = g, GateInfo[k][7] = h,	GateInfo[k][8] = i; //Center
	GateState[k] = 0; //Gate Closed
	GateObject[k] = CreateObject(z ,a, b, c, 0.0,0.0,j);
}

stock IsPlayerNearGate(pid, tempgate, tolerance)
{
	GetPlayerPos(pid, Tempx, Tempy, Tempz);
	xtol1 = GateInfo[tempgate][6] + tolerance;
	xtol2 = GateInfo[tempgate][6] - tolerance;
	ytol1 = GateInfo[tempgate][7] + tolerance;
	ytol2 = GateInfo[tempgate][7] - tolerance;
	if(Tempx >= xtol2 && Tempx <= xtol1 && Tempy >= ytol2 && Tempy <= ytol1) return 1;
	return 0;
}
And here is the object id.

When the gete is up:
Код:
CreateObject(987, -51.799999237061, 1495.3000488281, 11.800000190735, 0, 0, 318.70239257813);
When it is in the middle
Код:
CreateObject(987, -51.799999237061, 1495.3000488281, 9.6999998092651, 0, 0, 318.70239257813);
And when its down
Код:
CreateObject(987, -51.799999237061, 1495.3000488281, 5.5, 0, 0, 318.70239257813);
Reply
#2

You need to compile using the 0.3d/e includes and/or update your object streamer (if using, code suggests not).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)