Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weapon_pistol bypasses SetNextPrimaryFire #5373

Closed
TIMONz1535 opened this issue Dec 21, 2022 · 3 comments
Closed

weapon_pistol bypasses SetNextPrimaryFire #5373

TIMONz1535 opened this issue Dec 21, 2022 · 3 comments

Comments

@TIMONz1535
Copy link

TIMONz1535 commented Dec 21, 2022

Details

The standard HL2 weapon 9mm pistol weapon_pistol resets his m_flNextPrimaryAttack every frame. It sets the variable to -0.1s (CurTime() - 0.1) after Lua call. So the weapon will always shoot, despite of the SetNextPrimaryFire.

Steps to reproduce

  • Call weapon:SetNextPrimaryFire(CurTime() + 60) on weapon_pistol
  • Call print(weapon:GetNextPrimaryFire() - CurTime()) or print(weapon:GetInternalVariable("m_flNextPrimaryAttack")) and you will see that it has been reset.
  • You still can shoot.
hook.Add(
	"Think",
	"5373_test",
	function()
		local weapon = Entity(1):GetActiveWeapon()
		print(
			weapon,
			weapon:GetNextPrimaryFire(),
			weapon:GetInternalVariable("m_flNextPrimaryAttack"),
			weapon:GetNextPrimaryFire() - CurTime()
		)
	end
)
Protocol version 24
Exe version 2022.06.08 (garrysmod)
Exe build: 10:53:50 May 30 2022 (8605) (4000)
GMod version 2022.07.13, branch: x86-64, multicore: 1
Windows 64bit
@robotboy655
Copy link
Contributor

It's not a bug,

https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/server/hl2/weapon_pistol.cpp#L313-L317

@TIMONz1535
Copy link
Author

I tried weapon:SetSaveValue("m_flSoonestPrimaryAttack", CurTime() + 60) but it does nothing on SV, also weapon:GetInternalVariable("m_flSoonestPrimaryAttack") returns nil on SV

@Kefta
Copy link
Contributor

Kefta commented Dec 22, 2022

m_flSoonestPrimaryAttack is not an exposed entity variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants