SA-MP Forums Archive
Moveable objects - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Moveable objects (/showthread.php?tid=605802)



Moveable objects - CSLangdale - 24.04.2016

Anybody know how i would make a door open by pressing f? or enter?


Re: Moveable objects - povargek - 24.04.2016

My example:

Код:
new gDoorLSPD[2];
new gDoorZone[2]; //for LSPD and SFPD
new gDoorStatus[2]; //for LSPD and SFPD

gDoorLSPD[0] = CreateDynamicObject(1495,244.987503, 72.491752, 1002.589904, 0.000000, 0.000000, 0.000000, 30);
	gDoorLSPD[1] = CreateDynamicObject(1495,247.984191, 72.491752, 1002.589904, 0.000000, 0.000000, 180.0, 30);

forward MoveLSPDDoors();
public MoveLSPDDoors()
{
	if(!gDoorStatus[0]) return 1;
	
	MoveDynamicObject(gDoorLSPD[0], 244.987503, 72.491752, 1002.589904, 0.3);
	MoveDynamicObject(gDoorLSPD[1], 247.987503, 72.491752, 1002.589904, 0.3);
	gDoorStatus[0] = 0;
	
	return 1;
}

if(!IsPlayerInAnyVehicle(playerid) && (newkeys & KEY_SECONDARY_ATTACK))
	{
		if(IsPlayerInDynamicArea(playerid, gDoorZone[0]))
		{
			if(!CopKeys[playerid] && !IsPlayerCop(playerid)) return SendClientMessage(playerid, COLOR_GREY, " You no have a keys");
		
			if(IsDynamicObjectMoving(gDoorLSPD[0]) || IsDynamicObjectMoving(gDoorLSPD[1])) return SendClientMessage(playerid, COLOR_GREY, " Doors moving!");
		
			if(!gDoorStatus[0])
			{
				MoveDynamicObject(gDoorLSPD[0], 243.987503, 72.491752, 1002.589904, 0.3);
				MoveDynamicObject(gDoorLSPD[1], 248.987503, 72.491752, 1002.589904, 0.3);
				gDoorStatus[0] = 1;
				SetTimer("MoveLSPDDoors", 10000, 0);
			}
			else
			{
				MoveDynamicObject(gDoorLSPD[0], 244.987503, 72.491752, 1002.589904, 0.3);
				MoveDynamicObject(gDoorLSPD[1], 247.987503, 72.491752, 1002.589904, 0.3);
				gDoorStatus[0] = 0;
			}
		}
	}



Re: Moveable objects - Saliim - 24.04.2016

Quote:
Originally Posted by povargek
Посмотреть сообщение
My example:

Код:
new gDoorLSPD[2];
new gDoorZone[2]; //for LSPD and SFPD
new gDoorStatus[2]; //for LSPD and SFPD

gDoorLSPD[0] = CreateDynamicObject(1495,244.987503, 72.491752, 1002.589904, 0.000000, 0.000000, 0.000000, 30);
	gDoorLSPD[1] = CreateDynamicObject(1495,247.984191, 72.491752, 1002.589904, 0.000000, 0.000000, 180.0, 30);

forward MoveLSPDDoors();
public MoveLSPDDoors()
{
	if(!gDoorStatus[0]) return 1;
	
	MoveDynamicObject(gDoorLSPD[0], 244.987503, 72.491752, 1002.589904, 0.3);
	MoveDynamicObject(gDoorLSPD[1], 247.987503, 72.491752, 1002.589904, 0.3);
	gDoorStatus[0] = 0;
	
	return 1;
}

if(!IsPlayerInAnyVehicle(playerid) && (newkeys & KEY_SECONDARY_ATTACK))
	{
		if(IsPlayerInDynamicArea(playerid, gDoorZone[0]))
		{
			if(!CopKeys[playerid] && !IsPlayerCop(playerid)) return SendClientMessage(playerid, COLOR_GREY, " У вас нет ключей");
		
			if(IsDynamicObjectMoving(gDoorLSPD[0]) || IsDynamicObjectMoving(gDoorLSPD[1])) return SendClientMessage(playerid, COLOR_GREY, " Двери еще не закончили движение!");
		
			if(!gDoorStatus[0])
			{
				MoveDynamicObject(gDoorLSPD[0], 243.987503, 72.491752, 1002.589904, 0.3);
				MoveDynamicObject(gDoorLSPD[1], 248.987503, 72.491752, 1002.589904, 0.3);
				gDoorStatus[0] = 1;
				SetTimer("MoveLSPDDoors", 10000, 0);
			}
			else
			{
				MoveDynamicObject(gDoorLSPD[0], 244.987503, 72.491752, 1002.589904, 0.3);
				MoveDynamicObject(gDoorLSPD[1], 247.987503, 72.491752, 1002.589904, 0.3);
				gDoorStatus[0] = 0;
			}
		}
	}
where is your dynamic area


Re: Moveable objects - povargek - 24.04.2016

Quote:
Originally Posted by Saliim
Посмотреть сообщение
where is your dynamic area
Near door

Код:
gDoorZone[0] =  CreateDynamicSphere(244.987503, 72.491752, 1002.589904, 3.0, 30);
	gDoorZone[1] =  CreateDynamicSphere(239.576156, 117.520126, 1002.239562, 3.0, 30);



Re: Moveable objects - CSLangdale - 24.04.2016

Is there a stock for the dynamic moving though cause no matter how i try to set them up its saying invalid function