Solved Using the Lang API?

Discussion in 'Rust Development' started by TheMechanical97, Jan 4, 2016.

  1. How should i add lang api to may already coded plugin?
     
  2. Wulf

    Wulf Community Admin

    Take a look at some of my recent plugins, all of them use the Lang API. Resources from Wulf | Oxide

    All you're doing is creating a dictionary, registering that dictionary with the Lang API, and then calling it with lang.GetMessage along with a Steam ID when sending to a player.
     
  3. How can replace this?

    player.Message(GetMessage("Test", player));

    messages.Add("Test", "test message! You have {0}$");
    i want to replace the {0} with a variable :S
     
  4. Wulf

    Wulf Community Admin

    Use C#'s string.Format. Also, the "player.Message" is only available through the Covalence API, which you most likely aren't using.
    Code:
    rust.SendChatMessage(player, string.Format(GetMessage("Test", player.UserIDString), moneyVar);
     
  5. Should be like this?:
    player.Message(GetMessage("test").Replace({0}, .VariableToString), player));
    [DOUBLEPOST=1451943831][/DOUBLEPOST]
    lets see
     
  6. Wulf

    Wulf Community Admin

    The string.Format would make more sense if you are using {0} and such. The .Replace is better for custom placeholders.
     
  7. Okay! Working thanksss.

    The other question now is.... Popup notifications, How its suposet to get messages? just call it and set the message as:
    string.Format(GetMessage("Test", player.UserIDString), moneyVar))
    ??
     
  8. Wulf

    Wulf Community Admin

    What popup notifications?
     
  9. Plugin popup notifications
    [DOUBLEPOST=1451944412][/DOUBLEPOST]PopupNotifications?.Call("CreatePopupNotification", "Test message");
    [DOUBLEPOST=1451944454][/DOUBLEPOST]Alsoooo XD How can I replace {0} & {1} in the same message??
     
  10. Wulf

    Wulf Community Admin

    Just replace "Test message" with your message, just like shown previously.

    For the other question:
    Code:
    string.Format(GetMessage("Test", player.UserIDString), moneyVar, otherVar))
    C# basics. ;)
     
  11. thanks dude :D
     
    Last edited by a moderator: Jan 4, 2016