Sign in to follow this  
Peti930

Trunk open

Recommended Posts

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

Share this post


Link to post

that is the functions you need

getPedOccupiedVehicle
setVehicleDoorState
addCommandHandler

 

Edited by Dimos7

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.