..:D&G:.. Posted November 23, 2014 Posted November 23, 2014 Hello guys, I am trying to make a small function to allow people select their own language on the server. I would like to use elementData and a command such as /eng to set the language of the player to english. I did something like: languages = { eng = "English", ro = "Romanian", sp = "Spanish", it = "Italian", fr = "French", } function setPlayerLanguage(thePlayer, language) setElementData(thePlayer, language) outputChatBox("Language set to "..language, thePlayer) if getElementData(thePlayer, it) then outputChatBox("Your language is already italian", thePlayer) end end addCommandHandler("setlanguage", setPlayerLanguage) PS: Before someone comes and says "Retard, this script will not work, this is a mess, what kind of scripter are you?". I just made this in like 2 minutes, so I can give you guys an example to help me, because I want to do something like that. Thank you. MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
ViRuZGamiing Posted November 23, 2014 Posted November 23, 2014 Try this; function languageCmd(player, cmd, language) if cmd == "setlanguage" then language = tostring(language) if language then -- set player language else outputChatBox("[usage] /setlanguage [language]", player) end else outputChatBox("[usage] /setlanguage [language]", player) end end addCommandHandler("setlanguage", languageCmd) Not tested, never used the command with extra parameters but this is what I understand of it. "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
ChaosMTA Posted November 23, 2014 Posted November 23, 2014 -- Currently enabled languages. languages = { ["english"] = true, ["romanian"] = true, ["spanish"] = true, ["italian"] = true, ["french"] = true, } function languageCmd(player, cmd, language) if not tostring(language) then outputChatBox("[usage] /setlanguage [language]", player) return end language = string.lower(tostring(language)) if languages[language] then -- set player language else outputChatBox("Not a supported language type, you may choose from:", player) for k, v in pairs(languages) do outputChatBox(k, player) end end end addCommandHandler("setlanguage", languageCmd) OwlGaming Community Owner
..:D&G:.. Posted November 25, 2014 Author Posted November 25, 2014 Thanks ChaosMTA and ViRuZGamiing MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
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