Hello, I’m editing a Lock System and I want to when I lock or unlock a vehicle appears a message on the vehicle saying “Locked” or “Unlocked”.
I manage to make the message working by using a DrawText3Ds, but the message appears on my player.
Does someone know how can I make the message appear in the vehicle?
Examples on how it is working now:
This is the part of the code that is controlling the text coordinates
function Display(mePlayer, text, offset)
local displaying = true
Citizen.CreateThread(function()
Wait(time)
displaying = false
end)
Citizen.CreateThread(function()
nbrDisplaying = nbrDisplaying + 1
while displaying do
Wait(0)
local coords = GetEntityCoords(GetPlayerPed(mePlayer), false)
DrawText3Ds( coords.x, coords.y, coords.z, text)
end
nbrDisplaying = nbrDisplaying - 1
end)
end
And this is what opens, closes the vehicle and triggers the message:
RegisterNetEvent('esx_vehiclelock:triggerDisplay')
AddEventHandler('esx_vehiclelock:triggerDisplay', function(text, source)
local offset = 1 + (nbrDisplaying*0.14)
Display(GetPlayerFromServerId(source), text, offset)
end)
function OpenCloseVehicle()
local playerPed = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)
local vehicle = nil
if IsPedInAnyVehicle(playerPed, false) then
vehicle = GetVehiclePedIsIn(playerPed, false)
else
vehicle = GetClosestVehicle(coords.x, coords.y, coords.z, 7.0, 0, 70)
end
local locked = GetVehicleDoorLockStatus(vehicle)
if locked == 1 then -- if unlocked
SetVehicleDoorsLocked(vehicle, 2)
PlayVehicleDoorCloseSound(vehicle, 1)
TriggerServerEvent('esx_vehiclelock:shareDisplay', "Vehicle locked")
Wait(5000)
elseif locked == 2 then -- if locked
SetVehicleDoorsLocked(vehicle, 1)
PlayVehicleDoorOpenSound(vehicle, 0)
TriggerServerEvent('esx_vehiclelock:shareDisplay', "Vehicle unlocked")
Wait(5000)
end
end