forked from Simnation/Main
27 lines
919 B
Lua
27 lines
919 B
Lua
local attachedWeapons = {}
|
|
|
|
-- Track player weapons
|
|
RegisterNetEvent('force-sling:server:syncWeapons')
|
|
AddEventHandler('force-sling:server:syncWeapons', function(weaponData, action)
|
|
local src = source
|
|
if action == 'attach' then
|
|
attachedWeapons[src] = attachedWeapons[src] or {}
|
|
attachedWeapons[src][weaponData.weaponName] = weaponData
|
|
elseif action == 'detach' then
|
|
if attachedWeapons[src] then
|
|
attachedWeapons[src][weaponData.weaponName] = nil
|
|
end
|
|
end
|
|
|
|
-- Broadcast to all players except source
|
|
TriggerClientEvent('force-sling:client:syncWeapons', -1, src, weaponData, action)
|
|
end)
|
|
|
|
-- Clean up when player disconnects
|
|
AddEventHandler('playerDropped', function()
|
|
local src = source
|
|
if attachedWeapons[src] then
|
|
TriggerClientEvent('force-sling:client:cleanupPlayerWeapons', -1, src)
|
|
attachedWeapons[src] = nil
|
|
end
|
|
end)
|