papam77 Posted July 19, 2013 Share Posted July 19, 2013 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
Jaysds1 Posted July 19, 2013 Share Posted July 19, 2013 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
papam77 Posted July 20, 2013 Author Share Posted July 20, 2013 No, 'cause russian players see my messages and i am from CZ. Only czech players must see messages by CZ players. Slovakia players must see messages by SK players. Russian players must see messages by RU players. and etc.... Link to comment
WASSIm. Posted July 20, 2013 Share Posted July 20, 2013 (edited) 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 July 20, 2013 by Guest Link to comment
papam77 Posted July 20, 2013 Author Share Posted July 20, 2013 Now i can't write to Language chat. It doesn't send my message Link to comment
WASSIm. Posted July 20, 2013 Share Posted July 20, 2013 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
papam77 Posted July 20, 2013 Author Share Posted July 20, 2013 ------ 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
WASSIm. Posted July 20, 2013 Share Posted July 20, 2013 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
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