AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CS:GO] Hook game in background (https://forums.alliedmods.net/showthread.php?t=309019)

Ilusion9 07-10-2018 13:48

[CS:GO] Hook game in background
 
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.

kratoss1812 07-10-2018 15:15

Re: [CS:GO] Hook game in background
 
https://sm.alliedmods.net/new-api/cl...IsClientInGame

if(IsClientInGame(client))
{
code
}

Mitchell 07-10-2018 15:19

Re: [CS:GO] Hook game in background
 
What do you mean runs his client in the background? You mean running in console mode?

backwards 07-10-2018 19:19

Re: [CS:GO] Hook game in background
 
Quote:

Originally Posted by Mitchell (Post 2602760)
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.

Mitchell 07-11-2018 01:47

Re: [CS:GO] Hook game in background
 
Quote:

Originally Posted by 1337norway (Post 2602816)
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.

backwards 07-11-2018 02:40

Re: [CS:GO] Hook game in background
 
Quote:

Originally Posted by Mitchell (Post 2602845)
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

mug1wara 07-11-2018 06:01

Re: [CS:GO] Hook game in background
 
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)

Neuro Toxin 07-12-2018 06:22

Re: [CS:GO] Hook game in background
 
Sourcemod cant check a clients actual OS keys.

mug1wara 07-12-2018 08:02

Re: [CS:GO] Hook game in background
 
Oh, I just asumed you could xd
sry for misleading information!

Bacardi 07-12-2018 16:43

Re: [CS:GO] Hook game in background
 
...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.


All times are GMT -4. The time now is 18:11.

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