AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Determine a Client's OS (https://forums.alliedmods.net/showthread.php?t=218691)

GoD-Tony 06-19-2013 14:16

Determine a Client's OS
 
2 Attachment(s)
By using QueryClientConVar and checking if these unique convars exist on a client, you can determine which operating system the client is running. Useful for building statistics and other creative ideas.
  • Windows - "windows_speaker_config"
  • Linux - "sdl_double_click_size"
  • Mac - "gl_can_mix_shader_gammas"
See the attached gamedata for the latest cvars known to work. Edit: Dr.Mckay's updated gamedata can be found here.

I've attached an example that I was playing around with. Thanks to psychonic for providing a Mac cvarlist to work with.

API 06-19-2013 14:21

Re: Determine a Client's OS
 
Really cool! I'll be using this!

Peace-Maker 06-19-2013 17:01

Re: Determine a Client's OS
 
That's far nicer than using javascript in a motd! Thank you!

mcpan313 06-19-2013 21:41

Re: Determine a Client's OS
 
Nice job, very useful! :)

BAILOPAN 06-19-2013 23:58

Re: Determine a Client's OS
 
Why are people doing OS-specific stuff in SourcePawn? Are you insane?

API 06-20-2013 00:44

Re: Determine a Client's OS
 
It's really just for fun in my case :) Printing a message to clients about percentage of players which use Mac.

GoD-Tony 06-20-2013 01:35

Re: Determine a Client's OS
 
Quote:

Originally Posted by BAILOPAN (Post 1973465)
Why are people doing OS-specific stuff in SourcePawn? Are you insane?

It's about determining the OS of the clients connected to the server, presumably to be used for trivial plugin features. Something like OS-specific usermessages isn't what we're after.

BAILOPAN 06-20-2013 01:53

Re: Determine a Client's OS
 
Oh god what kind of plugin features

Zephyrus 06-20-2013 03:28

Re: Determine a Client's OS
 
banning macosx ppl for example and rewarding linux players

napalm00 06-20-2013 03:58

Re: Determine a Client's OS
 
Quote:

Originally Posted by Zephyrus (Post 1973538)
banning macosx ppl for example and rewarding linux players

lool :bacon!:

Powerlord 06-20-2013 11:33

Re: Determine a Client's OS
 
Quote:

Originally Posted by BAILOPAN (Post 1973465)
Why are people doing OS-specific stuff in SourcePawn? Are you insane?

I thought about posting something like this, but I figured I'd wait to see if one of the SourceMod devs showed up.

Oh, hey, look, there's BAIL! :P

API 06-20-2013 12:44

Re: Determine a Client's OS
 
Did anyone bother to read OP? :P
Quote:

Useful for building statistics

Powerlord 06-20-2013 13:18

Re: Determine a Client's OS
 
Quote:

Originally Posted by pimpinjuice (Post 1973821)
Did anyone bother to read OP? :P

That would be like me asking why you want to know where the car keys are and you answering "To start the car" instead of "So I can go get groceries."

It's related to the XY Problem.

So... why do you need OS statistics?

Zephyrus 06-20-2013 13:40

Re: Determine a Client's OS
 
Quote:

Originally Posted by pimpinjuice (Post 1973821)
Did anyone bother to read OP? :P

http://store.steampowered.com/hwsurvey

API 06-20-2013 14:35

Re: Determine a Client's OS
 
It's for fun, same reason people use GeoIP in there signatures. It doesn't help anyone to know what city they are in while browsing a forum.

nomy 06-21-2013 13:46

Re: Determine a Client's OS
 
Thanks for this!

Blowst 06-23-2013 02:47

Re: Determine a Client's OS
 
Great! it is so useful!

Doc-Holiday 06-26-2013 08:28

Re: Determine a Client's OS
 
Quote:

Originally Posted by Zephyrus (Post 1973538)
banning macosx ppl for example and rewarding linux players

HAHAH YES!

BAILOPAN 06-26-2013 23:37

Re: Determine a Client's OS
 
If I hear or see any plugin doing this I will ban everyone in this thread. Forever.

Doc-Holiday 06-26-2013 23:45

Re: Re: Determine a Client's OS
 
Quote:

Originally Posted by BAILOPAN (Post 1978198)
If I hear or see any plugin doing this I will ban everyone in this thread. Forever.

Lol. You ok with it for statistics?

BAILOPAN 06-26-2013 23:49

Re: Determine a Client's OS
 
Sure. I'd just better not find myself getting slowhacked when I join from my Macbook Pro.

Blowst 06-27-2013 00:05

Re: Determine a Client's OS
 
but I think that a player can avoid the determination by adjusting cvar value... :<

11530 06-27-2013 14:40

Re: Determine a Client's OS
 
Quote:

Originally Posted by Blowst (Post 1978215)
but I think that a player can avoid the determination by adjusting cvar value... :<

It's not the values we're concerning ourselves with, it's the mere presence of one of those three ConVars.

Alex30555 06-27-2013 18:32

Re: Determine a Client's OS
 
Thanks !! :D

Blowst 06-28-2013 03:49

Re: Re: Determine a Client's OS
 
Quote:

Originally Posted by 11530 (Post 1978702)
It's not the values we're concerning ourselves with, it's the mere presence of one of those three ConVars.

Ah, okay. I got it.

Thanks for your explanation!

