Detecting if a Garry's Mod client is on a Mac?

Is there any way to check if a player is on a Mac? Thanks in advance.

And then look if the second char is a “:” then its windows else its mac.

or use http://wiki.garrysmod.com/?title=G.GetConVarNumber on a mac only convar. and see if it returns nil.

[lua]
function _R.Player:IsMac()
local path = util.RelativePathToFull(“gameinfo.txt”);
local exploded = string.Explode(path,"")
if exploded[2] == “:” then
return false
else
return true
end
[/lua]

usage: find the player meta-tabe and do: Player:IsMac()
Place in autorun/IsMac.lua


actually it might have to be client…

How would you make that without knowing it is clientside?

You could make the player run a consolecommand when they spawn (If they are on a mac) and the server can save that for the IsMac function.

[lua]
if CLIENT then
function _R.Player:IsMac()
local path = util.RelativePathToFull(“gameinfo.txt”);
local exploded = string.Explode(path,"")
if exploded[2] == “:” then
return false
else
return true
end

hook.Add(“PlayerInitialSpawn”,“PlayerIsMac”,function()
local IsMac = LocalPlayer():IsMac()
if IsMac then
RunConCommand(“IAmMac”,LocalPlayer())
else
RunConCommand(“IAmPC”,LocalPlayer())
end
end)
else
concommand.Add(“IAmMac”,function(ply)
print(ply.Nick()…" Is a mac")
end)
concommand.Add(“IAmPC”,function(ply)
print(ply.Nick()…" Is a Pc")
end)
end
[/lua]

[editline]29th December 2010[/editline]

goes in shared

[editline]29th December 2010[/editline]

why rate me dumb when i have given you what you wanted?

because you have dumb tabbing

[editline]29th December 2010[/editline]

[lua]if CLIENT then
function _R.Player:IsMac()
local path = util.RelativePathToFull(“gameinfo.txt”);
local exploded = string.Explode(path,"")
if exploded[2] == “:” then
return false
else
return true
end

hook.Add("PlayerInitialSpawn","PlayerIsMac",function()
	local IsMac = LocalPlayer():IsMac()
	if IsMac then
		RunConCommand("IAmMac",LocalPlayer()) 
	else
		RunConCommand("IAmPC",LocalPlayer())
	end
end)

else
concommand.Add(“IAmMac”,function(ply)
print(ply.Nick()…" Is a mac")
end)
concommand.Add(“IAmPC”,function(ply)
print(ply.Nick()…" Is a Pc")
end)
end[/lua]

All these methods are stupid, just detect a mac-only convar.

if pl:GetInfo(“some_mac_convar”) then pc else mac end

Not 100% sure if GetInfo will work on the mac convars.

No, because the code you tabbed without reading doesn’t work.

I didn’t say it would work :v:

again youve proven yourself to be a dumb skiddie

Idiot…

:saddowns:

Explains everything…

Also staying on-topic here, isn’t their some module recently released that lets you hook into the execution of console commands?

yes

At least read the first page of the modules section before asking a question like this.
http://www.facepunch.com/threads/994287-gm_concmdhook-An-omnipotent-console-command-hook

Well I knew it existed I was saying it in a retoricle sort of way, meaning maybe you could use said module to do this. I had an idea how but I forgot. :confused:

Where can I find a list of Mac only ConVars?