Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 49 additions & 170 deletions client/weapdraw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ local weapons = {
'WEAPON_STONE_HATCHET'
}

local holstered = true
local canFire = true
local currWeap = `WEAPON_UNARMED`
local currHolster = nil
local currHolsterTexture = nil
local wearingHolster = nil
local canFire = false

local function loadAnimDict(dict)
if HasAnimDictLoaded(dict) then return end
Expand Down Expand Up @@ -140,192 +135,76 @@ RegisterNetEvent('qb-weapons:ResetHolster', function()
canFire = true
currWeap = `WEAPON_UNARMED`
currHolster = nil
currHolsterTexture = nil
wearingHolster = nil
end)

RegisterNetEvent('qb-weapons:client:DrawWeapon', function()
if GetResourceState('qb-inventory') == 'missing' then return end
local sleep
local weaponCheck = 0
while true do
local ped = PlayerPedId()
sleep = 250
if DoesEntityExist(ped) and not IsEntityDead(ped) and not IsPedInParachuteFreeFall(ped) and not IsPedFalling(ped) and (GetPedParachuteState(ped) == -1 or GetPedParachuteState(ped) == 0) then
sleep = 0
if currWeap ~= GetSelectedPedWeapon(ped) then
local pos = GetEntityCoords(ped, true)
local rot = GetEntityHeading(ped)

local newWeap = GetSelectedPedWeapon(ped)
SetCurrentPedWeapon(ped, currWeap, true)
loadAnimDict('reaction@intimidation@1h')
loadAnimDict('reaction@intimidation@cop@unarmed')
loadAnimDict('rcmjosh4')
loadAnimDict('weapons@pistol@')

local holsterVariant = GetPedDrawableVariation(ped, 8)
wearingHolster = false
for i = 1, #Config.WeapDraw.variants, 1 do
if holsterVariant == Config.WeapDraw.variants[i] then
wearingHolster = true
end
end
if checkWeapon(newWeap) then
if holstered then
if wearingHolster then
--TaskPlayAnim(ped, 'rcmjosh4', 'josh_leadout_cop2', 8.0, 2.0, -1, 48, 10, 0, 0, 0 )
canFire = false
CeaseFire()
currHolster = GetPedDrawableVariation(ped, 7)
currHolsterTexture = GetPedTextureVariation(ped, 7)
TaskPlayAnimAdvanced(ped, 'rcmjosh4', 'josh_leadout_cop2', pos.x, pos.y, pos.z, 0, 0, rot, 3.0, 3.0, -1, 50, 0, 0, 0)
Wait(300)
SetCurrentPedWeapon(ped, newWeap, true)

if isWeaponHolsterable(newWeap) then
SetPedComponentVariation(ped, 7, currHolster == 8 and 2 or currHolster == 1 and 3 or currHolster == 6 and 5, currHolsterTexture, 2)
end
currWeap = newWeap
Wait(300)
ClearPedTasks(ped)
holstered = false
canFire = true
else
canFire = false
CeaseFire()
TaskPlayAnimAdvanced(ped, 'reaction@intimidation@1h', 'intro', pos.x, pos.y, pos.z, 0, 0, rot, 8.0, 3.0, -1, 50, 0, 0, 0)
Wait(1000)
SetCurrentPedWeapon(ped, newWeap, true)
currWeap = newWeap
Wait(1400)
ClearPedTasks(ped)
holstered = false
canFire = true
end
elseif newWeap ~= currWeap and checkWeapon(currWeap) then
if wearingHolster then
canFire = false
CeaseFire()

TaskPlayAnimAdvanced(ped, 'reaction@intimidation@cop@unarmed', 'intro', pos.x, pos.y, pos.z, 0, 0, rot, 3.0, 3.0, -1, 50, 0, 0, 0)
Wait(500)

if isWeaponHolsterable(currWeap) then
SetPedComponentVariation(ped, 7, currHolster, currHolsterTexture, 2)
end

SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
currHolster = GetPedDrawableVariation(ped, 7)
currHolsterTexture = GetPedTextureVariation(ped, 7)

TaskPlayAnimAdvanced(ped, 'rcmjosh4', 'josh_leadout_cop2', pos.x, pos.y, pos.z, 0, 0, rot, 3.0, 3.0, -1, 50, 0, 0, 0)
Wait(300)
SetCurrentPedWeapon(ped, newWeap, true)
local ped = PlayerPedId()
local currWeap = `WEAPON_UNARMED`
local holstered = true
canFire = true

if isWeaponHolsterable(newWeap) then
SetPedComponentVariation(ped, 7, currHolster == 8 and 2 or currHolster == 1 and 3 or currHolster == 6 and 5, currHolsterTexture, 2)
end
loadAnimDict('rcmjosh4')
loadAnimDict('reaction@intimidation@cop@unarmed')

Wait(500)
currWeap = newWeap
ClearPedTasks(ped)
holstered = false
canFire = true
else
canFire = false
CeaseFire()
TaskPlayAnimAdvanced(ped, 'reaction@intimidation@1h', 'outro', pos.x, pos.y, pos.z, 0, 0, rot, 8.0, 3.0, -1, 50, 0, 0, 0)
Wait(1600)
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
TaskPlayAnimAdvanced(ped, 'reaction@intimidation@1h', 'intro', pos.x, pos.y, pos.z, 0, 0, rot, 8.0, 3.0, -1, 50, 0, 0, 0)
Wait(1000)
SetCurrentPedWeapon(ped, newWeap, true)
currWeap = newWeap
Wait(1400)
ClearPedTasks(ped)
holstered = false
canFire = true
while true do
if DoesEntityExist(ped) and not IsEntityDead(ped) then
local newWeap = GetSelectedPedWeapon(ped)
if newWeap ~= currWeap then
local holsterVariant = GetPedDrawableVariation(ped, 7)
local wearingHolster = Config.WeapDraw.variants[holsterVariant] ~= nil

if checkWeapon(newWeap) then -- Drawing a weapon
if holstered and wearingHolster and not IsEntityPlayingAnim(ped, 'rcmjosh4', 'josh_leadout_cop2', 3) then
canFire = false
CeaseFire()
TaskPlayAnim(ped, 'rcmjosh4', 'josh_leadout_cop2', 3.0, 3.0, -1, 50, 0, false, false, false)
Wait(300)

local emptyDrawable = Config.WeapDraw.variants[holsterVariant]
if emptyDrawable and emptyDrawable ~= holsterVariant then
SetPedComponentVariation(ped, 7, emptyDrawable, GetPedTextureVariation(ped, 7), 2)
end
else
if wearingHolster then
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
currHolster = GetPedDrawableVariation(ped, 7)
currHolsterTexture = GetPedTextureVariation(ped, 7)
TaskPlayAnimAdvanced(ped, 'rcmjosh4', 'josh_leadout_cop2', pos.x, pos.y, pos.z, 0, 0, rot, 3.0, 3.0, -1, 50, 0, 0, 0)
Wait(300)
SetCurrentPedWeapon(ped, newWeap, true)

if isWeaponHolsterable(newWeap) then
SetPedComponentVariation(ped, 7, currHolster == 8 and 2 or currHolster == 1 and 3 or currHolster == 6 and 5, currHolsterTexture, 2)
end

currWeap = newWeap
Wait(300)
ClearPedTasks(ped)
holstered = false
canFire = true
else
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
TaskPlayAnimAdvanced(ped, 'reaction@intimidation@1h', 'intro', pos.x, pos.y, pos.z, 0, 0, rot, 8.0, 3.0, -1, 50, 0, 0, 0)
Wait(1000)
SetCurrentPedWeapon(ped, newWeap, true)
currWeap = newWeap
Wait(1400)
ClearPedTasks(ped)
holstered = false
canFire = true
end
SetCurrentPedWeapon(ped, newWeap, true)
currWeap = newWeap
holstered = false
canFire = true
ClearPedTasks(ped)
elseif newWeap ~= `WEAPON_UNARMED` then
SetCurrentPedWeapon(ped, newWeap, true)
currWeap = newWeap
holstered = false
end
else
if not holstered and checkWeapon(currWeap) then
if wearingHolster then
canFire = false
CeaseFire()
TaskPlayAnimAdvanced(ped, 'reaction@intimidation@cop@unarmed', 'intro', pos.x, pos.y, pos.z, 0, 0, rot, 3.0, 3.0, -1, 50, 0, 0, 0)
Wait(500)

if isWeaponHolsterable(currWeap) then
SetPedComponentVariation(ped, 7, currHolster, currHolsterTexture, 2)
end
if newWeap == `WEAPON_UNARMED` and currWeap ~= `WEAPON_UNARMED` and wearingHolster and isWeaponHolsterable(currWeap) and not IsEntityPlayingAnim(ped, 'reaction@intimidation@cop@unarmed', 'intro', 3) then
canFire = false
CeaseFire()
TaskPlayAnim(ped, 'reaction@intimidation@cop@unarmed', 'intro', 3.0, 3.0, -1, 50, 0, false, false, false)
Wait(300)

SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
ClearPedTasks(ped)
SetCurrentPedWeapon(ped, newWeap, true)
holstered = true
canFire = true
currWeap = newWeap
else
canFire = false
CeaseFire()
TaskPlayAnimAdvanced(ped, 'reaction@intimidation@1h', 'outro', pos.x, pos.y, pos.z, 0, 0, rot, 8.0, 3.0, -1, 50, 0, 0, 0)
Wait(1400)
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
ClearPedTasks(ped)
SetCurrentPedWeapon(ped, newWeap, true)
holstered = true
canFire = true
currWeap = newWeap
local holsteredDrawable = Config.WeapDraw.variants[holsterVariant]
if holsteredDrawable and holsteredDrawable ~= holsterVariant then
SetPedComponentVariation(ped, 7, holsteredDrawable, GetPedTextureVariation(ped, 7), 2)
end
else
SetCurrentPedWeapon(ped, newWeap, true)
holstered = false

SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
currWeap = `WEAPON_UNARMED`
holstered = true
canFire = true
currWeap = newWeap
ClearPedTasks(ped)
end
end
end
end
Wait(sleep)
if currWeap == nil or currWeap == `WEAPON_UNARMED` then
weaponCheck += 1
if weaponCheck == 2 then
break
end
end
Wait(250)
end
end)



function CeaseFire()
CreateThread(function()
if GetResourceState('qb-inventory') == 'missing' then return end
Expand Down