Main/resources/[jobs]/[weapons]/force-sling/server/main.lua

28 lines
919 B
Lua
Raw Normal View History

2025-06-12 00:25:14 +02:00
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
2025-06-07 08:51:21 +02:00
end)