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

[CS:GO] Hook game in background


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 07-10-2018 , 13:48   [CS:GO] Hook game in background
Reply With Quote #1

Is there a way to hook or to check when a client runs his client in background?
I know there's an option in Audio Settings: Play audio when game in background, so within the game it's possible to check.

Last edited by Ilusion9; 07-10-2018 at 13:48.
Ilusion9 is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 07-10-2018 , 15:15   Re: [CS:GO] Hook game in background
Reply With Quote #2

https://sm.alliedmods.net/new-api/cl...IsClientInGame

if(IsClientInGame(client))
{
code
}
kratoss1812 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 07-10-2018 , 15:19   Re: [CS:GO] Hook game in background
Reply With Quote #3

What do you mean runs his client in the background? You mean running in console mode?
Mitchell is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 07-10-2018 , 19:19   Re: [CS:GO] Hook game in background
Reply With Quote #4

Quote:
Originally Posted by Mitchell View Post
What do you mean runs his client in the background? You mean running in console mode?
I'm pretty sure he means alt-tabbed.

You can't check this naively in source mod or from the source engine server itself. You would need a way to run code on a client to figure this out normally but through my development of my previous anti-cheats I've discovered a way within CS:GO at least. NetChannels has a virtual function called GetTimeSinceLastReceived. You can use this information to figure out when the game client last sent data to the server along with the GetAvgLoss function to figure out when players are most likely alt tabbed. They will send less info to the server or none in some cases then they would if they were in-game. This is really the only way I believe you can currently do this and it's really hacky.
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 07-11-2018 , 01:47   Re: [CS:GO] Hook game in background
Reply With Quote #5

Quote:
Originally Posted by 1337norway View Post
I'm pretty sure he means alt-tabbed.

You can't check this naively in source mod or from the source engine server itself. You would need a way to run code on a client to figure this out normally but through my development of my previous anti-cheats I've discovered a way within CS:GO at least. NetChannels has a virtual function called GetTimeSinceLastReceived. You can use this information to figure out when the game client last sent data to the server along with the GetAvgLoss function to figure out when players are most likely alt tabbed. They will send less info to the server or none in some cases then they would if they were in-game. This is really the only way I believe you can currently do this and it's really hacky.
If they have the game minimize i remember others saying OnPlayerRunCmd no longer fires for that client so you could have a timer every 10 seconds check if some one hasn't fired that forward.
Mitchell is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 07-11-2018 , 02:40   Re: [CS:GO] Hook game in background
Reply With Quote #6

Quote:
Originally Posted by Mitchell View Post
If they have the game minimize i remember others saying OnPlayerRunCmd no longer fires for that client so you could have a timer every 10 seconds check if some one hasn't fired that forward.
In CS:GO at least the server seems to be firing the last good known usercmd if no new ones are supplied. This prevents the AirStuck from when you stop sending packets method and also is the reason why when most people timeout they continue walking forwards or backwards into walls constantly. The normal hook for OnRunCommand would still fire in this case so it's not exposed to sourcemod as anything different. Should be a function you can hook prior to see if the RunCommand is being called via normal means after ProcessUserCmds or is being forwarded the most recent usercmd received. It's a good idea just not natively easy in sourcemod as you'd need a custom extension wrote for handling this.

*edit* also I already know you are aware of this, just public discussion so others know if they find this topic
__________________
I highly recommend joining the SourceMod Discord Server for real time support.

Last edited by backwards; 07-11-2018 at 02:47.
backwards is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-11-2018 , 06:01   Re: [CS:GO] Hook game in background
Reply With Quote #7

You could check if the player has pressed alt + tab, I would toggle a boolean, then make it false if the client eg. presses w. (If that's even what you mean, no idea)
mug1wara is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 07-12-2018 , 06:22   Re: [CS:GO] Hook game in background
Reply With Quote #8

Sourcemod cant check a clients actual OS keys.
__________________
Neuro Toxin is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 07-12-2018 , 08:02   Re: [CS:GO] Hook game in background
Reply With Quote #9

Oh, I just asumed you could xd
sry for misleading information!
mug1wara is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-12-2018 , 16:43   Re: [CS:GO] Hook game in background
Reply With Quote #10

...well, player cmd rate will drop down under 30 if game window is not focused/active.
Because game start run about 30 FPS when it is in background, inactive.
__________________
Do not Private Message @me
Bacardi 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 11:30.


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