Files
ND_Core/client/functions.lua

81 lines
2.4 KiB
Lua
Raw Normal View History

2023-07-16 12:29:20 +02:00
function NDCore.getPlayer()
return NDCore.player
end
2023-08-23 00:34:12 +02:00
function NDCore.getCharacters()
return NDCore.characters
end
function NDCore.getPlayersFromCoords(distance, coords)
if coords then
2023-07-09 03:07:46 +02:00
coords = type(coords) == "table" and vec3(coords.x, coords.y, coords.z) or coords
else
2023-01-03 18:18:54 -08:00
coords = GetEntityCoords(PlayerPedId())
end
distance = distance or 5
local closePlayers = {}
2023-01-03 18:18:54 -08:00
local players = GetActivePlayers()
2023-01-03 18:24:38 -08:00
for _, player in ipairs(players) do
local target = GetPlayerPed(player)
local targetCoords = GetEntityCoords(target)
local targetdistance = #(targetCoords - coords)
if targetdistance <= distance then
closePlayers[#closePlayers + 1] = player
end
end
return closePlayers
end
2023-07-09 21:19:35 +02:00
2023-09-24 11:19:22 +02:00
function NDCore.revivePlayer(reset, keepDead)
local usingAmbulance = GetResourceState("ND_Ambulance") == "started"
local veh = GetVehiclePedIsIn(cache.ped)
local seat = cache.seat
local coords = GetEntityCoords(cache.ped)
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, GetEntityHeading(cache.ped), true, true, false)
local ped = PlayerPedId()
if cache.ped ~= ped then
DeleteEntity(cache.ped)
ClearAreaOfPeds(coords.x, coords.y, coords.z, 1.5, false)
end
SetEntityInvincible(ped, false)
FreezeEntityPosition(ped, false)
SetEntityVisible(ped, true)
SetEveryoneIgnorePlayer(ped, false)
SetPedCanBeTargetted(ped, true)
SetEntityCanBeDamaged(ped, true)
SetBlockingOfNonTemporaryEvents(ped, false)
SetPedCanRagdollFromPlayerImpact(ped, true)
ClearPedTasksImmediately(ped)
if veh and veh ~= 0 then
SetPedIntoVehicle(ped, veh, seat)
end
if not keepDead then
LocalPlayer.state.dead = false
end
if reset and GetPedMovementClipset(ped) == `move_m@injured` then
ClearEntityLastDamageEntity(ped)
SetPedMoveRateOverride(ped, 1.0)
ResetPedMovementClipset(ped, 0)
end
if reset and usingAmbulance then
exports["ND_Ambulance"]:resetBodyDamage()
end
end
function NDCore.notify(...)
if GetResourceState("ModernHUD") == "started" then
exports["ModernHUD"]:notify(...)
elseif GetResourceState("ox_lib") == "started" then
lib.notify(...)
end
end
2023-07-09 21:19:35 +02:00
for name, func in pairs(NDCore) do
if type(func) == "function" then
exports(name, func)
end
end