• [Suggestion] Duplicated Ammo Types
    3 replies, posted
Hi people. Yesterday I was struggling with an SWEP that wasn't working for no reason. Apparently, the game refused to create its custom ammo type. After some experimentation, I noticed that there's a hardcoded limit of 128 ammo types. My first suggestion is to increase that limit a bit, as it can be easily reached with a few SWEP packs. However, I assume there's a reason to keep that limit (or perhaps it is a limitation of the engine itself) so maybe increasing it is not option. I also noticed that my game was full of duplicated ammo types. This is the original function, located in "lua/includes/extensions/game.lua": [CODE]game.AddAmmoType = function ( tbl ) if ( !tbl.name ) then return end table.insert( AmmoTypes, tbl ) end[/CODE] As you can see, it doesn't check if the new ammo type already exists, making the list quickly fill up with duplicates. Since we use a string to set our weapon ammo type, it probably only uses the first occurrence, and the rest of duplicates will never be used. I suggest adding this to that function: [CODE]game.AddAmmoType = function ( tbl ) if ( !tbl.name ) then return end for i=1, #AmmoTypes do if AmmoTypes[i].name == tbl.name then return end end table.insert( AmmoTypes, tbl ) end[/CODE] This way it won't create duplicated ammo types, and we can use more weapons at the same time. I did it in my GMOD instalation and it works perfectly. Perhaps it is a good idea to include that in the default game files.
[url]https://github.com/garrynewman/garrysmod/pull/1052[/url]
Oh, so it is already implemented in the beta Gmod? Nice. I guess we just need to wait until those changes are applied to the main branch.
I don't think it's implemented, it's still an open request, not a merged one yet
Sorry, you need to Log In to post a reply to this thread.