General > Developers Corner
Automatically move someone to a group if they join the steam group?
JamminR:
You'd have to add a hook or function/say command to call the check function.
It's not going to run on it's own.
Also, you can't just add "Sandboxwars" to the url in the code (you posted 'original' code but have that in it too)
CommunityID variable would have to be passed or assigned within the function.
Jaden Zepeda:
Ok I tried this, didn't work:
--- Code: ---hook.Add("PlayerSpawn", "Spawn", function(ply)
function CommunityCheckStatus( sandboxwars, ply )
if not IsValid(ply) then return end
local id = util.SteamIDTo64( ply:SteamID() )
http.Fetch( "http://steamcommunity.com/groups/sandboxwars" .. sandboxwars .. "/memberslistxml/?xml=1?lolwat="..os.time(),
function( body, _, _, _ )
if string.find( body, id ) then
SetPlayerMember( ply )
else
print( "FALSE" )
end
end,
function( error )
print( "Something went terribly wrong!" )
print( error )
end
)
end
function CommunityCheckStatusID( sandboxwars, sid )
local id = util.SteamIDTo64( sid )
http.Fetch( "http://steamcommunity.com/groups/sandboxwars" .. sandboxwars .. "/memberslistxml/?xml=1?lolwat="..os.time(),
function( body, _, _, _ )
if string.find( body, id ) then
SetPlayerMemberID( id )
else
print( "FALSE" )
end
end,
function( error )
print( "Something went terribly wrong!" )
print( error )
end
)
end
function SetPlayerMember( ply )
if not IsValid(ply) then return end
RunConsoleCommand("ulx", "adduserid", ply:SteamID(), "member")
end
function SetPlayerMemberID( id )
RunConsoleCommand("ulx", "adduserid", ply:SteamID(), "member")
end
end)
--- End code ---
Jaden Zepeda:
Found a HUGE MISTAKE in the URL's and corrected it, thought for sure this would work but nope.
--- Code: ---hook.Add("PlayerSpawn", "Spawn", function(ply)
function CommunityCheckStatus( sandboxwars, ply )
if not IsValid(ply) then return end
local id = util.SteamIDTo64( ply:SteamID() )
http.Fetch("http://steamcommunity.com/groups/sandboxwars/memberslistxml/?xml=1?lolwat="..os.time(),
function( body, _, _, _ )
if string.find( body, id ) then
SetPlayerMember( ply )
else
print( "FALSE" )
end
end,
function( error )
print( "Something went terribly wrong!" )
print( error )
end
)
end
function CommunityCheckStatusID( sandboxwars, sid )
local id = util.SteamIDTo64( sid )
http.Fetch("http://steamcommunity.com/groups/sandboxwars/memberslistxml/?xml=1?lolwat="..os.time(),
function( body, _, _, _ )
if string.find( body, id ) then
SetPlayerMemberID( id )
else
print( "FALSE" )
end
end,
function( error )
print( "Something went terribly wrong!" )
print( error )
end
)
end
function SetPlayerMember( ply )
if not IsValid(ply) then return end
RunConsoleCommand("ulx", "adduserid", ply:SteamID(), "member")
end
function SetPlayerMemberID( id )
RunConsoleCommand("ulx", "adduserid", ply:SteamID(), "member")
end
end)
--- End code ---
An Error Has Occurred!
array_keys(): Argument #1 ($array) must be of type array, null given
[0] Board index
Go to full version