Jump to content

Tag No chat


Recommended Posts

chat_range        = 100 
chatTime          = {}
elementID         = "ID"
lastChatMessage   = {}

function isPlayerInRangeOfPoint(player,x,y,z,range) 
  local px,py,pz=getElementPosition(player) 
  return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range 
end 

function onChatLocal(text, type)
  local new   = ""
  local iter  = 0
  local msg   = string.gsub(text, "_", "")
  
  for word in msg:gmatch("%S+") do
    iter = iter + 1

    if iter == 1 and word:len() > 0 then
      word = word:gsub("%a", string.upper, 1)
    end

    new = new..word.." "
  end

  if new ~= "" then msg = new end
  text = msg

  if not hasObjectPermissionTo(source, "function.kickPlayer") then
        if chatTime[source] and chatTime[source] + tonumber(5000) > getTickCount() then
            cancelEvent()
            outputChatBox("Espere 5 segundo para poder digitar novamente!", source, 255, 0, 0)
            return
        else
            chatTime[source] = getTickCount()
        end
  end
  
  lastChatMessage[source] = text
  cancelEvent(true)
  
    local px,py,pz = getElementPosition(source) 
  local nick = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "") 
  local id = getElementData(source, elementID) or "n.a"
    for _,v in ipairs(getElementsByType("player")) do 
    if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then       
          outputChatBox("᠉  #1E90FF BNR - #ffa500[ ChatLocal ]   - #FFFFFF"..nick.." #1E90FF ["..id.."]#00ff00 - #ffa500"..msg, v, 200, 200, 200,true) 
        end 
    end  
end
addEventHandler("onPlayerChat", root, onChatLocal)

function MensagemTwitter(source, cmd, ...) 
  local MessagemT = table.concat ( { ... }, " " )
  local name = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "")
  local id = getElementData(source, elementID) or "n.a"

  for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("᠉  #1E90FF BNR - #1E90FF[ Facebook ]   - #ffffff"..name.." #1E90FF["..id.."]#00BFFF - #1E90FF"..MessagemT,v, 255, 255, 255, true) 
  end 
end 
addCommandHandler("Facebook",  MensagemTwitter)
  
addCommandHandler( "DeepWeb", function ( source, cmd, ... )            
    local message2 = #{...} > 0 and table.concat({...}," ") or nil
    if message2 then
        for _, p in ipairs (getElementsByType("player")) do
      if hasObjectPermissionTo(p, "command.mute", true) then
        local name = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "")
        local id = getElementData(source, elementID) or "n.a"
                outputChatBox("᠉ #1E90FF BNR - #696969[ DeepWeb ]  - #ffffff"..name.." ["..id.."]#696969 - #696969"..message2, p, 255, 255, 255, true)
            else
                outputChatBox("᠉ #696969 DeepWeb   - #696969"..message2, p, 255, 255, 255, true)
            end
        end
    else
    end
end)

addEventHandler("onPlayerJoin", getRootElement(), function() 
  bindKey(source, "y", "down", "chatbox", "Facebook")
end) 

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
    bindKey(player,"y", "down", "chatbox", "Facebook")
  end 
end) 

addEventHandler("onPlayerJoin", getRootElement(), function() 
  bindKey(source, "u", "down", "chatbox", "DeepWeb")
end) 

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
    bindKey(player,"u", "down", "chatbox", "DeepWeb")
  end 
end) 





Edited by Kaio Bruno Silveira
Eu so queria que aparecesse no facebook e no chatlocal as TAG: ''Presidente'' ''Vice Presidente'' ''Deputado Federal'' ''Deputado Estudal'' ''Prefeito'' ''Vereador''
Link to comment

Veja se vai funcinar assim:

Spoiler

Lembre-se de usar o setPlayerNametagText para setar a tag e setPlayerNametagColor pra definir a cor.

 

 

chat_range        = 100 
chatTime          = {}
elementID         = "ID"
lastChatMessage   = {}

