Ulysses

General => Developers Corner => Topic started by: kaos2100 on October 13, 2012, 08:15:54 PM

Title: How do I create stopsound chat command?
Post 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.
Title: Re: Could someone help me please?
Post by: iSnipeu on October 13, 2012, 09:06:07 PM
Code: [Select]
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.
Title: Re: Could someone help me please?
Post by: JamminR on October 13, 2012, 09:16:36 PM
Snipe, i wonder if he wants default level set that high (admin).
Title: Re: Could someone help me please?
Post by: iSnipeu on October 13, 2012, 10:47:02 PM
@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.

Code: [Select]
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." )
Title: Re: Could someone help me please?
Post by: kaos2100 on October 14, 2012, 12:59:55 AM
Thanks but I'm getting

FCVAR_SERVER_CAN_EXECUTE prevented server running command: stopsounds
Title: Re: Could someone help me please?
Post by: kaos2100 on October 14, 2012, 01:17:32 AM
I actually fixed it by doing the SendLua command. Thanks though!

Here it is if anyone wants to use it

Code: [Select]
calling_ply:SendLua("LocalPlayer():ConCommand('stopsounds')")
Title: Re: Could someone help me please?
Post by: Megiddo on October 14, 2012, 05:11:57 AM
Garry's blocks on remote execution are so silly. :P
Title: Re: How do I create stopsound chat command?
Post by: JamminR on October 14, 2012, 07:38:24 AM
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...")
Title: Re: Could someone help me please?
Post by: MulleDK13 on October 24, 2012, 03:58:18 PM
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.