Open VortixDev opened 5 years ago
So don't do it?
A practical example of this bug is in Clockwork, where next primary fire is set into the future when a weapon is lowered and is set back to a previous value (which lies in the past by the time it is set back) when it is raised. I've patched this on Clockwork's end, but older versions will still be affected, and other scripts may be too.
I consider this a potential issue, because such shooting causes the server to lag for a second or so. If your weapon has a large clip, for example, about 500, then your server will freeze
So I tried to profile in singleplayer and something similar happens there, but not so terrible. Lag occurs in GMOD, GLua, CBaseEntity::EmitSound, Unaccounted
perhaps some badcode called on top of the FireBullets can worsen the situation, but I can't profile dedicated server
Setting the next primary fire time from a future time to a past time causes automatic weapons to simulate a number of shots based on how far into the past you set the next fire time.
To clarify:
bot_zombie 1
would be helpful, too)weapon_ar2
andweapon_smg1
)Player(userID):GetActiveWeapon():SetNextPrimaryFire(CurTime() + 20) timer.Simple(6, function() Player(userID):GetActiveWeapon():SetNextPrimaryFire(CurTime() - 15) end)
Once the timer runs and sets the primary fire time into the past, the game seems to treat the situation as if I'd been firing for the 15 seconds I set it back for. The bot dies instantly, and my ammo is depleted. If I set the time to something smaller, like 1 second, I notice a sudden decrease in ammo and a large health loss from the bot once the timer elapses, but the bot survives and I am left with some ammo remaining.