Help with ULX Command

I’m trying to make a ULX command that takes a target player and a string as inputs, then forces the player to open the webpage, which the string would be. For example, !openwebpage rooday google.com should target me, then append google.com to the http:// and then force the player to open it. This is what I have so far, but it does not work.



function ulx.openwebpage ( calling_ply, target_ply, web_page )
if not GetConVarString("gamemode") == "terrortown" then ULib.tsayError( calling_ply, gamemode_error, true ) else
			
		target_player:SendLua([[gui.OpenURL("http://" .. web_page)]])
			
		ulx.fancyLogAdmin( calling_ply, "#A made #T open webpage: http://#i", target_ply, web_page )
	end
end
local openwebpage = ulx.command( CATEGORY_NAME, "ulx openwebpage", ulx.openwebpage )
openwebpage:addParam{ type=ULib.cmds.PlayersArg}
openwebpage:addParam{ type=ULib.cmds.StringArg, hint="http://"}
openwebpage:defaultAccess( ULib.ACCESS_SUPERADMIN )
openwebpage:help( "Forces the selected player to open the specified webpage.." )


Can anyone help?

#i” will be replaced with an integer, you are attempting to replace it with a string; use “#s”.
You’re using different arguments than are passed in the function. Use “target_ply:SendLua” not “target_player:SendLua”.

Seriously, copy/pasting code won’t do you any favours.

i didn’t copy paste, I was just really stupid when i made that lol. thanks for help, ill try it

[editline]15th March 2014[/editline]

Still didn’t work. I currently have this:



function ulx.openwebpage ( calling_ply, target_plys, web_page )
	for i=1, #target_plys do
		target_plys:SendLua([[gui.OpenURL(web_page)]])
	end	
	ulx.fancyLogAdmin( calling_ply, "#A made #T open webpage: #s", target_ply, web_page )
end
local openwebpage = ulx.command( CATEGORY_NAME, "ulx openwebpage", ulx.openwebpage, "!owp" )
openwebpage:addParam{ type=ULib.cmds.PlayersArg}
openwebpage:addParam{ type=ULib.cmds.StringArg, hint="http://", ULib.cmds.round}
openwebpage:defaultAccess( ULib.ACCESS_ADMIN )
openwebpage:help( "Forces the selected player to open the specified webpage." )


It still does not work. It shows up in the ulx menu, and it allows selection of players and input, but nothing happens, no logs or stuff either. I removed the gamemode check and instead set it up like how hp is done.

hello?

I’d recommend looking into net-messages instead of SendLua.

Here’s an example sending 1 bit / booleans: https://dl.dropboxusercontent.com/u/26074909/tutoring/networking/networking_booleans.lua

You’d essentially just need to update it to WriteString, and ReadString - you don’t need the second one. WriteString the URL, ReadString and do the code on the player there.

when you do net.Send( ) make sure you net.Send( ply ); to the player. Remove Broadcast, etc.

okeedokee will try!