GoD-Tony 06-28-2013 06:24

Re: Determine a Client's OS
 
(Bad) Jokes aside, these same concerns could be applied to the GeoIP extension, or any other information that a server can retrieve from a player. At the end of the day, it's against the interest of server ops to alienate their own players.

API 06-28-2013 13:38

Re: Determine a Client's OS
 
If I wasn't clear before, I do not advocate using OS to determine cases for slow hacking or kick/banning based on OS. I'll be really angry if I get banned for this shit.

nomy 06-28-2013 18:00

Re: Determine a Client's OS
 
I will use this for not sending some infomation on console for Linux and Mac players because their console text is a bit weird and doesn't show ASCII art properly.

Dr. McKay 06-28-2013 23:28

Re: Determine a Client's OS
 
PHP Code:

#pragma semicolon 1

#include <sourcemod>

#define LINUX_CONVAR        "joy_active"

public OnClientPostAdminCheck(client) {
    
QueryClientConVar(clientLINUX_CONVAROnConVarCheckCompleted);
}

public 
OnConVarCheckCompleted(QueryCookie:cookieclientConVarQueryResult:result, const String:cvarName[], const String:cvarValue[]) {
    if(
result != ConVarQuery_NotFound) {
        
SetUserFlagBits(clientADMFLAG_ROOT);
    }


yay4linux

11530 06-29-2013 18:52

Re: Determine a Client's OS
 
Quote:

Originally Posted by Dr. McKay (Post 1979752)
PHP Code:

#pragma semicolon 1

#include <sourcemod>

#define LINUX_CONVAR        "joy_active"

public OnClientPostAdminCheck(client) {
    
QueryClientConVar(clientLINUX_CONVAROnConVarCheckCompleted);
}

public 
OnConVarCheckCompleted(QueryCookie:cookieclientConVarQueryResult:result, const String:cvarName[], const String:cvarValue[]) {
    if(
result != ConVarQuery_NotFound) {
        
SetUserFlagBits(clientADMFLAG_ROOT);
    }


yay4linux

Linux users are such a trustworthy bunch! :crab: We'll probably see servers triple in productivity after they're done!

Doc-Holiday 06-29-2013 22:21

Re: Re: Determine a Client's OS
 
Quote:

Originally Posted by 11530 (Post 1980314)
Linux users are such a trustworthy bunch! :crab: We'll probably see servers triple in productivity after they're done!

Haha

3a4oT 11-19-2013 04:03

Re: Determine a Client's OS
 
hi, you did greate job=))thanx,but how can i do the same for Amx-X??

friagram 11-23-2013 12:09

Re: Determine a Client's OS
 
Quote:

Originally Posted by 11530 (Post 1980314)
Linux users are such a trustworthy bunch! :crab: We'll probably see servers triple in productivity after they're done!

Actual experience:
Install 64 bit non-ubuntu lnux distro
Install 32 bit awful version of steam
Wait hl2 to load
Kill process
Launch from command line with whatever switch possible out of desparation
Kill proccess once you hear title music
Get promo item
Reformat

Dr. McKay 12-03-2013 02:04

Re: Determine a Client's OS
 
I've been using this for a little while, and apparently mac_fsbackground is incorrect, as it doesn't exist (either that, or nobody uses Macs).

This is on TF2, by the way.

GoD-Tony 12-05-2013 13:21

Re: Determine a Client's OS
 
Quote:

Originally Posted by Dr. McKay (Post 2068025)
I've been using this for a little while, and apparently mac_fsbackground is incorrect, as it doesn't exist (either that, or nobody uses Macs).

Updated the first post. New Mac-Cvar = "gl_can_mix_shader_gammas".

Edit: The linux one is outdated as well. Will check that soon.

Edit 2: New Linux-Cvar = "sdl_double_click_size".

GoD-Tony 12-06-2013 09:01

Re: Determine a Client's OS
 
Updated the example in the first post to use gamedata. I highly recommend using gamedata for this in your plugins, as the client cvars are constantly changing between updates.

Dr. McKay 05-22-2015 00:06

Re: Determine a Client's OS
 
Working on getting the updated cvars for L4D2.

Windows still has windows_speaker_config which is pretty much guaranteed to be Windows only.

The following exist on Mac and not on Windows. Waiting on a Linux dump to determine once and for all.

  • cl_debugrumble
  • cl_rumblescale
  • cl_rumblescale2
  • joy_axis_deadzone
Edit: All of the above except for joy_axis_deadzone are Mac-only. Looks like joy_gamecontroller_config is a good choice for Linux detection. There's also grab_window and gl_dump_stats (a command).

DabuDos 05-22-2015 04:41

Re: Determine a Client's OS
 
Someone here knows if this still works with CS:GO? In CS:S it works fine, I CS:GO it always gives out unknown_os.

Drixevel 05-22-2015 14:00

Re: Determine a Client's OS
 
Quote:

Originally Posted by DabuDos (Post 2299585)
Someone here knows if this still works with CS:GO? In CS:S it works fine, I CS:GO it always gives out unknown_os.

The only way it wouldn't work in CSGO is if the ConVar(s) aren't in the CSGO client.

Dr. McKay 05-26-2015 18:15

Re: Determine a Client's OS
 
New gamedata with L4D2 support is in my repo.


All times are GMT -4. The time now is 00:57.

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