Skip to content

Commit cb0164d

Browse files
author
Imagic
committed
Fix weapons duplication issue.
1 parent 5180e85 commit cb0164d

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

vrp/client/player_state.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ function tvRP.getWeapons()
104104
return weapons
105105
end
106106

107+
-- replace weapons (combination of getWeapons and giveWeapons)
108+
-- return previous weapons
109+
function tvRP.replaceWeapons(weapons)
110+
local old_weapons = tvRP.getWeapons()
111+
tvRP.giveWeapons(weapons, true)
112+
return old_weapons
113+
end
114+
107115
function tvRP.giveWeapons(weapons,clear_before)
108116
local player = GetPlayerPed(-1)
109117

vrp/modules/police.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ local choice_seize_weapons = {function(player, choice)
328328
local nuser_id = vRP.getUserId(nplayer)
329329
if nuser_id and vRP.hasPermission(nuser_id, "police.seizable") then
330330
if vRPclient.isHandcuffed(nplayer) then -- check handcuffed
331-
local weapons = vRPclient.getWeapons(nplayer)
331+
local weapons = vRPclient.replaceWeapons(nplayer, {})
332332
for k,v in pairs(weapons) do -- display seized weapons
333333
-- vRPclient._notify(player,lang.police.menu.seize.seized({k,v.ammo}))
334334
-- convert weapons to parametric weapon items
@@ -338,8 +338,6 @@ local choice_seize_weapons = {function(player, choice)
338338
end
339339
end
340340

341-
-- clear all weapons
342-
vRPclient._giveWeapons(nplayer,{},true)
343341
vRPclient._notify(nplayer,lang.police.menu.seize.weapons.seized())
344342
else
345343
vRPclient._notify(player,lang.police.not_handcuffed())
@@ -478,17 +476,14 @@ end, lang.police.menu.fine.description()}
478476
local choice_store_weapons = {function(player, choice)
479477
local user_id = vRP.getUserId(player)
480478
if user_id then
481-
local weapons = vRPclient.getWeapons(player)
479+
local weapons = vRPclient.replaceWeapons(player, {})
482480
for k,v in pairs(weapons) do
483481
-- convert weapons to parametric weapon items
484482
vRP.giveInventoryItem(user_id, "wbody|"..k, 1, true)
485483
if v.ammo > 0 then
486484
vRP.giveInventoryItem(user_id, "wammo|"..k, v.ammo, true)
487485
end
488486
end
489-
490-
-- clear all weapons
491-
vRPclient._giveWeapons(player,{},true)
492487
end
493488
end, lang.police.menu.store_weapons.description()}
494489

0 commit comments

Comments
 (0)