VParker Posted February 17, 2017 Share Posted February 17, 2017 (edited) So,i want to remove the command /me from my server,but the scripts i've seen on the internet,and the one i done myself didn't work,so i'm asking for your help. This is the script that is not working: addEventHandler ( "onPlayerChat", root, function(cmd) if cmd = "me" then cancelEvent () end end) What did i do wrong? There is a pink /me command in the vanilla MTA server,that's what i am looking forward to disable for roleplay. (I want to make my own /me command) Edited February 17, 2017 by VParker Link to comment
MTA Team botder Posted February 17, 2017 MTA Team Share Posted February 17, 2017 You have to use cancelEvent in the onPlayerChat event if messageType == 1 and place your /me related code there. Link to comment
VParker Posted February 17, 2017 Author Share Posted February 17, 2017 So,can you like write down the fixed script? Because i dont really know where to put what you said.. 39 minutes ago, Necktrox said: You have to use cancelEvent in the onPlayerChat event if messageType == 1 and place your /me related code there. Link to comment
Mr.Loki Posted February 17, 2017 Share Posted February 17, 2017 52 minutes ago, VParker said: So,can you like write down the fixed script? Because i dont really know where to put what you said.. Example 1 on the wiki for onPlayerChat is perfect for what you are trying to achieve because all you have to di is remove some lines of code from it. Link to comment
VParker Posted February 17, 2017 Author Share Posted February 17, 2017 (edited) Not really helpful if i dont even know what lines should i delete. Instead of wasting my and your time,just maybe,tell which lines to delete? or where to add text to my script. I am not an experienced scripter,sorry. Edited February 17, 2017 by VParker why not. Link to comment
Mr.Loki Posted February 17, 2017 Share Posted February 17, 2017 (edited) Well this is the best way to learn unless you want to keep asking others for help when you can help yourself. Its all about thinking logically about how you want the script to run and a bit of trial and error which will help you understand way more. Your code above is a good start but onPlayerChat has 2 Parameters: string message, int messageType you would need to change cmd because it is in the position of the message parameter and add the message type after it function( message, messageType ) You can now use the messageType to determine if the message was a: 0: normal message 1: action message (/me) 2: team message Since you want to disable "1" which is /me aka action message you will need to check for it if messageType == 1 then now that it's an action message you want to cancel it using cancelEvent cancelEvent() and that's basically it, pretty simple right? Edited February 17, 2017 by loki2143 Link to comment
VParker Posted February 17, 2017 Author Share Posted February 17, 2017 (edited) Well,you are right about the learning part,but its easier to learn from someone then learn from yourself. ^^" But,it's still not working,maybe i misunderstood you. welp. I'll provide the edited script,because maybe im just stupid. addEventHandler ( "onPlayerChat", root, function( message,messageType ) if messageType == 1 then cancelEvent() end end) Edited February 17, 2017 by VParker Link to comment
Mr.Loki Posted February 17, 2017 Share Posted February 17, 2017 Use the code button < > to make code easily readable: addEventHandler ( "onPlayerChat", root, function( message,messageType ) if messageType == 1 then cancelEvent() end end) This code works fine for me. Are you running the code Server side? Link to comment
nikitafloy Posted February 17, 2017 Share Posted February 17, 2017 Shut down player use this command in ACL. Link to comment
VParker Posted February 17, 2017 Author Share Posted February 17, 2017 Hmm. Good idea,im going to try that now,but if i make a resource where the command is /me,will i be able to use that? Link to comment
Infinity# Posted February 17, 2017 Share Posted February 17, 2017 function disableCommand(command) if command == "me" then cancelEvent() end end addEventHandler("onPlayerCommand", root, disableCommand) This should definitely work. Link to comment
Mr.Loki Posted February 17, 2017 Share Posted February 17, 2017 Yes you would, but only if you set the restricted argument to false. Link to comment
VParker Posted February 17, 2017 Author Share Posted February 17, 2017 (edited) Well. I have freaking tried everything. I have added the script of SARSRPG after removing the restriction in ACL. No luck,didnt work. But if i disabled it in ACL i couldn't use my own /me command. So we are kinda back at the beginning. And yes,i cant use anything else for /me,because that not how everybody's used to it. Maybe i should try reinstalling my server? Because now im all out of ideas. 23 minutes ago, loki2143 said: Yes you would, but only if you set the restricted argument to false. 24 minutes ago, SARSRPG said: function disableCommand(command) if command == "me" then cancelEvent() end end addEventHandler("onPlayerCommand", root, disableCommand) This should definitely work. Edited February 17, 2017 by VParker Link to comment
koragg Posted February 17, 2017 Share Posted February 17, 2017 -- Remove /me chat addEventHandler ( "onPlayerChat", root, function ( _, tp ) if ( tp == 1 ) then outputChatBox("/me messages are disabled in this server", source, 255, 0, 0) cancelEvent ( ) end end ) Link to comment
VParker Posted February 17, 2017 Author Share Posted February 17, 2017 Your's worked koragg,but i want to use my own /me script,and i cant use it if your script is active. Link to comment
Mr.Loki Posted February 17, 2017 Share Posted February 17, 2017 Use @koragg code and modify the /me command like this: addEventHandler ( "onPlayerChat", root, function ( msg, tp ) if ( tp == 1 ) then cancelEvent ( ) -- Add your /me code here for example: outputChatBox(getPlayerName(source)..": "..msg,root,255,255,0) end end ) 1 Link to comment
VParker Posted February 17, 2017 Author Share Posted February 17, 2017 I Love you man. Thanks. Its working just fine. I'll send a PM to you. 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