-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
40 lines (32 loc) · 1.25 KB
/
client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-- Pickups
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
-- if there's no nearby pickups we can wait a bit to save performance
if next(pickups) == nil then
Citizen.Wait(500)
end
for k,v in pairs(pickups) do
local distance = GetDistanceBetweenCoords(coords, v.coords.x, v.coords.y, v.coords.z, true)
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
local dict, anim = 'weapons@first_person@aim_rng@generic@projectile@sticky_bomb@', 'plant_floor'
if distance <= 5.0 then
ESX.Game.Utils.DrawText3D({
x = v.coords.x,
y = v.coords.y,
z = v.coords.z + 0.25
}, v.label)
end
if (closestDistance == -1 or closestDistance > 3) and distance <= 1.0 and not v.inRange and IsPedOnFoot(playerPed) then
TriggerServerEvent('esx:onPickup', v.id)
ESX.Streaming.RequestAnimDict(dict)
TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, 1000, 16, 0.0, false, false, false)
Citizen.Wait(1000)
PlaySoundFrontend(-1, 'PICK_UP', 'HUD_FRONTEND_DEFAULT_SOUNDSET', false)
v.inRange = true
end
end
end
end)