RunConsoleCommand with only 1 parameter?

So basically I’m trying to run this console command through lua code: “ulx adduser username member”. The username must be inside quotes in the command.
I found that I should use “RunConsoleCommand”. I also noticed that it requires two parameters, the command and the value. I have no idea how it could work with the command I want to run, so I tried creating something like this:

RunConsoleCommand("ulx adduser " .. '"' .. ply:GetName() .. '"', "member")

However I get an error saying

RunConsoleCommand: Command has invalid characters! (ulx adduser "JohnnyKing" (' '))
The first parameter of this function should contain only the command, the second parameter should contain arguments.

Any help would be appreciated!

It would look like this
[lua]RunConsoleCommand(“ulx”, “adduser”, ‘"’…ply:GetName()…’"’, “member”)[/lua]

Parameters are separated by commas

The RunConsoleCommand takes 2 parameters only. It is supposed to run the following command exactly as typed here:

ulx adduser “playername” member

The 2 parameters of RunConsoleCommand are the command itself and the value, usually 0 or 1, however this command doesn’t require any value.

Do you even know what the heck you’re talking about?

What I’m talking about is that RunConsoleCommand requires 2 parameters, and he gave me a code that has 4.

Have you actually tested his code? Sure, print takes 1 parameter, doesn’t stop you from unpacking an entire table into it.

The first argument is the command. All that come after it are the arguments for said command. It can take more than one argument, or no arguments at all.



Well, his code didn’t work. The error I get is
Command “ulx adduser”, argument #1: No target found or target has immunity!

Also I am 100% sure that ply:GetName() gave the correct name and that the command itself works.

Try using a SteamID.

local name, rank = ply:Name(), “superadmin”
RunConsoleCommand(“ulx”, "adduser “… name …” "… rank)

Are you sure that I don’t need to add the quotes around the player’s name? So that the console command can recognize the whole arg if it’s got spaces?

That’s true. Just throw some “”" in there.

[lua]RunConsoleCommand(“ulx”, “adduser”, ply:GetName(), “member” )[/lua]

The quotes aren’t needed, with them, instead of adding HumbleTH, it would try to add "HumbleTH " and no such player would have that name, so that’s where the store’s from.

They are needed if you have spaces in your name… Hence why quotes were used in the first place


ULib.ucl.addUser(ply:SteamID(), nil, nil, "member")

local ID = ply:SteamID()


Dude not needing that is the entire point of the function taking one arg for each concommand arg

Works like a charm, a million thanks to you!
Didn’t even have time to test all of the replies, big thanks to everyone who replied!