Hey, I've been looking at several other plugins that use the Lang API but I still don't understand. If I have thisand thisCode:Discord.Call(lang.GetMessage("ReportMessage", this, id), player.Name, player.Id, targetUser.Name, targetUser.Id, message);
output this:Code:void LoadDefaultMessages() { //English lang.RegisterMessages(new Dictionary<string, string> { ["LoadingError"] = "{0} Discord not loaded correctly, please chjeck your plugin directory for Discord.cs file", ["PlayerNotFound"] = "{0} Player not found.", ["ReportConfirmation"] = "{0}Your report has been sent!", ["ReportMessage"] = "{0}{3} ({4}) reported {5} ({6}) for {7}" }, this); }
Code:Bobakanoosh (SteamID) reported Wulf (SteamID) for hacking
Lang API Question
Discussion in 'Rust Development' started by Bobakanoosh, Feb 13, 2017.
-
Wulf Community Admin
If you are setting the Lang API messages in a method called LoadDefaultMessages(), then you'd also need to call that from your Init() or Loaded() hook. For actually replacing variables in messages, you'd need to use string.Format to replace them with actual information.
Code:Discord.Call(string.Format(lang.GetMessage("ReportMessage", this, id), player.Name, player.Id, targetUser.Name, targetUser.Id, message));
-
Yes I am loading it in void Init(){}. I will test if it works.