[REQ] Open Trunk script

roleplay
server

#1

I was wondering if it would be possible for someone to make a script that uses chat command to open the trunk.

ie: /trunk opens trunk


#2

Client:

RegisterNetEvent("Trunk")
AddEventHandler("Trunk", function()
	local Veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
	SetVehicleDoorOpen(Veh, 5, false, false)
end)

RegisterNetEvent("TrunkClose")
AddEventHandler("TrunkClose", function()
	local Veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
	SetVehicleDoorShut(Veh, 5, false)
end)

Server:

AddEventHandler('chatMessage', function(player, playerName, message)
	local message = string.lower(message)
	local args = stringsplit(message, " ");
	if message == "/trunk" then
	elseif args[2] == 'open' then
		TriggerClientEvent('Trunk', player)
		CancelEvent()
	elseif args[2] == 'close' then
		TriggerClientEvent('TrunkClose', player)
		CancelEvent()
	end
end)

function stringsplit(self, delimiter)
	local a = self:Split(delimiter)
	local t = {}
	
	for i = 0, #a - 1 do
		table.insert(t, a[i])
	end
	
	return t
end

type /trunk open/close


#3

It opens but doesn’t close.


#4

To be fair, he asked only to open the trunk, and I delivered.
Updated original post with a workaround.
IsVehicleDoorFullyOpen(vehicle, doorIndex) does not seem to work properly, it catches if the door is not open, but can’t close it if it is…


#5

Hey im getting a error when im trying to do /trunk can you help me?