Raised This Month: $51 Target: $400
 12% 

[CSGO] How can I hook gravity change?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
butare
Senior Member
Join Date: Nov 2016
Old 01-21-2018 , 06:34   [CSGO] How can I hook gravity change?
Reply With Quote #1

Is there any way to hook gravity change for player? I don't need to hook sv_gravity command, and also if I use GetEntityGravity() it returns m_flGravity value, so maybe can I hook that somehow?
butare is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 01-22-2018 , 10:28   Re: [CSGO] How can I hook gravity change?
Reply With Quote #2

this should work, not sure if this is the correct way though
Code:
#include <sourcemod>
#include <sdktools>

public Action OnPlayerRunCmd(int client)
{
	static float fGravity[MAXPLAYERS+1] = { 1.0, ... };
	float gravity = GetEntityGravity(client);
	
	if(fGravity[client] != gravity)
	{
		// value is changed
	}
	
	fGravity[client] = gravity;
	
	return Plugin_Continue;
}
__________________
retired

Last edited by shavit; 01-22-2018 at 10:29.
shavit is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-22-2018 , 16:05   Re: [CSGO] How can I hook gravity change?
Reply With Quote #3

Probably best to hook server frames instead of usercmds.
__________________
Neuro Toxin is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 01-22-2018 , 17:57   Re: [CSGO] How can I hook gravity change?
Reply With Quote #4

Quote:
Originally Posted by Neuro Toxin View Post
Probably best to hook server frames instead of usercmds.
And why is that? As OP uses CS:GO, a usercmd is fired once per server frame even if the client misses it.
__________________
retired
shavit is offline
butare
Senior Member
Join Date: Nov 2016
Old 02-09-2018 , 13:30   Re: [CSGO] How can I hook gravity change?
Reply With Quote #5

woah, idk why but I didn't get any notifications that someone answered here, but I already using OnPlayerRunCmd(), and I thought maybe I can hook gravity change, rather then check it every frame, maybe somehow by using dhooks?
butare is offline
Reply



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 11:34.


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