mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2026-11-10 13:57:18 +01:00
* refactor: declare exports at runtime and drop the player-data provides alias Signed-off-by: Mathu-lmn <[email protected]> * refactor: pass handlers directly to RegisterNetEvent Signed-off-by: Mathu-lmn <[email protected]> * refactor: use CreateThread/Wait without the Citizen prefix Signed-off-by: Mathu-lmn <[email protected]> * chore: remove trailing whitespace, stray lines and unused locals Signed-off-by: Mathu-lmn <[email protected]> --------- Signed-off-by: Mathu-lmn <[email protected]>
38 lines
839 B
Lua
38 lines
839 B
Lua
local safePositions = {}
|
|
|
|
RegisterNetEvent('money:allowPickupNear', function(pedId)
|
|
local entity = NetworkGetEntityFromNetworkId(pedId)
|
|
|
|
Wait(250)
|
|
|
|
if not DoesEntityExist(entity) then
|
|
return
|
|
end
|
|
|
|
if GetEntityHealth(entity) > 100 then
|
|
return
|
|
end
|
|
|
|
local coords = GetEntityCoords(entity)
|
|
safePositions[pedId] = coords
|
|
end)
|
|
|
|
RegisterNetEvent('money:tryPickup', function(entity)
|
|
if not safePositions[entity] then
|
|
return
|
|
end
|
|
|
|
local source = source
|
|
local playerPed = GetPlayerPed(source)
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
if #(safePositions[entity] - coords) < 2.5 then
|
|
exports['money']:addMoney(source, 'cash', 40)
|
|
end
|
|
|
|
safePositions[entity] = nil
|
|
end)
|
|
|
|
AddEventHandler('entityRemoved', function(entity)
|
|
safePositions[entity] = nil
|
|
end) |