Ulysses
General => Developers Corner => Topic started 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 :(
-- 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." )
-
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.
-
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.
-
The command has already been made, and is included in...
http://forums.ulyssesmod.net/index.php/topic,5427.0.html
-
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)
-
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.
-
Not to my knowledge. Messed up your screen name (boy instead of fox). Now corrected.
-
ok this
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.
-
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.
-
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!
-
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.