Jump to content

Language Chat - How can get once special for country?


papam77

Recommended Posts

Hello i've made this, but how can set every chat for his own language, like: Czech = Czech Language

So if is player from Czech he can type with L only to Czech Language Chat.

  local function outputChatMsg(msgtype,m,source) 
    if msgtype == 0 then 
        for k,v in ipairs(getElementsByType("player")) do 
            if (getElementData(v,"room") == getElementData(source,"room")) then 
                outputChatBox(m,v,255,255,255,true) 
            end 
        end 
    elseif msgtype == 2 then 
        local team = getPlayerTeam(source) 
        if team then 
            for k,v in ipairs(getElementsByType("player")) do 
                if getPlayerTeam(v) then 
                    outputChatBox("#FF6464(Team) #ffffff"..m,v,255,255,255,true) 
                end 
            end 
        end 
    elseif msgtype == 3 then 
    outputChatBox("#FF6464[Language] #ffffff"..m,root,255,255,255,true) 
    end 
end 
  
local function LanguageChat(source,cmd,...) 
    local m = table.concat({...},' '):gsub("#%x%x%x%x%x%x",""):sub(1,100) 
    outputChatMsg(3,getPlayerName(source).."#F2F0F0: "..m,source) 
end 
addCommandHandler("Language",LanguageChat) 
  
addEventHandler("onPlayerJoin",root, 
function() 
    bindKey(source,"L","down","chatbox","Language") 
end) 
  
for k,v in ipairs(getElementsByType("player")) do 
    bindKey(v,"L","down","chatbox","Language") 
end 
  

How ?

Link to comment

Like this?

local function outputChatMsg(msgtype,m,source) 
    if not msgtype or type(msgtype)~="number" then 
        return false 
    end 
    if msgtype == 0 then 
        for _,v in ipairs(getElementsByType("player")) do 
            if (getElementData(v,"room") == getElementData(source,"room")) then 
                outputChatBox(m,v,255,255,255,true) 
            end 
        end 
    elseif msgtype == 2 then 
        local team = getPlayerTeam(source) 
        if team then 
            for _,v in ipairs(getElementsByType("player")) do 
                if getPlayerTeam(v) then 
                    outputChatBox("#FF6464(Team) #ffffff"..m,v,255,255,255,true) 
                end 
            end 
        end 
    elseif msgtype == 3 then 
        outputChatBox("#FF6464[Language] #ffffff"..m,root,255,255,255,true) 
    end 
end 
  
addCommandHandler("Language",function(source,_,...) 
    local m = table.concat({...},' '):gsub("#%x%x%x%x%x%x",""):sub(1,100) 
    outputChatMsg(3,getPlayerName(source).."#F2F0F0: "..m,source) 
end) 
  
addEventHandler("onPlayerJoin",root,function() 
    bindKey(source,"L","down","chatbox","Language") 
end) 
for _,v in ipairs(getElementsByType("player")) do 
    bindKey(v,"L","down","chatbox","Language") 
end 

Link to comment

:D

function LanguageChat(thePlayer, cmd, ...) 
    local msg = table.concat({...}, " ") 
    for _,players in ipairs(getElementsByType("player")) do 
        local r, g, b = getPlayerNametagColor (thePlayer) 
        local name = getPlayerName(thePlayer) 
        local mycountry = exports.admin:getPlayerCountry(thePlayer) 
        local playerscountry = exports.admin:getPlayerCountry(players) 
        if (playerscountry == mycountry) then 
            if (msg and msg ~= "") then 
                local r, g, b = getPlayerNametagColor (thePlayer) 
                local name = getPlayerName(thePlayer) 
                outputChatBox("("..getPlayerCountry(thePlayer)..") "..getPlayerName(name)..": #FFFFFF"..msg,root,r, g, b,true) 
            end 
        end 
    end 
end 
addCommandHandler("Language",LanguageChat) 
  
addEventHandler("onPlayerJoin",root, 
    function () 
        bindKey(source,"L","down","chatbox","Language") 
    end 
) 
  
addEventHandler("onResourceStart",resourceRoot, 
    function () 
        for index, player in ipairs(getElementsByType("player")) do 
            bindKey(player,"L","down","chatbox","Language") 
        end 
    end 
) 

Edited by Guest
Link to comment
Now i can't write to Language chat. It doesn't send my message

error ?

try it

