local QBCore = exports['qb-core']:GetCoreObject() if not lib then return end local Weapon = {} local Items = require 'modules.items.client' local Utils = require 'modules.utils.client' local pdWeapons = { --- TRUE İSE SİVİLLER KULLANAMAZ FALSE İSE SİVİLLER KULLANABİLİR. ["WEAPON_GLOCK19GEN4"] = true, ["WEAPON_BEANBAGSHOTGUN"] = true, ["WEAPON_NIGHTSTICK"] = true, } -- Polis ve siviller için ayrı animasyon süreleri local policeAnimTimes = { ['GROUP_MELEE'] = 800, [`GROUP_PISTOL`] = 800, [`GROUP_SMG`] = 1100, [`GROUP_MG`] = 1100, [`GROUP_RIFLE`] = 1100, [`GROUP_SHOTGUN`] = 1100, [`GROUP_STUNGUN`] = 1000 } local civilianAnimTimes = { ['GROUP_MELEE'] = 1800, [`GROUP_PISTOL`] = 2000, [`GROUP_SMG`] = 2200, [`GROUP_MG`] = 2200, [`GROUP_RIFLE`] = 2200, [`GROUP_SHOTGUN`] = 2200, [`GROUP_STUNGUN`] = 2200 } -- Polis animasyonları local policeAnims = { ['GROUP_MELEE'] = { 'reaction@intimidation@1h', 'intro', nil, 'reaction@intimidation@1h', 'outro', 800 }, [`GROUP_PISTOL`] = { 'reaction@intimidation@cop@unarmed', 'intro', nil, 'reaction@intimidation@cop@unarmed', 'outro', 300 }, [`GROUP_SMG`] = { 'reaction@intimidation@cop@unarmed', 'intro', nil, 'reaction@intimidation@cop@unarmed', 'outro', 400 }, [`GROUP_MG`] = { 'reaction@intimidation@cop@unarmed', 'intro', nil, 'reaction@intimidation@cop@unarmed', 'outro', 400 }, [`GROUP_RIFLE`] = { 'reaction@intimidation@cop@unarmed', 'intro', nil, 'reaction@intimidation@cop@unarmed', 'outro', 400 }, [`GROUP_SHOTGUN`] = { 'reaction@intimidation@cop@unarmed', 'intro', nil, 'reaction@intimidation@cop@unarmed', 'outro', 400 }, [`GROUP_STUNGUN`] = { 'reaction@intimidation@cop@unarmed', 'intro', nil, 'reaction@intimidation@cop@unarmed', 'outro', 300 } } -- Sivil animasyonları local civilianAnims = { ['GROUP_MELEE'] = { 'reaction@intimidation@1h', 'intro', nil, 'reaction@intimidation@1h', 'outro', 800 }, [`GROUP_PISTOL`] = { 'reaction@intimidation@1h', 'intro', nil, 'reaction@intimidation@1h', 'outro', 1000 }, [`GROUP_SMG`] = { 'reaction@intimidation@1h', 'intro', nil, 'reaction@intimidation@1h', 'outro', 1200 }, [`GROUP_MG`] = { 'reaction@intimidation@1h', 'intro', nil, 'reaction@intimidation@1h', 'outro', 1200 }, [`GROUP_RIFLE`] = { 'reaction@intimidation@1h', 'intro', nil, 'reaction@intimidation@1h', 'outro', 1200 }, [`GROUP_SHOTGUN`] = { 'reaction@intimidation@1h', 'intro', nil, 'reaction@intimidation@1h', 'outro', 1200 }, [`GROUP_STUNGUN`] = { 'reaction@intimidation@1h', 'intro', nil, 'reaction@intimidation@1h', 'outro', 800 } } local function getGroupName(weaponGroup) if weaponGroup == `GROUP_PISTOL` then return `GROUP_PISTOL` elseif weaponGroup == `GROUP_SMG` then return `GROUP_SMG` elseif weaponGroup == `GROUP_MG` then return `GROUP_MG` elseif weaponGroup == `GROUP_RIFLE` then return `GROUP_RIFLE` elseif weaponGroup == `GROUP_SHOTGUN` then return `GROUP_SHOTGUN` elseif weaponGroup == `GROUP_STUNGUN` then return `GROUP_STUNGUN` else return 'GROUP_MELEE' end end local function vehicleIsCycle(vehicle) local class = GetVehicleClass(vehicle) return class == 8 or class == 13 end function Weapon.Disarm(currentWeapon, noAnim) if currentWeapon?.timer then currentWeapon.timer = nil local isPolice = QBCore.Functions.GetPlayerData().job.type == "leo" TriggerServerEvent('ox_inventory:updateWeapon') SetPedAmmo(cache.ped, currentWeapon.hash, 0) if client.weaponanims and not noAnim then if cache.vehicle and vehicleIsCycle(cache.vehicle) then goto skipAnim end ClearPedSecondaryTask(cache.ped) local coords = GetEntityCoords(cache.ped, true) local weaponGroup = GetWeapontypeGroup(currentWeapon.hash) local groupName = getGroupName(weaponGroup) local selectedAnims = isPolice and policeAnims or civilianAnims local anim = selectedAnims[groupName] -- Sleep değerini direkt olarak animasyon tablosundan al local sleep = (isPolice and policeAnimTimes[groupName] or civilianAnimTimes[groupName]) or 800 if anim then Utils.PlayAnimAdvanced(sleep, anim[4], anim[5], coords.x, coords.y, coords.z, 0, 0, GetEntityHeading(cache.ped), 8.0, 3.0, sleep, 50, 0) else Utils.PlayAnimAdvanced(sleep, 'reaction@intimidation@1h', 'outro', coords.x, coords.y, coords.z, 0, 0, GetEntityHeading(cache.ped), 8.0, 3.0, sleep, 50, 0) end end ::skipAnim:: if client.weaponnotify then Utils.ItemNotify({ currentWeapon, 'ui_holstered' }) end TriggerEvent('ox_inventory:currentWeapon') end Utils.WeaponWheel() RemoveAllPedWeapons(cache.ped, true) end function Weapon.Equip(item, data, noWeaponAnim) local playerPed = cache.ped local coords = GetEntityCoords(playerPed, true) local isPolice = QBCore.Functions.GetPlayerData().job.type == "leo" if pdWeapons[data.name] and not isPolice and QBCore.Functions.GetPlayerData().job.type ~= "ems" then TriggerEvent("QBCore:Notify", "Bu silahı kullanamazsınız!", "error") return end if client.weaponanims then if noWeaponAnim or (cache.vehicle and vehicleIsCycle(cache.vehicle)) then goto skipAnim end local weaponGroup = GetWeapontypeGroup(data.hash) local groupName = getGroupName(weaponGroup) local selectedAnims = isPolice and policeAnims or civilianAnims local anim = selectedAnims[groupName] -- Sleep değerini direkt olarak animasyon tablosundan al local sleep = (isPolice and policeAnimTimes[groupName] or civilianAnimTimes[groupName]) or 800 if anim then Utils.PlayAnimAdvanced(sleep, anim[1], anim[2], coords.x, coords.y, coords.z, 0, 0, GetEntityHeading(playerPed), 8.0, 3.0, sleep, 50, 0.1) else Utils.PlayAnimAdvanced(sleep, 'reaction@intimidation@1h', 'intro', coords.x, coords.y, coords.z, 0, 0, GetEntityHeading(playerPed), 8.0, 3.0, sleep, 50, 0.1) end end ::skipAnim:: -- Kodun geri kalanı aynı kalıyor... item.hash = data.hash item.ammo = data.ammoname item.melee = GetWeaponDamageType(data.hash) == 2 and 0 item.timer = 0 item.throwable = data.throwable item.group = GetWeapontypeGroup(item.hash) GiveWeaponToPed(playerPed, data.hash, 0, false, true) if item.metadata.tint then SetPedWeaponTintIndex(playerPed, data.hash, item.metadata.tint) end if item.metadata.components then for i = 1, #item.metadata.components do local components = Items[item.metadata.components[i]].client.component for v=1, #components do local component = components[v] if DoesWeaponTakeWeaponComponent(data.hash, component) then if not HasPedGotWeaponComponent(playerPed, data.hash, component) then GiveWeaponComponentToPed(playerPed, data.hash, component) end end end end end if item.metadata.specialAmmo then local clipComponentKey = ('%s_CLIP'):format(data.model:gsub('WEAPON_', 'COMPONENT_')) local specialClip = ('%s_%s'):format(clipComponentKey, item.metadata.specialAmmo:upper()) if DoesWeaponTakeWeaponComponent(data.hash, specialClip) then GiveWeaponComponentToPed(playerPed, data.hash, specialClip) end end local ammo = item.metadata.ammo or item.throwable and 1 or 0 SetCurrentPedWeapon(playerPed, data.hash, true) SetPedCurrentWeaponVisible(playerPed, true, false, false, false) SetWeaponsNoAutoswap(true) SetPedAmmo(playerPed, data.hash, ammo) SetTimeout(0, function() RefillAmmoInstantly(playerPed) end) if item.group == `GROUP_PETROLCAN` or item.group == `GROUP_FIREEXTINGUISHER` then item.metadata.ammo = item.metadata.durability SetPedInfiniteAmmo(playerPed, true, data.hash) end TriggerEvent('ox_inventory:currentWeapon', item) if client.weaponnotify then Utils.ItemNotify({ item, 'ui_equipped' }) end return item, sleep end function Weapon.ClearAll(currentWeapon) Weapon.Disarm(currentWeapon) if client.parachute then local chute = `GADGET_PARACHUTE` GiveWeaponToPed(cache.ped, chute, 0, true, false) SetPedGadget(cache.ped, chute, true) end end Utils.Disarm = Weapon.Disarm Utils.ClearWeapons = Weapon.ClearAll return Weapon