Ulysses
General => Developers Corner => Topic started by: kaos2100 on October 13, 2012, 08:15:54 PM
-
How would I make a command "!stopsounds" in chat for example to make it so the clients can run "stopsounds" in their console?
Thank you.
-
function ulx.stopsounds( calling_ply )
for _, pl in ipairs( player.GetAll() ) do pl:ConCommand("stopsounds") end
end
local stopsounds = ulx.command( CATEGORY_NAME, "ulx stopsounds", ulx.stopsounds, "!stopsounds", true )
stopsounds:defaultAccess( ULib.ACCESS_ADMIN )
stopsounds:help( "Stops all sounds." )
If you also want it to log then add
ulx.fancyLogAdmin( calling_ply, "#A used stop sounds" )
Also I'm not sure if ConCommand would allow stopsounds to be run, but you could always try it.
-
Snipe, i wonder if he wants default level set that high (admin).
-
@kaos2100 Are you trying to make a command that makes admins run stopsounds on everyone, or are you trying to make a command that makes it run stopsounds on whoever called it?
If you want the second option, then use this.
function ulx.stopsounds( calling_ply )
calling_ply:ConCommand("stopsounds")
ULib.tsayColor( calling_ply, false, Color( 255, 0, 0 ), "Stopped all sounds." )
end
local stopsounds = ulx.command( CATEGORY_NAME, "ulx stopsounds", ulx.stopsounds, "!stopsounds", true )
stopsounds:defaultAccess( ULib.ACCESS_ALL )
stopsounds:help( "Stops all sounds." )
-
Thanks but I'm getting
FCVAR_SERVER_CAN_EXECUTE prevented server running command: stopsounds
-
I actually fixed it by doing the SendLua command. Thanks though!
Here it is if anyone wants to use it
calling_ply:SendLua("LocalPlayer():ConCommand('stopsounds')")
-
Garry's blocks on remote execution are so silly. :P
-
Kaos, I renamed your topic post. In future, at forums where you are asking for help, I'd suggest not just saying "I need help".
Most here already want/need help. Make it a title about 'what kind' of help you're needing. :)
If interested in writing more of your own ULX commands (or, using ULib), check out our ULib documentation
http://ulyssesmod.net/docs/files/lua/ulib/shared/commands-lua.html
And, specifically regarding ULX commands, chat and/or console, see halfway through my long comparison post.. it's closest we have to 'how to make commands'... has a well-commented example command.
http://forums.ulyssesmod.net/index.php/topic,4464.msg17838.html#msg17838 (find "So, on to the new New command structure...")
-
Garry's blocks on remote execution are so silly. :P
Ya, I hate that. I remember back in Gmod 10 when I was able to change people's Steam name, make them connect to another server or quit their game >:D lol.