Author Topic: Automatically move someone to a group if they join the steam group?  (Read 8426 times)

0 Members and 1 Guest are viewing this topic.

Offline Jaden Zepeda

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Is this possible with Lua? Automatically moving someone to a ULX group if they join my steam group?
Ulx group: member
Steam group: http://steamcommunity.com/groups/sandboxwars
If someone could write me up a quick code that would be great!

Offline Jaden Zepeda

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Automatically move someone to a group if they join the steam group?
« Reply #1 on: December 20, 2014, 03:47:14 PM »
I heard about a Steam callback but I still am clueless on if this is possible or not.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Automatically move someone to a group if they join the steam group?
« Reply #2 on: December 20, 2014, 09:14:53 PM »
ULX forum search within Dev corner is your friend.
http://forums.ulyssesmod.net/index.php/topic,7247.0.html
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Jaden Zepeda

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Automatically move someone to a group if they join the steam group?
« Reply #3 on: December 20, 2014, 09:37:25 PM »
ULX forum search within Dev corner is your friend.
http://forums.ulyssesmod.net/index.php/topic,7247.0.html

Wow Great! Sadly I'm still pretty new to Lua, so I have no Idea what function to add so they get ulx group member if they join the steam group.

Offline Jaden Zepeda

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Automatically move someone to a group if they join the steam group?
« Reply #4 on: December 20, 2014, 10:53:29 PM »
I thought this would work, replacing the prints with commands, didnt work...
Original:
Code: [Select]
function CommunityCheckStatus( communityID, ply )
        if not IsValid(ply) then return end
        local id = util.SteamIDTo64( ply:SteamID() )
        http.Fetch( "http://steamcommunity.com/groups/sandboxwars" .. communityID .. "/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( communityID, sid )
        local id = util.SteamIDTo64( sid )
        http.Fetch( "http://steamcommunity.com/groups/sandboxwars" .. communityID .. "/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
        print( "THIS PLAYER IS A MEMBER!")
end
 
function SetPlayerMemberID( id )
        print( "THIS PLAYER IS A MEMBER!")
end

Modified:

Code: [Select]
function CommunityCheckStatus( communityID, ply )
if not IsValid(ply) then return end
local id = util.SteamIDTo64( ply:SteamID() )
http.Fetch( "http://steamcommunity.com/groups/sandboxwars" .. communityID .. "/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( communityID, sid )
local id = util.SteamIDTo64( sid )
http.Fetch( "http://steamcommunity.com/groups/sandboxwars" .. communityID .. "/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", "adduser", ply:SteamID(), "member")
end
 
function SetPlayerMemberID( id )
RunConsoleCommand("ulx", "adduser", ply:SteamID(), "member")
end

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Automatically move someone to a group if they join the steam group?
« Reply #5 on: December 21, 2014, 01:46:52 AM »
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.
« Last Edit: December 21, 2014, 01:50:52 AM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Jaden Zepeda

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Automatically move someone to a group if they join the steam group?
« Reply #6 on: December 21, 2014, 08:25:07 AM »
Ok I tried this, didn't work:

Code: [Select]
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)

Offline Jaden Zepeda

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: Automatically move someone to a group if they join the steam group?
« Reply #7 on: December 21, 2014, 08:45:44 AM »
Found a HUGE MISTAKE in the URL's and corrected it, thought for sure this would work but nope.
Code: [Select]
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)

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given