sling
This commit is contained in:
parent
90cf348723
commit
619c6d40f6
4 changed files with 86 additions and 8 deletions
|
|
@ -18,6 +18,17 @@ Sling = {
|
|||
}
|
||||
}
|
||||
|
||||
local otherPlayersWeapons = {}
|
||||
|
||||
function Sling:SyncWeaponAttachment(weaponName, weaponVal, coords, action)
|
||||
local weaponData = {
|
||||
weaponName = weaponName,
|
||||
weaponVal = weaponVal,
|
||||
coords = coords
|
||||
}
|
||||
TriggerServerEvent('force-sling:server:syncWeapons', weaponData, action)
|
||||
end
|
||||
|
||||
function Sling:InitMain()
|
||||
Debug("info", "Initializing main thread")
|
||||
|
||||
|
|
@ -122,23 +133,22 @@ function Sling:WeaponThread()
|
|||
local weapon = GetSelectedPedWeapon(cache.ped)
|
||||
local isInVehicle = IsPedInAnyVehicle(cache.ped, false)
|
||||
|
||||
-- Check for vehicle state change
|
||||
if lastVehicleState ~= isInVehicle then
|
||||
lastVehicleState = isInVehicle
|
||||
if isInVehicle then
|
||||
-- Remove all weapons when entering vehicle
|
||||
for weaponName, _ in pairs(Sling.cachedAttachments) do
|
||||
if DoesEntityExist(Sling.cachedAttachments[weaponName].obj) then
|
||||
Utils:DeleteWeapon(weaponName)
|
||||
Sling:SyncWeaponAttachment(weaponName, nil, nil, 'detach')
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Reattach weapons when exiting vehicle
|
||||
for weaponName, weaponVal in pairs(Sling.cachedWeapons) do
|
||||
if not DoesEntityExist(Sling.cachedAttachments[weaponName]?.obj) then
|
||||
local coords = Sling.cachedPositions[weaponName] or Sling.cachedPresets[weaponName] or
|
||||
{ coords = { x = 0.0, y = -0.15, z = 0.0 }, rot = { x = 0.0, y = 0.0, z = 0.0 }, boneId = DEFAULT_BONE }
|
||||
Utils:CreateAndAttachWeapon(weaponName, weaponVal, coords, cache.ped)
|
||||
Sling:SyncWeaponAttachment(weaponName, weaponVal, coords, 'attach')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -263,13 +273,11 @@ function Sling:StartPositioning(selectData)
|
|||
SetEntityCollision(Sling.object, false, false)
|
||||
end
|
||||
|
||||
-- ENTER Handle control inputs for positioning
|
||||
if IsDisabledControlJustPressed(0, 18) then
|
||||
Sling:OnPositioningDone(coords, selectData)
|
||||
break
|
||||
end
|
||||
|
||||
-- Backspace cancel
|
||||
if IsDisabledControlJustPressed(0, 177) then
|
||||
DeleteObject(Sling.object)
|
||||
Sling.inPositioning = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue