Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion bridge/inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ if GetResourceState('ox_inventory') == 'started' then
end

Inventory.AddWeapon = function(source, data)
exports.ox_inventory:AddItem(source, data.weapon, 1, data.metadata, data.slot)
-- Assuming 'data.metadata' contains the weapon's ammo count
exports.ox_inventory:AddItem(source, data.weapon, 1, data.metadata)
end

Inventory.RemoveWeapon = function(source, data)
Expand Down
41 changes: 2 additions & 39 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Config.Debug = true

Config.Language = "en"

Config.DeathDropsWeapon = true -- Drops your current weapon upon death.
Config.DeathDropsWeapon = false -- Drops your current weapon upon death.

Config.ThrowKeybind = "e"

Expand Down Expand Up @@ -48,45 +48,8 @@ Config.Weapons = { -- Any weapon in this list is throwable.
"WEAPON_SMG",
"WEAPON_SMG_MK2",
"WEAPON_ASSAULTSMG",
"WEAPON_COMBATPDW",
"WEAPON_MACHINEPISTOL",
"WEAPON_MINISMG",
"WEAPON_RAYCARBINE",
"WEAPON_PUMPSHOTGUN",
"WEAPON_PUMPSHOTGUN_MK2",
"WEAPON_SAWNOFFSHOTGUN",
"WEAPON_ASSAULTSHOTGUN",
"WEAPON_BULLPUPSHOTGUN",
"WEAPON_MUSKET",
"WEAPON_HEAVYSHOTGUN",
"WEAPON_DBSHOTGUN",
"WEAPON_AUTOSHOTGUN",
"WEAPON_ASSAULTRIFLE",
"WEAPON_ASSAULTRIFLE_MK2",
"WEAPON_CARBINERIFLE",
"WEAPON_CARBINERIFLE_MK2",
"WEAPON_ADVANCEDRIFLE",
"WEAPON_SPECIALCARBINE",
"WEAPON_SPECIALCARBINE_MK2",
"WEAPON_BULLPUPRIFLE",
"WEAPON_BULLPUPRIFLE_MK2",
"WEAPON_COMPACTRIFLE",
"WEAPON_MG",
"WEAPON_COMBATMG",
"WEAPON_COMBATMG_MK2",
"WEAPON_GUSENBERG",
"WEAPON_SNIPERRIFLE",
"WEAPON_HEAVYSNIPER",
"WEAPON_HEAVYSNIPER_MK2",
"WEAPON_MARKSMANRIFLE",
"WEAPON_MARKSMANRIFLE_MK2",
"WEAPON_RPG",
"WEAPON_GRENADELAUNCHER",
"WEAPON_GRENADELAUNCHER_SMOKE",
"WEAPON_MINIGUN",
"WEAPON_FIREWORK",
"WEAPON_RAILGUN",
"WEAPON_HOMINGLAUNCHER",
"WEAPON_COMPACTLAUNCHER",
"WEAPON_RAYMINIGUN",
"WEAPON_GLOCK22",
}
6 changes: 2 additions & 4 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
shared_script '@qb-lockpickv2/ai_module_fg-obfuscated.lua'
fx_version 'cerulean'
lua54 'yes'
game 'gta5'

name 'pickle_weaponthrowing'
version '1.1.1'
description 'A multi-framework weapon throwing script.'
author 'Pickle Mods'


shared_scripts {
'@ox_lib/init.lua',
Expand Down
4 changes: 3 additions & 1 deletion modules/weapon/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function ThrowCurrentWeapon()
local equipped, weaponHash = GetCurrentPedWeapon(ped, 1)
local weapon = GetWeaponString(weaponHash)
if not equipped or not weapon then return end
local ammoCount = GetAmmoInPedWeapon(ped, weaponHash) -- Capture ammo count
throwingWeapon = true
CreateThread(function()
PlayAnim(ped, "melee@thrown@streamed_core", "plyr_takedown_front", -8.0, 8.0, -1, 49)
Expand All @@ -45,10 +46,11 @@ function ThrowCurrentWeapon()
SetEntityCoords(prop, coords.x, coords.y, coords.z)
SetEntityHeading(prop, GetEntityHeading(ped) + 90.0)
PerformPhysics(prop)
TriggerServerEvent("pickle_weaponthrowing:throwWeapon", {weapon = weapon, net_id = ObjToNet(prop)})
TriggerServerEvent("pickle_weaponthrowing:throwWeapon", {weapon = weapon, net_id = ObjToNet(prop), ammo = ammoCount}) -- Include ammo count
throwingWeapon = nil
end


function OnPlayerDeath()
if not Config.DeathDropsWeapon then return end
local ped = PlayerPedId()
Expand Down
17 changes: 16 additions & 1 deletion modules/weapon/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,26 @@ RegisterNetEvent("pickle_weaponthrowing:throwWeapon", function(data)
repeat
weaponID = os.time() .. "_" .. math.random(1000, 9999)
until not ThrownWeapons[weaponID]
ThrownWeapons[weaponID] = CreateWeaponData(source, data, weaponData)
-- Now include ammo count in the weapon data
local weaponInfo = CreateWeaponData(source, data, weaponData)
weaponInfo.ammo = data.ammo -- Store ammo count from the client
ThrownWeapons[weaponID] = weaponInfo
RemoveWeapon(source, ThrownWeapons[weaponID])
TriggerClientEvent("pickle_weaponthrowing:setWeaponData", -1, weaponID, data)
end)

RegisterNetEvent("pickle_weaponthrowing:pickupWeapon", function(weaponID)
local source = source
if not ThrownWeapons[weaponID] then return end
local entity = NetworkGetEntityFromNetworkId(ThrownWeapons[weaponID].net_id)
DeleteEntity(entity)
-- Ensure AddWeapon now accounts for the ammo count
AddWeapon(source, ThrownWeapons[weaponID])
ThrownWeapons[weaponID] = nil
TriggerClientEvent("pickle_weaponthrowing:setWeaponData", -1, weaponID, nil)
end)


RegisterNetEvent("pickle_weaponthrowing:pickupWeapon", function(weaponID)
local source = source
if not ThrownWeapons[weaponID] then return end
Expand Down