ULX

Author Topic: Add a player to your steam friends using a command.  (Read 7936 times)

0 Members and 1 Guest are viewing this topic.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Add a player to your steam friends using a command.
« on: July 10, 2012, 01:02:20 AM »
I have been trying to do this for a few hours, but errors just keep popping up.

Code: [Select]
-- ULX AddFriend for ULX SVN/ULib SVN by HeLLFox_15
function AddFriend( ply, command, args )
    local stmid = string.Explode("|", args[1])
    local cid = tostring(tonumber(stmid[3]) * 2 + 76561197960265728 + tonumber(stmid[2]))
    ply:SendLua([[HTMLTest = vgui.Create("HTML") HTMLTest:OpenURL("http://steamidfinder.com/advanced.aspx?".."]] .. cid .. [[") timer.Create( "FriendAddWindowRemove", 1, 1, function( HTMLTest ) if( HTMLTest ) then HTMLTest:Remove() end end, HTMLTest)]])
end
concommand.Add("hf_addfriend",AddFriend)

function ulx.friend( calling_ply, target_plys )
    calling_ply:ConCommand("hf_addfriend " .. string.gsub("STEAM_0:0:30311872",":","|"))
end
local friend = ulx.command( "Utility", "ulx friend", ulx.friend, "!friend" )
friend:addParam{ type=ULib.cmds.PlayerArg, target="!^", default="@", ULib.cmds.optional }
friend:defaultAccess( ULib.ACCESS_ADMIN )
friend:help( "Adds a person to your friends list. If you did not specify any one, the person who last physgunned you will be added." )

The error that I get is that Gmod wont open the URL I gave it. ( that's pretty much it, it just says that it wont open it. )

I would also love this to be in 1 file only, that way its easy to add and remove it from ULX.

Would extra DLL's need to be used?
I cry every time I see that I am not a respected member of this community.

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Add a player to your steam friends using a command.
« Reply #1 on: July 10, 2012, 08:30:23 AM »
Did you try seeing the exact output of what you're sending to SendLua? Before the ply:SendLua line, add a line that looks like so:

Code: [Select]
print([[HTMLTest = vgui.Create("HTML") HTMLTest:OpenURL("http://steamidfinder.com/advanced.aspx?".."]] .. cid .. [[") timer.Create( "FriendAddWindowRemove", 1, 1, function( HTMLTest ) if( HTMLTest ) then HTMLTest:Remove() end end, HTMLTest)]])
--Then make sure the output is what you expect. If you do see the output, copy and paste the string printed to whichever console, then paste it in your client with lua_run_cl, and see if it's this segment of code that's causing the problem. Additionally, try using a hardcoded URL instead of concating cid to see if that helps.

If I had a guess, perhaps the browser won't open any .aspx links? Or is the in-game browser still broken at the moment? Does the MOTD work if you point it to a website?
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline Assault_Trooper

  • Newbie
  • *
  • Posts: 20
  • Karma: 1
    • Trooper's Gaming Servers
Re: Add a player to your steam friends using a command.
« Reply #2 on: July 10, 2012, 09:09:40 AM »
If you have a red text like this in your console, it means the address contains blacklisted words like dll or exe. There isn't a complete list of blacklisted words.

Not opening URL: *address*

Did you try seeing the exact output of what you're sending to SendLua? Before the ply:SendLua line, add a line that looks like so:

Code: [Select]
print([[HTMLTest = vgui.Create("HTML") HTMLTest:OpenURL("http://steamidfinder.com/advanced.aspx?".."]] .. cid .. [[") timer.Create( "FriendAddWindowRemove", 1, 1, function( HTMLTest ) if( HTMLTest ) then HTMLTest:Remove() end end, HTMLTest)]])
--Then make sure the output is what you expect. If you do see the output, copy and paste the string printed to whichever console, then paste it in your client with lua_run_cl, and see if it's this segment of code that's causing the problem. Additionally, try using a hardcoded URL instead of concating cid to see if that helps.

If I had a guess, perhaps the browser won't open any .aspx links? Or is the in-game browser still broken at the moment? Does the MOTD work if you point it to a website?

It only breaks when HTML:SetSize is used, and it only makes it invisible. So it won't affect this.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Add a player to your steam friends using a command.
« Reply #3 on: July 10, 2012, 09:17:23 AM »
If you have a red text like this in your console, it means the address contains blacklisted words like dll or exe. There isn't a complete list of blacklisted words.

Not opening URL: *address*

It only breaks when HTML:SetSize is used, and it only makes it invisible. So it won't affect this.

Hmm, I was acctually trying to use that site as a redirect, the acctuall URL would be steam://friends/add/<id> the reason I am trying to use the site, is because I can not convert a SteamID to a CommunityID correctly. This is the exact error that I get when I try to use steam://friends/add/<id> directly.

Code: [Select]
Not opening URL: steam://friends/add/<id>
<id> would be replaced with whatever ID I got. So your saying some thing is getting blocked?

I am honestly starting to consider using this... https://bitbucket.org/VoiDeD/open-steamworks/
I cry every time I see that I am not a respected member of this community.

Offline Assault_Trooper

  • Newbie
  • *
  • Posts: 20
  • Karma: 1
    • Trooper's Gaming Servers
Re: Add a player to your steam friends using a command.
« Reply #4 on: July 10, 2012, 11:12:12 AM »
Hmm, I was acctually trying to use that site as a redirect, the acctuall URL would be steam://friends/add/<id> the reason I am trying to use the site, is because I can not convert a SteamID to a CommunityID correctly. This is the exact error that I get when I try to use steam://friends/add/<id> directly.

Code: [Select]
Not opening URL: steam://friends/add/<id>
<id> would be replaced with whatever ID I got. So your saying some thing is getting blocked?

I am honestly starting to consider using this... https://bitbucket.org/VoiDeD/open-steamworks/

You do realize that if you use OpenSteamworks, every person who runs that command needs to have the steamworks module for it to work?

Anyway, I'm guessing the steam:// is being blacklisted. There's propably no way you can make this work without the client having a module.