Raised This Month: $ Target: $400
 0% 

plugin causing csgo srcds freeze


Post New Thread Reply   
 
Thread Tools Display Modes
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 06-23-2022 , 09:12   Re: plugin causing csgo srcds freeze
Reply With Quote #11

Quote:
Originally Posted by azalty View Post
Avoid declaring variables inside frequently ran functions. Use global variables (either by declaring your variables outside or by using the 'static' keyword behind a variable).
Ex:

Code:
static float oldyaw;
oldyaw = g_flOldYawAngle[client];
See https://wiki.alliedmods.net/Introduc...7#Local_static

OnPlayerRunCmd is ran once every tick for every player. Assuming you have 20 players and your tickrate is 64, that makes 1280 calls per second. When you have that many calls, do as little checks and calculations as you can. Variable declaration is expensive.
I am beginning to understand why it is crashing but I am unsure of how to solve it.

I have tried doing what you suggested but it still crashes.

Code:
static float oldyaw;
static float delta;
AuricYoutube is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 06-23-2022 , 10:05   Re: plugin causing csgo srcds freeze
Reply With Quote #12

What he means is that stuff that runs a lot of times per second (based on frame/tick) should have the variables already created, cause this process is kinda expensive when running loops/lot of times.

Is better to use variables that you already have the value like "which button" is being pressed, before, when possible, than all that calculations logic.

Also, you shouldn't do a lot of calculations inside this process cause will hang

A good use case would be putting all that inside a timer, so instead of calling 1280 times per second you could optimize it to running, for example, once per second.
__________________

Last edited by Marttt; 06-23-2022 at 12:16.
Marttt is offline
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 06-23-2022 , 12:34   Re: plugin causing csgo srcds freeze
Reply With Quote #13

Quote:
Originally Posted by Marttt View Post
What he means is that stuff that runs a lot of times per second (based on frame/tick) should have the variables already created, cause this process is kinda expensive when running loops/lot of times.

Is better to use variables that you already have the value like "which button" is being pressed, before, when possible, than all that calculations logic.

Also, you shouldn't do a lot of calculations inside this process cause will hang

A good use case would be putting all that inside a timer, so instead of calling 1280 times per second you could optimize it to running, for example, once per second.
He also said that timer wouldn’t be good because it would not be accurate for simulating a tickrate
AuricYoutube is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:59.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode