From 3ff2f4ac746a94426a8f20292ba9b345e3845e9f Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 3 Jun 2021 19:38:29 +1000 Subject: [PATCH] fix(server/commands): /clearloadout will properly wipe all weapons Loadout indexes are being updated while the loop runs causing it to break after removing a few weapons. This reverts the command to how it worked prior to ESX 1.2 --- server/commands.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/commands.lua b/server/commands.lua index b20ccec1..5b6491b0 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -117,8 +117,8 @@ end, true, {help = _U('command_clearinventory'), validate = true, arguments = { }}) ESX.RegisterCommand('clearloadout', 'admin', function(xPlayer, args, showError) - for k,v in ipairs(args.playerId.loadout) do - args.playerId.removeWeapon(v.name) + for i=#args.playerId.loadout, 1, -1 do + xPlayer.removeWeapon(args.playerId.loadout[i].name) end end, true, {help = _U('command_clearloadout'), validate = true, arguments = { {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}