Skip to content

Commit

Permalink
Fix weapons duplication issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Imagic committed Jul 18, 2018
1 parent 5180e85 commit cb0164d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 8 additions & 0 deletions vrp/client/player_state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ function tvRP.getWeapons()
return weapons
end

-- replace weapons (combination of getWeapons and giveWeapons)
-- return previous weapons
function tvRP.replaceWeapons(weapons)
local old_weapons = tvRP.getWeapons()
tvRP.giveWeapons(weapons, true)
return old_weapons
end

function tvRP.giveWeapons(weapons,clear_before)
local player = GetPlayerPed(-1)

Expand Down
9 changes: 2 additions & 7 deletions vrp/modules/police.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ local choice_seize_weapons = {function(player, choice)
local nuser_id = vRP.getUserId(nplayer)
if nuser_id and vRP.hasPermission(nuser_id, "police.seizable") then
if vRPclient.isHandcuffed(nplayer) then -- check handcuffed
local weapons = vRPclient.getWeapons(nplayer)
local weapons = vRPclient.replaceWeapons(nplayer, {})
for k,v in pairs(weapons) do -- display seized weapons
-- vRPclient._notify(player,lang.police.menu.seize.seized({k,v.ammo}))
-- convert weapons to parametric weapon items
Expand All @@ -338,8 +338,6 @@ local choice_seize_weapons = {function(player, choice)
end
end

-- clear all weapons
vRPclient._giveWeapons(nplayer,{},true)
vRPclient._notify(nplayer,lang.police.menu.seize.weapons.seized())
else
vRPclient._notify(player,lang.police.not_handcuffed())
Expand Down Expand Up @@ -478,17 +476,14 @@ end, lang.police.menu.fine.description()}
local choice_store_weapons = {function(player, choice)
local user_id = vRP.getUserId(player)
if user_id then
local weapons = vRPclient.getWeapons(player)
local weapons = vRPclient.replaceWeapons(player, {})
for k,v in pairs(weapons) do
-- convert weapons to parametric weapon items
vRP.giveInventoryItem(user_id, "wbody|"..k, 1, true)
if v.ammo > 0 then
vRP.giveInventoryItem(user_id, "wammo|"..k, v.ammo, true)
end
end

-- clear all weapons
vRPclient._giveWeapons(player,{},true)
end
end, lang.police.menu.store_weapons.description()}

Expand Down

1 comment on commit cb0164d

@DylinKirk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi i did the above and when you click store weapons they don't go in your inventory

Please sign in to comment.