Ulysses

General => Developers Corner => Topic started by: strategos on December 27, 2011, 02:48:24 AM

Title: ULX Clear Decals Command
Post by: strategos on December 27, 2011, 02:48:24 AM
I am trying to make a command that clears decals and also shows up as $user has ran the command in chat. However, it doesn't work and there are no errors in console :(

Code: [Select]
-- ULX Cleanup by Strategos

local function ClearDecals(ply, cmd, args)

for k,v in pairs(player.GetAll()) do
v:ConCommand("r_cleardecals")
end

ulx.fancyLogAdmin( ply, true, "#A has cleared all the decals" )

end

local ClearDecals = ulx.command( "Utility", "Clear Decals", ClearDecals, "!clear" )
ClearDecals:defaultAccess( ULib.ACCESS_ADMIN )
ClearDecals:help( "Clears Decals." )
Title: Re: ULX Clear Decals Command
Post by: JackYack13 on December 27, 2011, 02:30:01 PM
Code: [Select]
local function ClearDecals(ply)
  for k, v in pairs(player.GetAll()) do
    v:ConCommand("r_cleardecals")
  end
  ulx.fancyLogAdmin(ply, "#A has cleared all the decals.")
end
local cmd_ClearDecals= ulx.command("Utility", "clear decals", ClearDecals, "!clear")
cmd_ClearDecals:defaultAccess(ULib.ACCESS_ADMIN)
cmd_ClearDecals:help("Clears decals.")

This should work.

Your function and variable containing the command info had the same name. Also, you had some unneeded arguments in the function.
Title: Re: ULX Clear Decals Command
Post by: Aaron113 on December 27, 2011, 02:56:54 PM
If it still doesn't work, try taking the local out ("local function" to "function").  If it still doesn't work, try renaming the function to "ulx.cleardecals".  I'm not sure if they matter, but just some tips if it doesn't.
Title: Re: ULX Clear Decals Command
Post by: LuaTenshi on December 27, 2011, 09:39:09 PM
The command has already been made, and is included in...

http://forums.ulyssesmod.net/index.php/topic,5427.0.html
Title: Re: ULX Clear Decals Command
Post by: JamminR on December 29, 2011, 07:17:11 AM
Re: It being included in UPS Menu - but don't let that stop anyone from experimenting/learning how to do it through the Glua and the ULX command structure of this discussion.
Though Hellfox's release is great and allows for addition to UPS settings, and includes a few bonus features such as the cleardecal function...sometimes, something as simple as this one command may be all you want, without the addition of UPS and Hellfox's UPS Menu. (You may use another prop protector..your choice (but why would you not use the best?! :P)
Title: Re: ULX Clear Decals Command
Post by: LuaTenshi on December 29, 2011, 12:48:22 PM
Re: It being included in UPS Menu - but don't let that stop anyone from experimenting/learning how to do it through the Glua and the ULX command structure of this discussion.
Though Hellboy's release is great and allows for addition to UPS settings, and includes a few bonus features such as the cleardecal function...sometimes, something as simple as this one command may be all you want, without the addition of UPS and Hellboy's UPS Menu. (You may use another prop protector..your choice (but why would you not use the best?! :P)

Sorry, that I made it seem like I was trying to stop people.

I was just saying that there is an existing script for people to improve on, and or learn from.

Also there is another UPS menu?

----

The above script looks like it should work, I wounder if there is a different way of doing it rather then running a console command on every one.
Title: Re: ULX Clear Decals Command
Post by: JamminR on December 29, 2011, 01:21:03 PM
Not to my knowledge. Messed up your screen name (boy instead of fox). Now corrected.
Title: Re: ULX Clear Decals Command
Post by: strategos on January 04, 2012, 02:31:35 PM
ok this

Code: [Select]
local function ClearDecals(ply)
  for k, v in pairs(player.GetAll()) do
    v:ConCommand("r_cleardecals")
  end
  ulx.fancyLogAdmin(ply, "#A has cleared all the decals.")
end
local cmd_ClearDecals= ulx.command("Utility", "clear decals", ClearDecals, "!clear")
cmd_ClearDecals:defaultAccess(ULib.ACCESS_ADMIN)
cmd_ClearDecals:help("Clears decals.")

returns this in console when I try to use it.

[ulx\xgui\commands.lua:259] RunConsoleCommand: Command is blocked! (clear)

Also, you cant configure which usergroups can use it like I can with the Sban module.
Title: Re: ULX Clear Decals Command
Post by: Assault_Trooper on January 05, 2012, 05:39:18 AM
Code: [Select]
function ulx.cleardecals( ply )

for k,v in pairs ( player.GetAll() ) do

v:ConCommand( "r_cleardecals" )
v:SendLua( "game.RemoveRagdolls()" )

end

ulx.fancyLogAdmin( ply, "#A cleared all decals" )

end

local cleardecals = ulx.command( "Trooper's Additions", "ulx cleardecals", ulx.cleardecals, "!cleardecals" )
cleardecals:defaultAccess( ULib.ACCESS_ADMIN )
cleardecals:help( "Clears all decals, and removes client ragdolls." )

This is what I use, it removes the dead NPC's too. And it works definently, been using it for ages.
Title: Re: ULX Clear Decals Command
Post by: strategos on January 06, 2012, 11:57:18 AM
Code: [Select]
function ulx.cleardecals( ply )

for k,v in pairs ( player.GetAll() ) do

v:ConCommand( "r_cleardecals" )
v:SendLua( "game.RemoveRagdolls()" )

end

ulx.fancyLogAdmin( ply, "#A cleared all decals" )

end

local cleardecals = ulx.command( "Trooper's Additions", "ulx cleardecals", ulx.cleardecals, "!cleardecals" )
cleardecals:defaultAccess( ULib.ACCESS_ADMIN )
cleardecals:help( "Clears all decals, and removes client ragdolls." )

This is what I use, it removes the dead NPC's too. And it works definently, been using it for ages.

I bestow 1000 blessings upon you. Thanks!
Title: Re: ULX Clear Decals Command
Post by: JamminR on January 06, 2012, 04:05:28 PM
Ah, looking at the comparisons, I see now why one would and one not work.
The command setup in non-working, "clear decals", gets spit back by Gmod.