Weapons Table.

I am iterating over my LocalPlayer():GetWeapons() table with an “in pairs” for loop.

for k, v in pairs (LocalPlayer():GetWeapons()) do

I am multiplying a number by “k” to set spacing for some things on the hud.

If I print the table for my weapons, and I have three weapons, for example, a crowbar, a pistol, and a 357, it goes:



1    =    Weapon [81] -- crowbar
2    =    Weapon [82] -- pistol
3    =    Weapon [83] -- 357


If I drop weapon 2 (pistol) it goes:



1    =    Weapon [81] -- crowbar
3    =    Weapon [83] -- 357


I need it to go



1    =    Weapon [81] -- crowbar
2    =    Weapon [83] -- 357


I tried:

table.SortByKey(LocalPlayer():GetWeapons(), 1)

But I get the error:



includes/extensions/table.lua:150: attempt to compare two userdata values


Anyone know what I should do?

Control the spacing yourself.



x = 0
for k, v in pairs( LocalPlayer( ):GetWeapons( ) ) do
  //stuff
  x = x + some_width
end


Found a way to get it working.

Thank you.