Making a ULX command to open a player's profile, encountering some issues with defining variables fo
2 replies, posted
Ok so I have this
[LUA]function ulx.profile( calling_ply, target_plys )
local affected_plys = {}
for i=1, #target_plys do
for _, v in ipairs( target_plys ) do
local comID = v:SteamID64()
end
calling_ply:gui.OpenURL(string.format("http://steamcommunity.com/profiles/%s", comID))
end
ulx.fancyLogAdmin( calling_ply, "#A opened #T's profile ", affected_plys )
end
local profile = ulx.command( CATEGORY_NAME, "ulx profile", ulx.profile, "!profile" )
profile:addParam{ type=ULib.cmds.PlayersArg }
profile:defaultAccess( ULib.ACCESS_ALL )
profile:help( "Opens target's profile" ) [/LUA]
It opens http:steamcommunity.com/profiles/nil because it returns comID as a nil value. This seems to be because its not defined for the client. How can I get my variable to be usable for the client and still update to the targeted player's id when I use the command?
You'd only want it targeting one player.
Try this.
[code]
function ulx.profile( calling_ply, target_ply )
calling_ply:SendLua("gui.OpenURL('http://steamcommunity.com/profiles/".target_ply:SteamID64()."')")
ulx.fancyLogAdmin( calling_ply, "#A opened the profile of #T", target_ply )
end
local profile = ulx.command( CATEGORY_NAME, "ulx profile", ulx.profile, "!profile" )
profile:addParam{ type=ULib.cmds.PlayerArg }
profile:defaultAccess( ULib.ACCESS_ALL )
profile:help( "Opens target's profile" )
[/code]
Also I would suggest removing the log, it's pointless and will just get spammed.
I'll be honest, I wasn't expecting that to work but I just changed it to [lua]calling_ply:SendLua("gui.OpenURL('http://steamcommunity.com/profiles/".. target_ply:SteamID64() .."')")[/lua] and it worked perfect. Thanks a ton!
Sorry, you need to Log In to post a reply to this thread.