Jump to content

/me command


golanu21

Recommended Posts

i try it like that

chat_rangee=100 
  
function isPlayerInRangeOfPoint(player,xx,yy,zz,rangee) 
   local pxx,pyy,pzz=getElementPosition(player) 
   return ((xx-pxx)^2+(yy-pyy)^2+(zz-pzz)^2)^0.5<=rangee 
end 
  
function onChat(player,_,...) 
  local pxx,pyy,pzz=getElementPosition(player) 
  local msgg = table.concat({...}, " ") 
  local nickk=getPlayerName(player) 
  for _,c in ipairs(getElementsByType("player")) do 
    if isPlayerInRangeOfPoint(c,pxx,pyy,pzz,chat_rangee) then 
      outputChatBox( "#00ffff *"..nickk.." "..msgg,c,r,g,b,true) 
    end 
  end 
end 
addCommandHandler("me",onChat) 
  
  
 addEventHandler ( "onPlayerChat", root, 
    function ( message ) 
         if message == me then 
            cancelEvent ( ) 
        end 
    end 
) 

Edited by Guest
Link to comment

Please learn from this code I just baked in my oven.

chatRadius = 30 
  
addEventHandler('onPlayerChat', getRootElement(), 
function(message, mType) 
    if mType == 1 then 
        cancelEvent() 
        local posX, posY, posZ = getElementPosition(source) 
        local chatSphere = createColSphere(posX, posY, posZ, chatRadius) 
        local nearbyPlayers = getElementsWithinColShape(chatSphere, "player") 
        destroyElement(chatSphere) 
        for i, v in ipairs(nearbyPlayers) do 
            outputChatBox('* '..getPlayerName(v):gsub('#%x%x%x%x%x%x', '')..' '..message:gsub('#%x%x%x%x%x%x', ''), v, 255, 0, 255) 
        end 
    end 
end ) 
  

Link to comment
Please learn from this code I just baked in my oven.
chatRadius = 30 
  
addEventHandler('onPlayerChat', getRootElement(), 
function(message, mType) 
    if mType == 1 then 
        cancelEvent() 
        local posX, posY, posZ = getElementPosition(source) 
        local chatSphere = createColSphere(posX, posY, posZ, chatRadius) 
        local nearbyPlayers = getElementsWithinColShape(chatSphere, "player") 
        destroyElement(chatSphere) 
        for i, v in ipairs(nearbyPlayers) do 
            outputChatBox('* '..getPlayerName(v):gsub('#%x%x%x%x%x%x', '')..' '..message:gsub('#%x%x%x%x%x%x', ''), v, 255, 0, 255) 
        end 
    end 
end ) 
  

thanx man

Link to comment

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...