View Single Post
AnimalMonster
Senior Member
Join Date: May 2020
Old 12-01-2022 , 15:16   Re: Any thoughts on this code?
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
You're actually adding overhead by having to create a hook on every frame by calling RequestFrame() on every frame. If you need something faster than the minimum set_task() then I've seen smart people on here (e.g. Bugsy) recommend using a thinking entity to execute your code. This will not have the extra overhead in every frame like you have here.

Even if you need to execute on every frame, I think there are much better ways to do it that doesn't need to re-create the hook every time. For example, the forward server_frame() executes at the beginning of every frame already but it does warn you that "more specific hooks and forwards should be used whenever possible."


Also, instead of:

PHP Code:
#define CvarValueMaxLen CI_Value - CI_Name - CI_Id 
You can simply use sizeof or charsmax() (depending what which you need):

PHP Code:
sizeof g_iCvars[][CI_Value]
// or
charsmax(g_iCvars[][CI_Value]) 
Not a functional change and the only downside is that it requires the variable which is declared using that enum but shouldn't really matter since you've only used it in one variable.
Using an entity was my first thought since i didn't know there existed the RequestFrame. Before trying any of these i tried with simply using supercede on round end reapi hook and check every 0.1 but it was too much.. another way i could do and would maybe or maybe not be my best try is to check the round end and etc at the disconnect, connect, kill and spawn of players and round end to check if the time's up.

Last edited by AnimalMonster; 12-01-2022 at 15:16.
AnimalMonster is offline