Fix thrown items not synced with mid-joined players

This commit is contained in:
ElPumpo
2019-09-18 13:47:41 +02:00
parent 5159e892fe
commit 8586fdcce2
3 changed files with 25 additions and 3 deletions
+18
View File
@@ -40,6 +40,24 @@ AddEventHandler('esx:playerLoaded', function(xPlayer)
end
end)
RegisterNetEvent('esx:createMissingPickups')
AddEventHandler('esx:createMissingPickups', function(pickups)
for pickupId,v in pairs(pickups) do
ESX.Game.SpawnLocalObject('prop_money_bag_01', v.coords, function(obj)
SetEntityAsMissionEntity(obj, true, false)
PlaceObjectOnGroundProperly(obj)
Pickups[pickupId] = {
id = pickupId,
obj = obj,
label = v.label,
inRange = false,
coords = v.coords
}
end)
end
end)
AddEventHandler('playerSpawned', function()
while not ESX.PlayerLoaded do
Citizen.Wait(1)
+6 -3
View File
@@ -162,16 +162,19 @@ ESX.GetItemLabel = function(item)
end
end
ESX.CreatePickup = function(type, name, count, label, player)
ESX.CreatePickup = function(type, name, count, label, playerId)
local pickupId = (ESX.PickupId == 65635 and 0 or ESX.PickupId + 1)
local xPlayer = ESX.GetPlayerFromId(playerId)
ESX.Pickups[pickupId] = {
type = type,
name = name,
count = count
count = count,
label = label,
coords = xPlayer.getCoords()
}
TriggerClientEvent('esx:pickup', -1, pickupId, label, player)
TriggerClientEvent('esx:pickup', -1, pickupId, label, playerId)
ESX.PickupId = pickupId
end
+1
View File
@@ -234,6 +234,7 @@ AddEventHandler('es:playerLoaded', function(source, _player)
})
xPlayer.displayMoney(xPlayer.getMoney())
TriggerClientEvent('esx:createMissingPickups', _source, ESX.Pickups)
end)
end)