Solved Automatic language switching for incoming players?
Discussion in 'Rust Development' started by hulimontana, Dec 16, 2016.
-
Wulf Community Admin
-
yep, i have Russian language files, if i write in chat "/lang ru" - it's work.
-
Wulf Community Admin
The chat command uses the same thing, so that doesn't make any sense. -
I see the sense in it.
Where i can find information about: lang, player.ConsoleMessage and other oxide functions?
and why this code works for other people but not for me?
maybe I did not connect the necessary libraries?Code:lang.SetLanguage("ru", player.UserIDString);
It's all code:
Code:namespace Oxide.Plugins { [Info("Lang", "hulimontana", 0.1)] [Description("Auto change language")] class Lang : RustPlugin { void OnPlayerInit(BasePlayer player) { if (player == null || player.net == null || player.net.connection == null) return; string ply_lang = player.net.connection.info.GetString("global.language", null); // returns a shortcode like 'en' if (ply_lang != null) { //do whatelse example string lng = ply_lang.Substring(0, 1); Puts($"Player {player.displayName} has the language {lng}"); lang.SetLanguage(lng, player.UserIDString); } } } } -
Wulf Community Admin
player.ConsoleMessage is from Rust, not Oxide, and is not for running commands.
The 'lang' library helper is from Oxide, and can be found in Oxide's source on GitHub.
If the plugin is compiling, it should be working. Is the plugin compiling successfully? Do you see the message that you have with Puts? -
what you mean about compilation? i just create .txt file and rename it in "lang.cs".
if you about loading plugin:
Last edited by a moderator: Dec 28, 2016 -
Code:
public static string GetLanguage(this Connection connection) { bool flag = connection != null; string result; if (flag) { result = connection.info.GetString("global.language", "en").ToUpper(); } else { result = "EN"; } return result; }
