View Single Post
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