Hey FP. I’m kind of lost with this issue and I’m fairly new to Lua. I’m trying to mimic CS:S physics and gameplay for numerous Fretta gamemodes.
First issue: When a round starts, all the weapons on the map are affected by physics like gravity, and fall from their place midair. I don’t believe this is the issue with HL2 weapons though, but only custom ones. Supposingly, I’m missing the piece of code from the weapons that disables this behaviour and freezes the weapons at their spawn location. This is the intended behaviour I’d like to have, as it’s not pretty to have a ton of guns falling on ground instead of being organized nicely on the shelf. “phys_timescale 0” won’t do, I still need to have proper physics.
I ended up with something like this:
[LUA]for k,v in pairs(ents.GetAll()) do
if v:IsWeapon() then
local phys = v:GetPhysicsObject()
if phys and phys:IsValid() then
Only need to hook it somewhere (OnPreRoundStart). Tried it inside GM:OnPreRoundStart in one gamemode, but that didn’t seem to work.
Second issue: Let’s take an example. We have a primary weapon, an AWP. We can still pickup any other primary weapon (in same slot) like Scout or AK47, and carry multiple weapons. Okay, we can disallow people picking up multiple weapons of the same type with this:
which may also cause some issues with ammunition, but seems better though. If we have an AWP, we cannot pickup another AWP this way. However, we can still pickup any other primary weapon like AK47 once, and carry both AK47 and AWP. I’d only like to carry one weapon at the time (plus the melee weapon + pistol).
Would a table with all primary weapon names (and another table with secondary weapons) work, or as “HasPrimaryWeapon = true” check somewhere work?
tl;dr: Freeze entities/weapons in mid air on spawn and disable picking up multiple weapons in same slot.
Any help is appreciated. Cheers!