Issue with "SendLUA" and "gui.OpenURL"

So I’m having issues with my script(module/addon for ULX) that’s bugging me.

It’s so that I can use a ULX command to lookup info on a player. I added the tsayError code as a sort of “debugger” because it wasn’t helping. There’s another version that uses raw input, but I’m only including this one(both don’t work).

First issue, it only gets to “Got here”. Which means there’s an issue with getting the SteamID, wrong function? idk.
It also won’t get past the SendLua command, I don’t know what’s wrong with it, I’ve tried so many variations.

Keep in mind the other version uses a variable not ply:SteamID(), it breaks either way. Like if I did steamid = “steamid” and then tried to use the SendLua command.

Mind helping me out?


function ulx.blank( calling_ply, ply )

		ULib.tsayError( calling_ply, "Got here" )
		ULib.tsayError( calling_ply, "Test: " .. ply:SteamID() )
		calling_ply:SendLua("gui.OpenURL(\"http://blank.com?steamid=" .. ply:SteamID() "\")")
		ULib.tsayError( calling_ply, "And got here" )
    
end
local blank = ulx.command( CATEGORY_NAME, "ulx blank", ulx.blank, "!blank" )
blank:addParam{ type=ULib.cmds.PlayersArg }
blank:defaultAccess( ULib.ACCESS_ADMIN )
blank:help( "Starts adding a record on the user." )

I thought this was a forum for helping people. Could I please get a reply?

i believe the second argument returns a table of players in the case of ULX

This is a forum to help people, put people don’t systematically have the answer for your question.

[lua]
calling_ply:SendLua([[gui.OpenURL(“http://blank.com/?steamid=” … ply:SteamID())]])
[/lua]

I get in issue with the SteamID() part I’m trying to solve.
attempt to call method ‘SteamID’ (a nil value)

Also, if I do
steamid = “STEAM_0:0:00000000” (with a real SteamID of course)

And then call it like that I get:


[User|2|STEAM_0:0:00000000] Lua Error:

[ERROR] LuaCmd:1: attempt to concatenate global 'steamid' (a nil value)
  1. unknown - LuaCmd:1



Which I’m assuming must be an issue with SendLua not having the global value “steamid”.

When you use SendLua its like the client is using lua_run_cl. I’m not sure if the player object gets sent over to the client but I doubt it. Try getting the players steamid serverside, before you use sendlua, then send the openurl over.



local playerSteamid = ply:SteamID()
calling_ply:SendLua("gui.OpenURL(\"http://blank.com?steamid=" .. playerSteamid "\")")


That worked! I was trying a similar version by sending the value clientside first then calling it. But that worked like a charm(once I added another … after playerSteamid which you forgot xD).

Now I gotta figure out what’s wrong with FancyLogAdmin Dx
And then the ply:SteamID() part.

For that one I adapted it to a command that takes plaintext and not a playerarg…

Here’s the code that is still being buggy:


-- Add Offense
function ulx.addoffense( calling_ply, ply )

	local usersteamid = ply:SteamID()
	calling_ply:SendLua("gui.OpenURL(\"http://blank.com/addoffense.php?autofillsteamid=" .. usersteamid .. "\")")
	ULib.tsayError( calling_ply, "And got here" )
	ulx.fancyLogAdmin( calling_ply, should_silent, "#A has started adding a record on #T", ply )
    
end
local addoffense = ulx.command( CATEGORY_NAME, "ulx addoffense", ulx.addoffense, "!addoffense" )
addoffense:addParam{ type=ULib.cmds.PlayersArg }
addoffense:defaultAccess( ULib.ACCESS_ADMIN )
addoffense:help( "Starts adding a record on the user." )

I decided to stop censoring stuff. I’m making a system for a TTT server I’m a staff on to help log user offenses so it’s not just based on memory xD. The PHP portion of the system was a breeze but I’m new to Lua.

ply is not defined.

I switched it temporarily from ply to player in the function.
Edited with a change.

Edit:
As simple as changing PlayersArg to PlayerArg. I’m glad I’m looking in the ULX files for help xD.

Now to find out what the heck is wrong with the logs Q_Q



[ERROR] addons/ulx/lua/ulx/log.lua:440: attempt to index local 'format' (a nil value)
  1. fancyLogAdmin - addons/ulx/lua/ulx/log.lua:440
   2. call - addons/ztttlogs/lua/ulx/modules/sh/ztttlogs.lua:39
    3. __fn - addons/ulib/lua/ulib/shared/commands.lua:943
     4. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
      5. unknown - lua/includes/modules/concommand.lua:69

If you’re making offences, why not have a MySQL module and have derma (dpanel, dtextinput, dlistview) to add and show it instead of opening a web page?

Flexibility I guess?

Originally I hadn’t planned on commands. Plus you have to be logged in and using the steam browser is easier.

I just jumped right into programming for Garry’s Mod. I’m amazing I’ve churned out what I have.

I’d imagine that for what you want (user logging for warnings basically) it would be easier on your administration team if it didn’t have to open the steam browser to either look at the info or add it. You can always make it so only admins place warnings by using ply:IsAdmin().

I have a system I’ve been working on that does almost the same thing, but it’s an entire admin module. It logs any action (warn, kick, ban) against the user into MySQL via tMySQL4 and then uses the net library to retrieve the info when an admin requests it. This also allows the player to view their own info, and since its on MySQL instead of sqlite it allows for everything to be linked on PHP as well for out of game viewing.

Interesting…
I was messing around with the mysqloo for a while but…
Being new to Lua I don’t understand this “clientside” “serverside” and “shared” thing, at all. So I’ve given up xD.

Right now I’m planning on going with an API on the PHP side and http.get to grab the information and parse it.

The only problem is the security holes it opens, but there are workarounds that make for more hindrances xD.