MIKI785 Posted January 4, 2012 Posted January 4, 2012 (edited) 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 January 4, 2012 by Guest
Castillo Posted January 4, 2012 Posted January 4, 2012 I understand that "hraci" is a table. for _, element in ipairs(hraci) do local hracuvJazyk = getElementData(element , "lang") if (hracuvJazyk == "CZ") then outputChatBox(CZ, element, 250, 0, 0, true) end end
MIKI785 Posted January 4, 2012 Author Posted January 4, 2012 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...
MIKI785 Posted January 4, 2012 Author Posted January 4, 2012 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..
Castillo Posted January 4, 2012 Posted January 4, 2012 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.
MIKI785 Posted January 4, 2012 Author Posted January 4, 2012 Ok I'll try it, will it send the CZ text to players who has language set to CZ? And EN text to who has EN as language? But as I'm looking at it, it should work, i'm still beginner
Cadu12 Posted January 4, 2012 Posted January 4, 2012 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...
Castillo Posted January 4, 2012 Posted January 4, 2012 Ok I'll try it, will it send the CZ text to players who has language set to CZ? And EN text to who has EN as language?But as I'm looking at it, it should work, i'm still beginner It should do yes.
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