ULX Command running an ULX Command

Hey there,
I would like to create an ULX command that runs 2 other ulx commands on a specified player.
Can i use runConsoleCommand for that or is there a different way to handle commands with ulx?
Thanks in advance to anyone replying.

what are the two ulx commands you want to use?
in my opinion it’s best to just emulate the same code, not use RunConsoleCommand.
Using RunConsoleCommand will print that the console has done those two things to that person which will be an eyesore in your chatbox.
If you tell me which commands you want to use I’ll post the code for you, or you can go to the source code for those commands and copy that instead (Without the fancyLogAdmin() )

Okay so i got these two commands i want to use:
ulx tempadduser <player> <group> <time(minutes)> <group>

and the other one being:
!givepoints <target> <amount>

I would need 3 different versions of this with different times and point amounts. You could just create 3 templates and i can edit the times. The commands for these should be:
!paket 1 <target>
!paket 2 <target>
!paket 3 <target>
Thanks for your help dude!

I don’t…
Are the 2 commands already existing?

Yes they are ulx addons.
Both can be found here:
Temporary Users
Pointshop Commands
Sorry for not providing them. I went full retard mode.

Can nobody help anymore?

use game.ConsoleCommand
its not too hard if you know lua.
just use this to go off of and make it do what you want
btw, the
at the end of game.ConsoleCommand is mandatory, so don’t remove it


function ulx.morecommands( calling_ply, target_ply )

	game.ConsoleCommand("ulx tempadduser "..target_ply:Nick().." rank time rank
")
	
end
local morecommands = ulx.command( "Chat", "ulx mc", ulx.morecommands, "!mc" )
morecommands:defaultAccess( ULib.ACCESS_ADMIN )
morecommands:help( "blahlbalhbalhg." )

  • snip - Im an idiot

I tried it now, doesnt seem to work…
This is what i got:


local CATEGORY_NAME = "Extra Commands"
--- Paket 1 ----------------------------------------------------------------------------------------------
function ulx.paket1( calling_ply, target_ply )

	game.ConsoleCommand("ulx tempadduser "..target_ply:Nick().." donator 44640 user
")
	game.ConsoleCommand("ulx givepoints "..target_ply:Nick().." 50000")	
	
end
local paket1 = ulx.command( CATEGORY_NAME, "ulx paket1", ulx.paket1, "!paket 1" )
paket1:defaultAccess( ULib.ACCESS_ADMIN )
paket1:help( "Gibt dem Spieler das Donation Paket Nummer 2" )

--- Paket 2 ----------------------------------------------------------------------------------------------
function ulx.paket2( calling_ply, target_ply )

	game.ConsoleCommand("ulx tempadduser "..target_ply:Nick().." donator 89280 user
")
	game.ConsoleCommand("ulx givepoints "..target_ply:Nick().." 100000")	
	
end
local paket2 = ulx.command( CATEGORY_NAME, "ulx paket2", ulx.paket2, "!paket 2" )
paket2:defaultAccess( ULib.ACCESS_ADMIN )
paket2:help( "Gibt dem Spieler das Donation Paket Nummer 2" )

--- Paket 3 ----------------------------------------------------------------------------------------------
function ulx.paket3( calling_ply, target_ply )

	game.ConsoleCommand("ulx tempadduser "..target_ply:Nick().." donator 178560 user
")
	game.ConsoleCommand("ulx givepoints "..target_ply:Nick().." 175000")	
	
end
local paket3 = ulx.command( CATEGORY_NAME, "ulx paket2", ulx.paket3, "!paket 3" )
paket3:defaultAccess( ULib.ACCESS_ADMIN )
paket3:help( "Gibt dem Spieler das Donation Paket Nummer 3" )

Why even use game.ConsoleCommand?
RunConsoleCommand is just more comfortable…

If functions isn’t localized in this ULX modules, I think you can call functions itself, not emulate running console commands.

You are using this command to give VIP out correct?

Correct, and pointshop points.

[editline]5th March 2016[/editline]

The People over at the Ulysses forums said, this was a smarter way.

Still not working. RunConsoleCommand doesnt work either :frowning:

Are you using last version of ULX? I think that tempadd is already in ULX.

its not working because you are forgetting the
before the end quote of game.ConsoleCommand
Example: game.ConsoleCommand("command here
")
there must be the
before the last quotation mark before you end game.ConsoleCommand.
Anyways, Heres the code you previously stated, except i added the



local CATEGORY_NAME = "Extra Commands"
--- Paket 1 ----------------------------------------------------------------------------------------------
function ulx.paket1( calling_ply, target_ply )

	game.ConsoleCommand("ulx tempadduser "..target_ply:Nick().." donator 44640 user
")
	game.ConsoleCommand("ulx givepoints "..target_ply:Nick().." 50000
")	--THE 
 IS CRITICAL
	
end
local paket1 = ulx.command( CATEGORY_NAME, "ulx paket1", ulx.paket1, "!paket 1" )
paket1:defaultAccess( ULib.ACCESS_ADMIN )
paket1:help( "Gibt dem Spieler das Donation Paket Nummer 2" )

--- Paket 2 ----------------------------------------------------------------------------------------------
function ulx.paket2( calling_ply, target_ply )

	game.ConsoleCommand("ulx tempadduser "..target_ply:Nick().." donator 89280 user
")
	game.ConsoleCommand("ulx givepoints "..target_ply:Nick().." 100000
")	
	
end
local paket2 = ulx.command( CATEGORY_NAME, "ulx paket2", ulx.paket2, "!paket 2" )
paket2:defaultAccess( ULib.ACCESS_ADMIN )
paket2:help( "Gibt dem Spieler das Donation Paket Nummer 2" )

--- Paket 3 ----------------------------------------------------------------------------------------------
function ulx.paket3( calling_ply, target_ply )

	game.ConsoleCommand("ulx tempadduser "..target_ply:Nick().." donator 178560 user
")
	game.ConsoleCommand("ulx givepoints "..target_ply:Nick().." 175000
")	
	
end
local paket3 = ulx.command( CATEGORY_NAME, "ulx paket2", ulx.paket3, "!paket 3" )
paket3:defaultAccess( ULib.ACCESS_ADMIN )
paket3:help( "Gibt dem Spieler das Donation Paket Nummer 3" )


Gonna try it later, thanks!

I told you over on the ULX forums to use RunConsoleCommand. RunConsoleCommand is a higher level function and will take care of things like newlines. Use it.

Better yet why not call the function directly?



ulx.tempadduser(ents.FindByClass("worldspawn")[1], target_ply, "donator", 44640, "user")
ulx.givepoints(ents.FindByClass("worldspawn")[1], target_ply, 50000)


ents.FindByClass(“worldspawn”)[1] is the default admin by the way.

I agree, except for some that may be a bit more advanced.
The best way to go about which functions to use all comes down to whatever you are comfortable using… as long as it works.
It doesn’t really matter if you choose game.ConsoleCommand over RunConsoleCommand, just use the one you are comfortable with.
In the long run, you are better off using the function with more capabilities because when the time comes, you won’t run into as many errors.