Main/resources/[carscripts]/slashtires/bridge/framework/nd/server.lua

35 lines
1.1 KiB
Lua
Raw Normal View History

2025-06-07 08:51:21 +02:00
if not lib then
error("ox_lib was not included or did not load before this file! Please make sure to add '@ox_lib/init.lua' before shared/bridge.lua inside the fxmanifest!")
end
---Logger function
---@param source string
---@param event string
---@param message string
---@param data table
function Log(source, event, message, data)
lib.logger(source, event, string.format("%s %s. data: %s", GetPlayerName(source), message, json.encode(data, {indent = true})))
end
---Checks if the player can slash tires
---@param source string
---@param playerPed integer
---@return boolean canPlayerSlash
---@return string|nil reason nil if canPlayerSlash is true
function CanPlayerSlashTires(source, playerPed)
local playerState = Player(source).state
if playerState.dead then
return false, 'is_dead'
end
if playerState.gettingCuffed or playerState.isCuffed then
return false, 'is_handcuffed'
end
if playerState.invBusy or playerState.handsUp or playerState.isCuffing then
return false, 'generic_fail_reason'
end
return true
end