Raised This Month: $52 Target: $400
 13% 

Solved trying to decrease "client_preThink" CPU usage


Post New Thread Reply   
 
Thread Tools Display Modes
JocAnis
Veteran Member
Join Date: Jun 2010
Old 02-25-2021 , 13:58   Re: trying to decrease "client_preThink" CPU usage
Reply With Quote #11

Maybe better change your cpu if that code will overload it xd
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...)
JocAnis is offline
kww
Member
Join Date: Feb 2021
Location: Russia
Old 02-25-2021 , 14:45   Re: trying to decrease "client_preThink" CPU usage
Reply With Quote #12

Quote:
Originally Posted by OciXCrom View Post
It's literally 1 line of code. Understanding PreThink and CPU usage but not HamSandwich doesn't make much sense
Ahh, sorry

Quote:
Originally Posted by OciXCrom View Post
Code:
RegisterHam(Ham_Player_Jump, "player", "OnPlayerJump", 1) public OnPlayerJump(id) {     // your code here... }
so i should just rename client_preThink to OnPlayerJump?

Last edited by kww; 02-25-2021 at 14:50.
kww is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-25-2021 , 15:34   Re: trying to decrease "client_preThink" CPU usage
Reply With Quote #13

Yes, and you would use HAM_* return values instead of PLUGIN_*
__________________


Dear admins. If somehow you managed to read this, plz fix.

Last edited by OciXCrom; 02-25-2021 at 15:35.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-25-2021 , 20:50   Re: trying to decrease "client_preThink" CPU usage
Reply With Quote #14

Give this a try:
PHP Code:
RegisterHamHam_Player_Jump "player" "HamPlayerJump" );

public 
HamPlayerJumpid 
{    
    if ( !
get_pcvar_nummp_bhop_ban ) ) 
    {
        new 
iFlags;
        
        
entity_set_floatid EV_FL_fuser2 0.0 );      
        
iFlags entity_get_intidEV_INT_flags );
        
        if ( !( 
iFlags FL_WATERJUMP ) && ( iFlags FL_ONGROUND ) && ( entity_get_intid EV_INT_waterlevel ) < ) )
        {
            if ( 
gAutojumpid ] == 
            {
                new 
Float:fVelocity];
                
entity_get_vectorid EV_VEC_velocity fVelocity );
                
fVelocity] += 250.0;
                
entity_set_vectorid EV_VEC_velocity fVelocity );
            }
        }
        
        
entity_set_intid EV_INT_gaitsequence );
    }

__________________

Last edited by Bugsy; 02-25-2021 at 20:52.
Bugsy is offline
DeMNiX
Senior Member
Join Date: Nov 2011
Location: Russia
Old 02-26-2021 , 04:49   Re: trying to decrease "client_preThink" CPU usage
Reply With Quote #15

better this way

use it https://dev-cs.ru/resources/939/

and like that
Code:
public plugin_init()
{
    // called once, when player pressed space button or unpressed it
	RegisterKeyPressed(IN_JUMP, "fw_PlayerJump");
}


public fw_PlayerJump(id, fwdid, bPressed)
{
    // calling when pressed
	if (bPressed)
	{
		if (!is_user_alive(id))
			return;

		if (get_entvar(id, var_flags) & FL_ONGROUND)
		{
            // your code here...
        }
    }
}
__________________
DeMNiX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-26-2021 , 08:45   Re: trying to decrease "client_preThink" CPU usage
Reply With Quote #16

Can you explain why this is better?
__________________
Bugsy is offline
kww
Member
Join Date: Feb 2021
Location: Russia
Old 02-26-2021 , 10:01   Re: trying to decrease "client_preThink" CPU usage
Reply With Quote #17

Thanks @CrazY. @OciXCrom and @Bugsy for help

Last edited by kww; 02-26-2021 at 10:02.
kww is offline
DeMNiX
Senior Member
Join Date: Nov 2011
Location: Russia
Old 02-28-2021 , 20:23   Re: trying to decrease "client_preThink" CPU usage
Reply With Quote #18

Quote:
Originally Posted by Bugsy View Post
Can you explain why this is better?
this code uses amxmod module that checks client's pressed buttons
if some current bitsums changed from prev. frame's bitsum, module will force event call once per change

add*
oh, i see. This way will call once, but for TS needs to jump every time when he is on the ground. Sorrry
__________________

Last edited by DeMNiX; 02-28-2021 at 20:27.
DeMNiX 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 20:58.


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