Oxsotus Posted July 15, 2013 Share Posted July 15, 2013 Hi! How can I switch off the standar /me and replace it with my own /me? function blockChatMessage() cancelEvent() end -- attach it as a handler to onPlayerChat addEventHandler( "onPlayerChat", getRootElement(), blockChatMessage ) It's blocked the standard /me, but it's blocked my /me too. function meChat(player,_,...) if(...==nil) then outputChatBox("Használat: /me szöveg",player,255,90,90) end if(...~=nil) then getCSD() local px,py,pz=getElementPosition(player) local msg = table.concat({...}, " ") for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,shoutRadius) then outputChatBox(csd[getElementData(player,"player_ID")].name.. "#cf4ca1 *"..msg.."*", v,255,150,150,true ) end end end end addCommandHandler("me",meChat) Link to comment
Vector Posted July 15, 2013 Share Posted July 15, 2013 SERVER-SIDE. function meChat(player,_,...) if(...==nil) then outputChatBox("Használat: /me szöveg",player,255,90,90) end if(...~=nil) then getCSD() local px,py,pz=getElementPosition(player) local msg = table.concat({...}, " ") for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,shoutRadius) then outputChatBox(csd[getElementData(player,"player_ID")].name.. "#cf4ca1 *"..msg.."*", v,255,150,150,true ) end end end end addEventHandler ("onPlayerCommand", getRootElement (), function (commandName) if string.lower (commandName) == "me" then cancelEvent (); end; end); addEvent ("onPlayerMeCommand", true); addEventHandler ("onPlayerMeCommand", getRootElement (), function (_, ...) meChat (source, "me", ...); end); CLIENT - SIDE addEventHandler("onClientConsole",getLocalPlayer(), function (text) -- get command name. local tokens = {}; for token in string.gmatch (text, "[^%s]+") do table.insert (tokens, token); end; if string.lower (tokens [1]) == "me" then triggerServerEvent ("onPlayerMeCommand", getLocalPlayer (), unpack (tokens)); end; end); Link to comment
Cadu12 Posted July 15, 2013 Share Posted July 15, 2013 function meChat(message, messageType) if (messageType == 1) then cancelEvent() getCSD() local px, py, pz = getElementPosition(source) for _, v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,shoutRadius) then outputChatBox(csd[getElementData(source,"player_ID")].name .. "#cf4ca1 *" .. message .. "*", v, 255, 150, 150, true) end end end end addEventHandler("onPlayerChat", getRootElement(), meChat) Link to comment
Vector Posted July 15, 2013 Share Posted July 15, 2013 that will not work. with onPlayerChat event, you cannot know what is the command name. That will call his function everytime the player enter a command. Link to comment
Castillo Posted July 15, 2013 Share Posted July 15, 2013 You're wrong, Vector, the onPlayerChat event has a message type argument, which specifies which chat is being used, 1 = "/me". Link to comment
Vector Posted July 15, 2013 Share Posted July 15, 2013 Ok. I believed "action message" means any command (not only the \me command) sorry 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