Author Topic: How do I create stopsound chat command?  (Read 5136 times)

0 Members and 3 Guests are viewing this topic.

Offline kaos2100

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
How do I create stopsound chat command?
« 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.
« Last Edit: October 14, 2012, 07:27:20 AM by JamminR »

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: Could someone help me please?
« Reply #1 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.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Could someone help me please?
« Reply #2 on: October 13, 2012, 09:16:36 PM »
Snipe, i wonder if he wants default level set that high (admin).
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: Could someone help me please?
« Reply #3 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." )
« Last Edit: October 13, 2012, 10:51:08 PM by iSnipeu »

Offline kaos2100

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: Could someone help me please?
« Reply #4 on: October 14, 2012, 12:59:55 AM »
Thanks but I'm getting

FCVAR_SERVER_CAN_EXECUTE prevented server running command: stopsounds

Offline kaos2100

  • Newbie
  • *
  • Posts: 13
  • Karma: 2
Re: Could someone help me please?
« Reply #5 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')")
« Last Edit: October 14, 2012, 02:20:15 AM by kaos2100 »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Could someone help me please?
« Reply #6 on: October 14, 2012, 05:11:57 AM »
Garry's blocks on remote execution are so silly. :P
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How do I create stopsound chat command?
« Reply #7 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...")
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MulleDK13

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: Could someone help me please?
« Reply #8 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.