1
0
Fork 0
forked from Simnation/Main
Main/resources/[carscripts]/kq_roofboxes/client/editable/debug.lua
2025-06-07 08:51:21 +02:00

119 lines
3.1 KiB
Lua

RESTARTING = false
local deleteModels = {
'kq_roofbox_1_1',
'kq_roofbox_1_2',
'kq_roofbox_1_3',
'kq_roofbox_1_4',
'kq_roofbox_1_5',
'kq_roofbox_1_6',
'kq_roofbox_1_7',
'kq_roofbox_1_8',
'kq_roofbox_2_1',
'kq_roofbox_2_2',
'kq_roofbox_2_3',
'kq_roofbox_2_4',
'kq_roofbox_2_5',
'kq_roofbox_2_6',
'kq_roofbox_2_7',
'kq_roofbox_2_8',
'kq_roofbox_3_1',
'kq_roofbox_3_2',
'kq_roofbox_3_3',
'kq_roofbox_3_4',
'kq_roofbox_3_5',
'kq_roofbox_3_6',
'kq_roofbox_3_7',
'kq_roofbox_3_8',
'kq_roofbox_2',
'kq_roofbox_3',
'kq_roofbox_b1',
'kq_roofbox_b2',
'kq_roofbox_b3',
'kq_roofbox_c1',
'kq_roofbox_c2',
'kq_roofbox_c3',
}
local function ContainsHash(tab, val)
for index, value in ipairs(tab) do
if GetHashKey(value) == val then
return true
end
end
return false
end
--- SAFE RESTART FUNCTIONALITY
RegisterNetEvent(GetCurrentResourceName() .. ':client:safeRestart')
AddEventHandler(GetCurrentResourceName() .. ':client:safeRestart', function(caller)
RESTARTING = true
Citizen.Wait(1000)
local entities = GetGamePool('CObject')
local playerPed = PlayerPedId()
WipeAllInteractionEntities()
for k, entity in pairs(entities) do
if DoesEntityExist(entity) then
if ContainsHash(deleteModels, GetEntityModel(entity)) then
SetEntityAsMissionEntity(entity, true, true)
DeleteEntity(entity)
end
end
end
if caller == GetPlayerServerId(PlayerId()) then
Citizen.Wait(2000)
ExecuteCommand('ensure ' .. GetCurrentResourceName())
end
end)
RegisterNetEvent(GetCurrentResourceName() .. ':client:toggleDebug')
AddEventHandler(GetCurrentResourceName() .. ':client:toggleDebug', function(val)
Config.debug = val
end)
--- STATE DEBUG
if Config.debug then
local function DrawStateData(vehicle, state)
local coords = GetEntityCoords(vehicle)
SetTextScale(0.28, 0.28)
SetTextFont(4)
SetTextProportional(1)
SetTextDropshadow(1, 1, 1, 1, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextCentre(0)
AddTextEntry("roofbox_veh_state", json.encode(state) .. '\n\n~g~Open: ' .. json.encode(Entity(vehicle).state.kq_roofboxes_open))
SetTextEntry("roofbox_veh_state")
SetDrawOrigin(coords, 0)
DrawText(0.0, 0.0)
ClearDrawOrigin()
end
--Citizen.CreateThread(function()
-- while true do
-- local sleep = 1000
--
-- local vehicle = GetVehiclePedIsUsing(PlayerPedId())
-- if vehicle > 0 then
-- sleep = 1
--
-- local state = GetVehicleRoofboxState(vehicle)
-- DrawStateData(vehicle, state)
-- end
--
-- Citizen.Wait(sleep)
-- end
--end)
end