This commit is contained in:
Nordi98 2025-06-12 00:25:14 +02:00
parent 90cf348723
commit 619c6d40f6
4 changed files with 86 additions and 8 deletions

View file

@ -1,3 +1,27 @@
CreateThread(function()
Sling:InitMain()
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)