General > Developers Corner

How do I create stopsound chat command?

(1/2) > >>

kaos2100:
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.

iSnipeu:

--- Code: ---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." )

--- End code ---

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.

JamminR:
Snipe, i wonder if he wants default level set that high (admin).

iSnipeu:
@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: ---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." )

--- End code ---

kaos2100:
Thanks but I'm getting

FCVAR_SERVER_CAN_EXECUTE prevented server running command: stopsounds

Navigation

[0] Message Index

[#] Next page

Go to full version