Jump to content

/me problem


Oxsotus

Recommended Posts

Posted

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) 

Posted

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); 
  

Posted
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) 

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...