/gate problems
#1

When I do /gate, it opens but then doesn't close automaticly, like it is supposed to...

Код:
command(gate, playerid, params[])
{
	#pragma unused params

	new string[128];

	if(Groups[Player[playerid][Group]][CommandTypes] == 1 || Groups[Player[playerid][Group]][CommandTypes] == 4)
	{
		GetPlayerPos(playerid, Positions[0][0], Positions[0][1], Positions[0][2]);
        GetDynamicObjectPos(lspdgate, Positions[1][0], Positions[1][1], Positions[1][2]);
		GetDynamicObjectPos(ImpoundGate, Positions[2][0], Positions[2][1], Positions[2][2]);
		GetDynamicObjectPos(PrisonGate, Positions[3][0], Positions[3][1], Positions[3][2]);

		if(GetDistance(Positions[0][0], Positions[0][1], Positions[0][2], Positions[1][0], Positions[1][1], Positions[1][2]) < 30.0)
		{
			if(GateOpen == 1)
			{
				format(string, sizeof(string), "* %s uses their remote to open the gates.", GetName(playerid));
                NearByMessage(playerid, PURPLE, string);
                MoveDynamicObject(lspdgate, 1588.5617, -1638.0871, 5.7200, 1);
                GateOpen = 1;
                SetTimer("CloseLspdGateTimer", 5000, false);
			}
			else
			{
				SendClientMessage(playerid, WHITE, "The gate is already open, wait for it to close.");
			}
		}
		else if(GetDistance(Positions[0][0], Positions[0][1], Positions[0][2], Positions[2][0], Positions[2][1], Positions[2][2]) < 30.0)
		{
			if(ImpoundOpen == 1)
			{
				format(string, sizeof(string), "* %s uses their remote to open the gates.", GetName(playerid));
                NearByMessage(playerid, PURPLE, string);
                DestroyDynamicObject(ImpoundGate);
				ImpoundGate = CreateDynamicObject(968, 1544.681640625, -1630.8916015625, 13.054567337036, 0, 0, 90); // Gate open coords
                ImpoundOpen = 1;
                SetTimer("CloseImpoundGateTimer", 5000, false);
			}
			else
			{
				SendClientMessage(playerid, WHITE, "The gate is already open, wait for it to close.");
			}
		}
		else if(GetDistance(Positions[0][0], Positions[0][1], Positions[0][2], Positions[3][0], Positions[3][1], Positions[3][2]) < 30.0)
		{
			if(PrisonGateOpen == 1)
			{
				format(string, sizeof(string), "* %s uses their remote to open the gates.", GetName(playerid));
                NearByMessage(playerid, PURPLE, string);
				MoveDynamicObject(PrisonGate, 1788.4794921875, -1600.173828125, 19.745199203491, 1);
				PrisonGateOpen = 1;
				SetTimer("PrisonGateTimer", 5000, false);
			}
			else
			{
				SendClientMessage(playerid, WHITE, "The gate is already open, wait for it to close.");
			}
		}
	}
	else if(Player[playerid][Group] == 11)
	{
		GetPlayerPos(playerid, Positions[0][0], Positions[0][1], Positions[0][2]);
		GetDynamicObjectPos(MarketGate, Positions[1][0], Positions[1][1], Positions[1][2]);

		if(MarketGateOpen == 0)
		{
			format(string, sizeof(string), "* %s uses their remote to open the gates.", GetName(playerid));
            NearByMessage(playerid, PURPLE, string);
			MoveDynamicObject(MarketGate, 828.37866210938, -1357.3833007813, 4.50577330589294, 1);
			MarketGateOpen = 1;
		}
		else
		{
			format(string, sizeof(string), "* %s uses their remote to close the gates.", GetName(playerid));
            NearByMessage(playerid, PURPLE, string);
			MoveDynamicObject(MarketGate, 828.37866210938, -1357.3833007813, 0.50577330589294, 1);
			MarketGateOpen = 0;
		}
	}
	else
    {
        if(Player[playerid][Group] == 5)
        {
			GetPlayerPos(playerid, Positions[0][0], Positions[0][1], Positions[0][2]);
	        GetDynamicObjectPos(CGate1, Positions[1][0], Positions[1][1], Positions[1][2]);

			if(GetDistance(Positions[0][0], Positions[0][1], Positions[0][2], Positions[1][0], Positions[1][1], Positions[1][2]) < 30.0)
			{
				if(CGateOpen == 0)
				{
					format(string, sizeof(string), "* %s uses their remote to open the doors.", GetName(playerid));
					NearByMessage(playerid, PURPLE, string);
					MoveDynamicObject(CGate1, 1479.6882324219, -1649.5045166016, -38.890918731689, 1);
					MoveDynamicObject(CGate2, 1485.3944091797, -1649.4760742188, -38.890918731689, 1);
					CGateOpen = 1;
				}
				else
				{
					format(string, sizeof(string), "* %s uses their remote to close the doors.", GetName(playerid));
					NearByMessage(playerid, PURPLE, string);
					MoveDynamicObject(CGate1, 1481.1398925781, -1649.4718017578, -38.890918731689, 1);
					MoveDynamicObject(CGate2, 1484.1184082031, -1649.4512939453, -38.890918731689, 1);
					CGateOpen = 0;
				}
			}
		}
    }
	return 1;
}
Reply
#2

why don't create a command that close the gate like /gclose
Reply
#3

check this out, it may help you
https://sampforum.blast.hk/showthread.php?tid=497223
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)