Jump to content

Multi language


MIKI785

Recommended Posts

Hi, I want to make a multi language messages, I have done for 1 player, who triggered the event or command:

function sendMessage (CZ, EN, source) 
  
if (getElementData(source, "lang") == "EN") then 
    outputChatBox(EN, source, 255, 0, 0, true) 
     
    else 
     
    outputChatBox(CZ, source, 255, 0, 0, true) 
    end 
end 

This is working, but how to do messages for all players? I have this:

for _, vehicleValue in ipairs(hraci) do --Vehicle value is because I copied this from command '''fixall'' ..  
    local hracuvJazyk = getElementData(hraci, "lang") 
       if (hracuvJazyk == "CZ") then 
       outputChatBox(CZ, hraci, 250, 0, 0, true) 
    end 
end 

But it doesn't work, and I think that this would work it will send message to all players, even to players which have different language..

How to do it?

EDIT: I probably made mistake, it should be:

  
hraci = getElementsByType("player") 
for _, vehicleValue in ipairs(hraci) do 
    local hracuvJazyk = getElementData(vehicleValue, "lang") 
       if (hracuvJazyk == "CZ") then 
       outputChatBox(CZ, hraci, 250, 0, 0, true) 
    end 
end 

Edited by Guest
Link to comment

Yes, it should be:

hraci = getElementsByType("player") 
for _, element in ipairs(hraci) do 
    local hracuvJazyk = getElementData(element, "lang") 
       if (hracuvJazyk == "CZ") then 
       outputChatBox(CZ, hraci, 250, 0, 0, true) 
    end 
end 

But will it work?

it should send message to people which has CZ as language only...

Link to comment

I won't post the whole .lua file, it has over 600 lines..

I just post that function:

function sendMessageAll (CZ, EN) 
  
hraci = getElementsByType("player") 
for _, vehicleValue in ipairs(hraci) do 
    local hracuvJazyk = getElementData(vehicleValue, "lang") 
       if (hracuvJazyk == "EN") then 
       outputChatBox(EN, vehicleValue, 250, 0, 0, true) 
    end 
    end  
  
for _, vehicleValue in ipairs(hraci) do 
    local hracuvJazyk = getElementData(vehicleValue, "lang") 
       if (hracuvJazyk == "CZ") then 
       outputChatBox(CZ, vehicleValue, 250, 0, 0, true) 
    end 
end 
end 
--This shloud be used like: sendMessageAll("Ahoj", "Hello") 

I editet it over 10 times.. :D

Link to comment
function sendMessageAll (CZ, EN) 
hraci = getElementsByType("player") 
for _, player in ipairs(hraci) do 
    local hracuvJazyk = getElementData(player, "lang") 
       if (hracuvJazyk == "EN") then 
            outputChatBox(EN, player, 250, 0, 0, true) 
       elseif (hracuvJazyk == "CZ") then 
            outputChatBox(CZ, player, 250, 0, 0, true) 
        end 
    end 
end 
--This shloud be used like: sendMessageAll("Ahoj", "Hello") 

Should work.

Link to comment
  
function sendMessageAll(CZ, EN) 
    for _, player in ipairs(getElementsByType("player")) do 
        local hracuvJazyk = getElementData(player, "lang") 
        if (hracuvJazyk == "EN") then 
            outputChatBox(EN, player, 250, 0, 0, true) 
        else 
            outputChatBox(CZ, player, 250, 0, 0, true) 
        end 
    end 
end 
  

Edit:

Damnit, Solidsnake14 was faster than me...

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