Jump to content

Trunk open


Peti930

Recommended Posts

Posted

Hi i want to make a script to if i type /trunk the trunk is goingto open and i type it again the trunk is closeing OR not /trunk, bind it to End

Posted (edited)

that is the functions you need

getPedOccupiedVehicle
setVehicleDoorState
addCommandHandler

 

Edited by Dimos7
Posted (edited)
local trunkDoor = -- put true or false if you want first time open put false
function toggleTrunk(player)
    if isPedInVehicle(player) then  - check player is in a car.
	    local car = getPedOccupiedVehicle(player) -- takes the car the player is inside.
		if turnkDoor then  -- put here trunk door and check if it false for open it or close it
		   setVehicleDoorOpenRatio(car)
		else
		   setVehicleDoorOpenRatio(car)
		end
	end
end
addCommandHandler("trunk", toggleTrunk)

 

Edited by Dimos7
Posted
local ms = 1000

addCommandHandler("trunk",
function(player)
	local vehicle = getPedOccupiedVehicle(player)
	if isElement(vehicle) then
		if getVehicleDoorOpenRatio(vehicle,1) > 0 then
			setVehicleDoorOpenRatio(vehicle,1,0,ms)
		else
			setVehicleDoorOpenRatio(vehicle,1,1,ms)
		end
	end
end)

Server side

Posted
local ms = 1000

addCommandHandler("trunk",
function(player)
	local vehicle = getPedOccupiedVehicle(player)
	if isElement(vehicle) and getElementModel(vehicle) == 541 then
		if getVehicleDoorOpenRatio(vehicle,1) > 0 then
			setVehicleDoorOpenRatio(vehicle,1,0,ms)
		else
			setVehicleDoorOpenRatio(vehicle,1,1,ms)
		end
	end
end)

Use getElementModel

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...