I am needing some suggestions on how to complete this code. I do not use lua very often so I am stumped at this point. What I am doing here is attempting to create a chat command that sends a ulx asay message in the event that someone closes out of the RDM manager I am using for my TTT server. The reason I am not just going to tell people to use the asay command, since they do have the ability to use it, is for shear simplicity. It is easier for me to say type !report than get them to understand the command.
[CODE]function report( ply, text, public )
if (string.sub(text, 1, 7) == "/report") then
--Not sure what to put here to get it to do an asay--
return(false) --Make sure it is a silent command
end
end
hook.Add( "PlayerSay", "report", report );[/CODE]
Any help in this would be much appreciated.
You could execute a console command through lua to call the asay function. Not sure if ULX lets you call through console, but I know Evolve does, and I've done things like that before.
PlayerSay portion:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/chat_commands/chat_commands.lua.html[/url]
Plus this:
[lua]concommand.Add( "report", function( _p, _cmd, _args )
local _msg = string.Implode( " ", _args );
ulx.asay( _p, _msg );
end );[/lua]
!report will be public while /report will be silent.
If I remember correctly, returning false in player say does nothing, you have to return an empty string,
correct me if I'm wrong.
[QUOTE=Acecool;45069206]PlayerSay portion:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/chat_commands/chat_commands.lua.html[/url]
Plus this:
[lua]concommand.Add( "report", function( _p, _cmd, _args )
local _msg = string.Implode( " ", _args );
ulx.asay( _p, _msg );
end );[/lua]
!report will be public while /report will be silent.[/QUOTE]
Thank you so much, I will check to see how this works in the morning. Also to Anon, I attempted this section of code with a kill command specified. EX ply:Kill() and it worked fine. The command was hidden like I intended. I was only having trouble with how to declare the code to do an asay command. This worked for me, I cannot attest to other coders, I may have just gotten lucky when coding it for testing.
Use
[lua]
return ""
[/lua]
instead of
[lua]
return false
[/lua]
otherwise it may break your other addons that rely on the same hook.
... I think.
Sorry, you need to Log In to post a reply to this thread.