forked from Simnation/Main
44 lines
1.1 KiB
Lua
44 lines
1.1 KiB
Lua
![]() |
if not ESX then
|
||
|
local exportExists, obj = pcall(function()
|
||
|
return exports.es_extended:getSharedObject()
|
||
|
end)
|
||
|
|
||
|
if exportExists then
|
||
|
ESX = obj
|
||
|
else
|
||
|
TriggerEvent('esx:getSharedObject', function(esx)
|
||
|
ESX = esx
|
||
|
end)
|
||
|
|
||
|
while not ESX do
|
||
|
Wait(100)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
---Logger function
|
||
|
---@param source string
|
||
|
---@param event string
|
||
|
---@param message string
|
||
|
---@param data table
|
||
|
function Log(source, event, message, data)
|
||
|
ESX.DiscordLog('default', "Slashtire", 'default', string.format("%s (%s) %s. data: %s", GetPlayerName(source), 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)
|
||
|
if Player(source).state.isDead then
|
||
|
return false, 'is_dead'
|
||
|
end
|
||
|
|
||
|
if IsPedHandcuffed(playerPed) then
|
||
|
return false, 'is_handcuffed'
|
||
|
end
|
||
|
|
||
|
return true
|
||
|
end
|