function LanguageChat(thePlayer, cmd, ...) 
    local msg = table.concat({...}, " ") 
    for _,players in ipairs(getElementsByType("player")) do 
        local r, g, b = getPlayerNametagColor (thePlayer) 
        local name = getPlayerName(thePlayer) 
        local mycountry = exports.admin:getPlayerCountry(thePlayer) 
        local playerscountry = exports.admin:getPlayerCountry(players) 
        if (playerscountry == mycountry) then 
            if (msg and msg ~= "") then 
            outputChatBox("("..mycountry..") "..getPlayerName(name)..": #FFFFFF"..msg.."",players,r, g, b,true) 
            end 
        end 
    end 
end 
addCommandHandler("Language",LanguageChat) 
  
addEventHandler("onPlayerJoin",root, 
    function () 
        bindKey(source,"L","down","chatbox","Language") 
    end 
) 
  
addEventHandler("onResourceStart",resourceRoot, 
    function () 
        for index, player in ipairs(getElementsByType("player")) do 
            bindKey(player,"L","down","chatbox","Language") 
        end 
    end 
) 

Link to comment
  ------ Global  
   
   
   
  local function outputChatMsg(msgtype,m,source) 
    if msgtype == 0 then 
        for k,v in ipairs(getElementsByType("player")) do 
            if (getElementData(v,"room") == getElementData(source,"room")) then 
                outputChatBox(m,v,255,255,255,true) 
            end 
        end 
    elseif msgtype == 2 then 
        local team = getPlayerTeam(source) 
        if team then 
            for k,v in ipairs(getElementsByType("player")) do 
                if getPlayerTeam(v) then 
                    outputChatBox("#FF6464(Team) #ffffff"..m,v,255,255,255,true) 
                end 
            end 
        end 
    elseif msgtype == 3 then 
    outputChatBox("#FF6464[Global] #ffffff"..m,root,255,255,255,true) 
    end 
end 
  
local function GlobalChat(source,cmd,...) 
    local m = table.concat({...},' '):gsub("#%x%x%x%x%x%x",""):sub(1,100) 
    outputChatMsg(3,getPlayerName(source).."#F2F0F0: "..m,source) 
end 
addCommandHandler("Globalsay",GlobalChat) 
  
addEventHandler("onPlayerJoin",root, 
function() 
    bindKey(source,"G","down","chatbox","Globalsay") 
end) 
  
for k,v in ipairs(getElementsByType("player")) do 
    bindKey(v,"G","down","chatbox","Globalsay") 
end 
----- Language 
  
  
  
  
function LanguageChat(thePlayer, cmd, ...) 
    local msg = table.concat({...}, " ") 
    for _,players in ipairs(getElementsByType("player")) do 
        local r, g, b = getPlayerNametagColor (thePlayer) 
        local name = getPlayerName(thePlayer) 
        local mycountry = exports.admin:getPlayerCountry(thePlayer) 
        local playerscountry = exports.admin:getPlayerCountry(players) 
        if (playerscountry == mycountry) then 
            if (msg and msg ~= "") then 
            outputChatBox("("..mycountry..") "..getPlayerName(name)..": #FFFFFF"..msg.."",players,r, g, b,true) 
            end 
        end 
    end 
end 
addCommandHandler("Language",LanguageChat) 
  
addEventHandler("onPlayerJoin",root, 
    function () 
        bindKey(source,"L","down","chatbox","Language") 
    end 
) 
  
addEventHandler("onResourceStart",resourceRoot, 
    function () 
        for index, player in ipairs(getElementsByType("player")) do 
            bindKey(player,"L","down","chatbox","Language") 
        end 
    end 
) 

Link to comment

edite

tested and working

function LanguageChat(thePlayer, cmd, ...) 
    local msg = table.concat({...}, " ") 
    for _,players in ipairs(getElementsByType("player")) do 
        local r, g, b = getPlayerNametagColor (thePlayer) 
        local name = getPlayerName(thePlayer) 
        local mycountry = exports.admin:getPlayerCountry(thePlayer) 
        local playerscountry = exports.admin:getPlayerCountry(players) 
        if (playerscountry == mycountry) then 
            if (msg and msg ~= "") then 
            outputChatBox("("..mycountry..") "..name..": #FFFFFF"..msg.."",players,r, g, b,true) 
            end 
        end 
    end 
end 
addCommandHandler("Language",LanguageChat) 
  
addEventHandler("onPlayerJoin",root, 
    function () 
        bindKey(source,"L","down","chatbox","Language") 
    end 
) 
  
addEventHandler("onResourceStart",resourceRoot, 
    function () 
        for index, player in ipairs(getElementsByType("player")) do 
            bindKey(player,"L","down","chatbox","Language") 
        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...