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

slowed loops if you dont have a weapon #208

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mustachedom
Copy link

I put a wait(1500) if unarmed
and a 1000 if there isnt CurrentWeaponData

this slows down the loops running while not using a weapon and gave less of a wait than a typical weapondraw animation so this should have minimal blowbacks for the 1.5 seconds it may miss

on my personal computer it took client side resmon down from 0.04 to 0.00 on idle

Describe Pull request
stop making loops go brrrr and make them slower when not needed and kept original speed when needed

Questions (please complete the following information):

  • Have you personally loaded this code into an updated qbcore project and checked all it's functionality? [yes] (Be honest)
  • Does your code fit the style guidelines? [yes]
  • Does your PR fit the contribution guidelines? [yes]

I put a wait(1500) if unarmed
and a 1000 if there isnt CurrentWeaponData

this slows down the loops running while not using a weapon and gave less of a wait than a typical weapondraw animation so this should have minimal blowbacks for the 1.5 seconds it may miss

on my personal computer it took client side resmon down from 0.04 to 0.00 on idle
client/main.lua Outdated
@@ -194,8 +195,10 @@ CreateThread(function()
TriggerServerEvent('qb-weapons:server:UpdateWeaponQuality', CurrentWeaponData, MultiplierAmount)
MultiplierAmount = 0
end
Wait(0)
else
Wait(1500)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting on the else for this condition means that it'll only be checking if the control was released every 1500ms. If a ped is armed, the first condition will be true, but if they don't attack, the second condition will be false meaning it'll wait 1500ms before checking the control again.

You could break up the conditions to only wait 1500ms when they're unarmed alone, but only wait 0-7ms if IsPedArmed returns 1 and you're waiting 0-7ms for the control.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally right and missed that

I'll edit it tomorrow with a if ped unarmed then Wait(1500) instead of :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Qwerty1Verified patched and reworked :) does this look good?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the Wait on 230 is necessary, and the single space on 235 was keeping the wait in line with the code, but that's not a big problem, just styling. Looks good to me

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left it in because I crashed without it. May not be needed and could have just been a random crash but better safe than sorry

Copy link
Contributor

@Qwerty1Verified Qwerty1Verified Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly when I loaded in before to test the new code I crashed too, before I had even brought in the new code.
I don't think it relates to that specific wait since there's one at the very bottom of the loop which always runs no matter what, but it must relate to something else.

I did test the code without the extra Wait and all seemed well so I'm not sure where the crash came from for us.

pogaroo

should be good, checks now if you have a weapon then runs the loop if true
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

Successfully merging this pull request may close these issues.

2 participants