• StopSound Code not working
    7 replies, posted
Hello, I'm new to LUA and my code for stopsound wasn't working. This is for a TTT server. I do use ULX. [CODE]local CATEGORY_NAME = "Utility" function ulx.stopsound( calling_ply, target_plys, amount ) local affected_plys = {} for i=1, #target_plys do local v = target_plys[ i ] if not should_stopsound then v:ConCommand("stopsound") v:ChatPrint("All sounds have been stopped for you.") end end if not should_stopsound then ulx.fancyLogAdmin( calling_ply, "#A has stopped music on #T clientside.", target_plys ) end end local tttstopsound = ulx.command( CATEGORY_NAME, "ulx stopsound", ulx.tttstopsound, "!stopsound" ) tttstopsound:addParam{ type=ULib.cmds.PlayersArg } tttstopsound:addParam{ type=ULib.cmds.BoolArg, invisible=true } tttstopsound:defaultAccess( ULib.ACCESS_SUPERADMIN ) tttstopsound:help( "Forces the target(s) sound to stop." )[/CODE] Thanks in advance :) It just says unknown command in console.
It's stopsounds I think, not stopsound
[QUOTE=Flash_Fire;40618179]It's stopsounds I think, not stopsound[/QUOTE] I'm sure it's stopsound.
stopsounds is removed in gmod 13 or sometime around that. stopsound is the correct command. The problem is that you named your function ulx.stopsound, while in ulx.command you point to ulx.tttstopsound, which doesn't exist. This caused the command not to get created and thus, unknown command.
[QUOTE=Donkie;40618445]stopsounds is removed in gmod 13 or sometime around that. stopsound is the correct command. The problem is that you named your function ulx.stopsound, while in ulx.command you point to ulx.tttstopsound, which doesn't exist. This caused the command not to get created and thus, unknown command.[/QUOTE] Thanks! I will try this and get back to you if it works. EDIT: It says the message, but doesn't work. I get this. [CODE]All sounds have been stopped for you. FCVAR_SERVER_CAN_EXECUTE prevented server running command: stopsound [/CODE]
[QUOTE=Donkie;40618445]stopsounds is removed in gmod 13 or sometime around that. stopsound is the correct command. The problem is that you named your function ulx.stopsound, while in ulx.command you point to ulx.tttstopsound, which doesn't exist. This caused the command not to get created and thus, unknown command.[/QUOTE] I'd got them mixed up then, I knew one was removed my bad!
stopsound is apparantly only executable from the client, which means we have to run it clientsidey. Which we can easily do using: v:SendLua([[RunConsoleCommand("stopsound")]]) This will send the snippet inside [[]] to the client, who then executes it.
[QUOTE=Donkie;40619049]stopsound is apparantly only executable from the client, which means we have to run it clientsidey. Which we can easily do using: v:SendLua([[RunConsoleCommand("stopsound")]]) This will send the snippet inside [[]] to the client, who then executes it.[/QUOTE] Thanks Donkie! I'll test it and get back to you. EDIT: It works now! Thanks SOOO much!
Sorry, you need to Log In to post a reply to this thread.