function isPlayerInRangeOfPoint(player,x,y,z,range) 
  local px,py,pz=getElementPosition(player) 
  return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range 
end 

function onChatLocal(text, type)
  local new   = ""
  local iter  = 0
  local msg   = string.gsub(text, "_", "")
  
  for word in msg:gmatch("%S+") do
    iter = iter + 1

    if iter == 1 and word:len() > 0 then
      word = word:gsub("%a", string.upper, 1)
    end

    new = new..word.." "
  end

  if new ~= "" then msg = new end
  text = msg

  if not hasObjectPermissionTo(source, "function.kickPlayer") then
        if chatTime[source] and chatTime[source] + tonumber(5000) > getTickCount() then
            cancelEvent()
            outputChatBox("Espere 5 segundo para poder digitar novamente!", source, 255, 0, 0)
            return
        else
            chatTime[source] = getTickCount()
        end
  end
  
  lastChatMessage[source] = text
  cancelEvent(true)
  
  local px,py,pz = getElementPosition(source) 
  local nick = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "") 
  local id = getElementData(source, elementID) or "n.a"
  
for _,v in ipairs(getElementsByType("player")) do 
    if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then       
          outputChatBox("᠉  #1E90FF BNR - #ffa500[ ChatLocal ]  "..tag (source).." - #FFFFFF"..nick.." #1E90FF ["..id.."]#00ff00 - #ffa500"..msg, v, 200, 200, 200,true) 
        end 
    end  
end
addEventHandler("onPlayerChat", root, onChatLocal)

function MensagemTwitter(source, cmd, ...) 
  local MessagemT = table.concat ( { ... }, " " )
  local name = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "")
  local id = getElementData(source, elementID) or "n.a"

  for _,v in ipairs(getElementsByType("player")) do 
    outputChatBox("᠉  #1E90FF BNR - #1E90FF[ Facebook ]  "..tag (source).." - #ffffff"..name.." #1E90FF["..id.."]#00BFFF - #1E90FF"..MessagemT,v, 255, 255, 255, true) 
  end 
end 
addCommandHandler("Facebook",  MensagemTwitter)
  
addCommandHandler( "DeepWeb", function ( source, cmd, ... )            
    local message2 = #{...} > 0 and table.concat({...}," ") or nil
    if message2 then
        for _, p in ipairs (getElementsByType("player")) do
      if hasObjectPermissionTo(p, "command.mute", true) then
        local name = string.gsub(getPlayerName(source), "#%x%x%x%x%x%x", "")
        local id = getElementData(source, elementID) or "n.a"
                outputChatBox("᠉ #1E90FF BNR - #696969[ DeepWeb ]  -"..tag (source).." #ffffff"..name.." ["..id.."]#696969 - #696969"..message2, p, 255, 255, 255, true)
            else
                outputChatBox("᠉ #696969 DeepWeb   - #696969"..message2, p, 255, 255, 255, true)
            end
        end
    else
    end
end)

function tag (player)
	if isElement(player) and getElementType ('player') then
      local r, g, b =  getPlayerNametagColor (player)
      local tag = getPlayerNametagText  (player)
      local color = RGBToHex (r, g, b)
      return color..tag
	end
end

function RGBToHex(red, green, blue, alpha)
	if( ( red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 ) or ( alpha and ( alpha < 0 or alpha > 255 ) ) ) then
		return nil
	end
	if alpha then
		return string.format("#%.2X%.2X%.2X%.2X", red, green, blue, alpha)
	else
		return string.format("#%.2X%.2X%.2X", red, green, blue)
	end
end

addEventHandler("onPlayerJoin", getRootElement(), function() 
  bindKey(source, "y", "down", "chatbox", "Facebook")
end) 

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
    bindKey(player,"y", "down", "chatbox", "Facebook")
  end 
end) 

addEventHandler("onPlayerJoin", getRootElement(), function() 
  bindKey(source, "u", "down", "chatbox", "DeepWeb")
end) 

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
    bindKey(player,"u", "down", "chatbox", "DeepWeb")
  end 
end) 
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...