greenday Posted May 10, 2014 Share Posted May 10, 2014 Players on my server abuse /me command, they bind it and spam the chat box. I wanna know the name of the resource this command is in. I searched a lot and couldn't find any thread related to it. Link to comment
xXMADEXx Posted May 10, 2014 Share Posted May 10, 2014 /me is a command that is created by the MTA server. You can use this script to cancel it: addEventHandler ( "onPlayerChat", root, function ( _, tp ) if ( tp == 1 ) then cancelEvent ( ) end end ) Link to comment
greenday Posted May 11, 2014 Author Share Posted May 11, 2014 Thanks a ton bro, it worked perfectly! Link to comment
Mr_Moose Posted May 12, 2014 Share Posted May 12, 2014 last_msg = {} addEventHandler ( "onPlayerChat", root, function ( message, tp ) if last_msg[source] and last_msg[source] == message then cancelEvent ( ) end -- Optinal disable "me" chat completly if ( tp == 1 ) then cancelEvent ( ) end -- Remember last message last_msg[source] = message end ) If the problem is spam then you might consider to protect the other chat's too since those may be accessed by command as well, cancel the event if the same message is sen't twice is one way, a timer would also work. Link to comment
#RooTs Posted May 12, 2014 Share Posted May 12, 2014 last_msg = {} addEventHandler ( "onPlayerChat", root, function ( message, tp ) if last_msg[source] and last_msg[source] == message then cancelEvent ( ) end -- Optinal disable "me" chat completly if ( tp == 1 ) then cancelEvent ( ) end -- Remember last message last_msg[source] = message end ) If the problem is spam then you might consider to protect the other chat's too since those may be accessed by command as well, cancel the event if the same message is sen't twice is one way, a timer would also work. and how to cancel the commands /register and /login ????? Link to comment
Toffbrown Posted May 12, 2014 Share Posted May 12, 2014 (edited) cancelEvent() use Edited May 12, 2014 by Guest Link to comment
#RooTs Posted May 12, 2014 Share Posted May 12, 2014 can make this script for me? PLEASE Link to comment
Toffbrown Posted May 12, 2014 Share Posted May 12, 2014 you really should try to make it yourself, and us help if you have errors but. addEventHandler("onPlayerCommand", root, function(noreg) if noreg == "register" then cancelEvent() end end) Link to comment
#RooTs Posted May 12, 2014 Share Posted May 12, 2014 addEventHandler("onPlayerCommand", root, function(noreg) if noreg == "register" then cancelEvent() end end) -- and addEventHandler("onPlayerCommand", root, function(noreg) if noreg == "login" then -- is right? cancelEvent() end end) is right? Link to comment
Mr_Moose Posted May 12, 2014 Share Posted May 12, 2014 It's correct but you could add both the "if" statements into the same command handler like this: -- List of commands to disable cmdList = { ["register"]=true, ["login"]=true } -- Disable unwanted commands addEventHandler("onPlayerCommand", root, function(cmdName) if cmdList[cmdName] then cancelEvent() end end) And then, why not improve it further by adding the commands to a table to make it easier to add even more commands you might want to disable. Link to comment
#RooTs Posted May 13, 2014 Share Posted May 13, 2014 -- List of commands to disable cmdList = { ["register"]=true, ["login"]=true ["me"]=true ["say"]=true -- right? } -- Disable unwanted commands addEventHandler("onPlayerCommand", root, function(cmdName) if cmdList[cmdName] then cancelEvent() end end) right? Link to comment
Toffbrown Posted May 13, 2014 Share Posted May 13, 2014 the commands "me" and "say" are onPlayerChat so use the previous bit of code with the current piece of code, Just wondering why do you wan't to remove "say"? Link to comment
Mr_Moose Posted May 13, 2014 Share Posted May 13, 2014 It's correct except for those commas at the end of each table line, this will work. -- List of commands to disable cmdList = { ["register"]=true, ["login"]=true, -- Don't forget the comma at the end of this and the below line. ["me"]=true, ["say"]=true } -- Disable unwanted commands addEventHandler("onPlayerCommand", root, function(cmdName) if cmdList[cmdName] then cancelEvent() end end) the commands "me" and "say" are onPlayerChat so use the previous bit of code with the current piece of code,Just wondering why do you wan't to remove "say"? It's also commands that triggers the onPlayerChat event, but you're right, the say command is used with the chatbox command so it won't work to disable those in this event probably. Many roleplay servers removes the main chat as far as I know so it makes sense. Link to comment
xXMADEXx Posted May 14, 2014 Share Posted May 14, 2014 I'm actually pretty sure that the /register (not sure about /login) is part of the default admin resource. Edit: I checked the admin resource, and it should be (by default) in admin/server/admin_server.lua on lines 447-468 Link to comment
xNicO.ox Posted May 8, 2018 Share Posted May 8, 2018 how remove code colour of the nickname of comand me? Link to comment
Hoffmann Posted May 8, 2018 Share Posted May 8, 2018 9 hours ago, xNicO.ox said: how remove code colour of the nickname of comand me? You have to disable the default /me command and write new one. Try this code: addEventHandler("onPlayerChat", root, function(message, type) if type == 1 then -- if action message cancelEvent() -- prevent from sending it into chatbox local actionMessage = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "").." "..message outputChatBox(actionMessage, root, 255, 255, 255, false) end end Link to comment
xNicO.ox Posted May 8, 2018 Share Posted May 8, 2018 10 hours ago, NeverUnbeatable said: You have to disable the default /me command and write new one. Try this code: addEventHandler("onPlayerChat", root, function(message, type) if type == 1 then -- if action message cancelEvent() -- prevent from sending it into chatbox local actionMessage = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "").." "..message outputChatBox(actionMessage, root, 255, 255, 255, false) end end where? admin_server.lua or what? Link to comment
Hoffmann Posted May 9, 2018 Share Posted May 9, 2018 7 hours ago, xNicO.ox said: where? admin_server.lua or what? Any serverside .lua script. Learn how to script and ask only if you have question related to scripting problem. Link to comment
Addlibs Posted May 9, 2018 Share Posted May 9, 2018 I'd also point out that string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "") won't remove double nested colour codes such as ##000000ff0000 but instead only remove the inner code #000000 and the output will contain #ff0000 which, if colour coding is enabled, will turn the subsequent text red. A better alternative would be to do a while-do loop which would keep doing string.gsub while colour codes are still present (string.find), or if preferable, add some code which would disallow colour codes in names, freeing the need to filter such colour codes from names every time someone says something. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now