concommand lua error (ULX Rocket)

[Lua]I am trying to use a ULX Rocket script that I found on the Ulysses forums (seen below):

function ulx.cc_rocket( ply, command, argv, args )
if #argv < 1 then
ULib.tsay( ply, ulx.LOW_ARGS )
return
end

local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords
if not targets then
	ULib.tsay( ply, err )
	return
end

for _, v in ipairs( targets ) do
	if not v:Alive() then
		ULib.tsay( ply, v:Nick() .. " is dead!", true )
		return
	end
	if v.jail then
		ULib.tsay( ply, v:Nick() .. " is in jail", true )
		return
	end
	if v.ragdoll then
		ULib.tsay( ply, v:Nick() .. " is a ragdoll", true )
		return
	end	

	if v:InVehicle() then
		local vehicle = v:GetParent()
		v:ExitVehicle()
	end
	ulx.logUserAct( ply, v, "#A rocketed #T " )
	v:SetMoveType(MOVETYPE_WALK)
	tcolor = team.GetColor( v:Team()  )
	local trail = util.SpriteTrail(v, 0, Color(tcolor.r,tcolor.g,tcolor.b), false, 60, 20, 4, 1/(60+20)*0.5, "trails/smoke.vmt")  				
	v:SetVelocity(Vector(0, 0, 2048))
	timer.Simple(2.5, function()
		local Position = v:GetPos()		
		local Effect = EffectData()
		Effect:SetOrigin(Position)
		Effect:SetStart(Position)
		Effect:SetMagnitude(512)
		Effect:SetScale(128)
		util.Effect("Explosion", Effect)
		timer.Simple(0.1, function()
			v:Kill() 
			trail:Remove()
		end)
	end)
end

end
ulx.concommand( “rocket”, ulx.cc_rocket, “<user(s)> - rockets a user”, ULib.ACCESS_ADMIN, “!rocket”, _, ulx.ID_PLAYER_HELP )
ulx.addToMenu( ulx.ID_MCLIENT, “rocket”, “ulx rocket” )[/lua]

The lua error that I am getting from this is as follows:

ULX] Loading SHARED module: rocket.lua

[ERROR] addons/ulx/lua/ulx/modules/sh/rocket.lua:51: attempt to call field ‘concommand’ (a nil value)

  1. unknown - addons/ulx/lua/ulx/modules/sh/rocket.lua:51
  2. include - [C]:-1
    3. unknown - addons/ulx/lua/ulx/cl_init.lua:17
    4. include - [C]:-1
    5. unknown - addons/ulx/lua/ulib/modules/ulx_init.lua:4
    6. include - [C]:-1
    7. unknown - addons/ulib/lua/ulib/cl_init.lua:23
    8. include - [C]:-1
    9. unknown - addons/ulib/lua/autorun/ulib_init.lua:5

I’ve no idea how to fix this so I was wondering if one of the kind citizens of Facepunch could assist me :slight_smile: Thanks!

Change the bottom two lines (ulx.concommand and ulx.addToMenu) to this:

[lua]
local rocket = ulx.command(“Fun”, “ulx rocket”, ulx.cc_rocket, “!rocket” )
rocket:addParam{ type=ULib.cmds.PlayersArg }
rocket:defaultAccess(ULib.ACCESS_ADMIN)
rocket:help(“Rockets a user.”)
[/lua]

Fixed the Lua error but now the command doesn’t function at all. Its in the menu but it doesn’t seem to work

This should do it:

[lua]
function ulx.cc_rocket( calling_ply, target_plys )
local affected_plys = {}

for i=1, #target_plys do
	local v = target_plys[ i ]

	if not v:Alive() then
		ULib.tsayError( calling_ply, v:Nick() .. " is dead!", true )
	elseif v.jail then
		ULib.tsayError( calling_ply, v:Nick() .. " is in jail", true )
	elseif v.ragdoll then
		ULib.tsayError( calling_ply, v:Nick() .. " is a ragdoll", true )
	end	

	if v:InVehicle() then v:ExitVehicle() end
	v:SetMoveType(MOVETYPE_WALK)
	tcolor = team.GetColor( v:Team() )
	local trail = util.SpriteTrail(v, 0, Color(tcolor.r, tcolor.g, tcolor.b), false, 60, 20, 4, 1/(60+20)*0.5, "trails/smoke.vmt")  				
	v:SetVelocity(Vector(0, 0, 2048))
	timer.Simple(2.5, function()
		local Position = v:GetPos()		
		local Effect = EffectData()
		Effect:SetOrigin(Position)
		Effect:SetStart(Position)
		Effect:SetMagnitude(512)
		Effect:SetScale(128)
		util.Effect("Explosion", Effect)
		timer.Simple(0.1, function()
			v:Kill() 
			trail:Remove()
		end)
	end)
	table.insert( affected_plys, v )
end
ulx.fancyLogAdmin( calling_ply, "#A rocketed #T", affected_plys )

end
local rocket = ulx.command(“Fun”, “ulx rocket”, ulx.cc_rocket, “!rocket” )
rocket:addParam{ type=ULib.cmds.PlayersArg }
rocket:defaultAccess( ULib.ACCESS_ADMIN )
rocket:help( “Rockets a user.” )
[/lua]

Basically, everything was written for the old ULX command system which has since changed.

I’ll test this out, thanks :slight_smile: