ConnectMessages

Moved

Total Downloads: 5,241 - First Release: Oct 20, 2016 - Last Update: Nov 10, 2017

5/5, 19 likes
  1. I'm getting the same thing.

    Code:
    (19:22:01) | Failed to call hook 'OnUserDisconnected' on plugin 'ConnectMessages v1.1.9' (NullReferenceException: Object reference not set to an instance of an object)
    (19:22:01) | at BasePlayer.SendConsoleCommand (System.String command, System.Object[] obj) [0x00000] in <filename unknown>:0
      at Oxide.Game.Rust.Libraries.Player.Message (.BasePlayer player, System.String message, System.String prefix, UInt64 userId, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Game.Rust.Libraries.Covalence.RustPlayer.Message (System.String message, System.String prefix, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Game.Rust.Libraries.Covalence.RustPlayer.Message (System.String message) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.ConnectMessages.Broadcast (System.String key, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.ConnectMessages.OnUserDisconnected (IPlayer player, System.String reason) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.ConnectMessages.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0
     
  2. Hi thanks for your Plugin. Does it possible to change a country name ?
     
  3. Wulf

    Wulf Community Admin

    Why would you change a player's country? The purpose is to show where they are from.
     
  4. Hi, i just wanted to change my country name to "Türkiye" not "Turkey".
     
  5. Wulf

    Wulf Community Admin

    Ah, not that I know of. That's pulled from the API I believe.
     
  6. it's ok thanks for sharing your time Wulf. I'm waiting an Oxide update on GS to update my server.
     
  7. I feel like this plugin could benefit from supporting DiscordMessages
    i have a text channel on my discord for chat, mutes, bans, etc. adding one for connect messages was pretty easy. if you agree, the api is on oxidemod.org/plugins/discordmessages.2486/

    upload_2017-12-18_12-37-30.png
     

    Attached Files:

  8. Hi, thanks for this plugin. I'd like to request support for the GeoIP plugin. I've created a working example below as a unified diff. I've also added a fix for the ip-info call for connections from private IP addresses to return "Unknown".

    Code:
    --- ConnectMessages.cs.2018-01-01       2018-01-01 14:27:18.191926200 -0700
    +++ ConnectMessages.cs  2018-01-01 15:35:07.339375300 -0700
    @@ -1,17 +1,21 @@
    using Oxide.Core.Libraries.Covalence;
    using System.Collections.Generic;
    using Newtonsoft.Json;
    using Oxide.Core;
    +using Oxide.Core.Plugins;
    using System;namespace Oxide.Plugins
    {
         [Info("ConnectMessages", "Spicy", "1.1.9", ResourceId = 2178)]
         [Description("Provides connect and disconnect messages.")]
         public class ConnectMessages : CovalencePlugin
         {
    +        [PluginReference]
    +        Plugin GeoIP;
    +
             #region Country API Class         private class Response
             {
                 [JsonProperty("country")]
    @@ -36,20 +40,22 @@         #region Config         private bool showConnectMessage;
             private bool showConnectCountry;
    +        private bool showConnectCountryUseGeoIP;
             private bool showDisconnectMessage;
             private bool showDisconnectReason;
             private bool showAdminMessages;         protected override void LoadDefaultConfig()
             {
                 Config["Settings"] = new Dictionary<string, bool>
                 {
                     ["ShowConnectMessage"] = true,
                     ["ShowConnectCountry"] = false,
    +                ["ShowConnectCountryUseGeoIP"] = false,
                     ["ShowDisconnectMessage"] = true,
                     ["ShowDisconnectReason"] = false,
                     ["ShowAdminMessages"] = true
                 };
             }
    @@ -58,10 +64,11 @@
             {
                 try
                 {
                     showConnectMessage = GetConfigValue("ShowConnectMessage");
                     showConnectCountry = GetConfigValue("ShowConnectCountry");
    +                showConnectCountryUseGeoIP = GetConfigValue("ShowConnectCountryUseGeoIP");
                     showDisconnectMessage = GetConfigValue("ShowDisconnectMessage");
                     showDisconnectReason = GetConfigValue("ShowDisconnectReason");
                     showAdminMessages = GetConfigValue("ShowAdminMessages");
                 }
                 catch (InvalidCastException)
    @@ -122,24 +129,40 @@
                 {
                     Broadcast("ConnectMessage", player.Name.Sanitize());
                     return;
                 }-            string apiUrl = "http://ip-api.com/json/";
    -
    -            webrequest.Enqueue(apiUrl + player.Address, null, (code, response) =>
    +            if (showConnectCountryUseGeoIP)
                 {
    -                if (code != 200 || response == null)
    +                if (!GeoIP)
                     {
    -                    Puts($"WebRequest to {apiUrl} failed, sending connect message without the country.");
    -                    Broadcast("ConnectMessage", player.Name.Sanitize());
    +                    Puts("GeoIP is not loaded! http://oxidemod.org/plugins/1365/");
                         return;
                     }-                string country = JsonConvert.DeserializeObject<Response>(response).Country;
    -                Broadcast("ConnectMessageCountry", player.Name.Sanitize(), country);
    -            }, this);
    +                var countryGeoIP = GeoIP.Call("GetCountry", player.Address.ToString());
    +
    +                Broadcast("ConnectMessageCountry", player.Name.Sanitize(), countryGeoIP);
    +            }
    +            else
    +            {
    +                string apiUrl = "http://ip-api.com/json/";
    +
    +                webrequest.Enqueue(apiUrl + player.Address, null, (code, response) =>
    +                {
    +                    if (code != 200 || response == null)
    +                    {
    +                        Puts($"WebRequest to {apiUrl} failed, sending connect message without the country.");
    +                        Broadcast("ConnectMessage", player.Name.Sanitize());
    +                        return;
    +                    }
    +
    +                    string country = JsonConvert.DeserializeObject<Response>(response).Country ?? "Unknown";
    +                    Broadcast("ConnectMessageCountry", player.Name.Sanitize(), country);
    +                }, this);
    +            }
    +
             }         private void OnUserDisconnected(IPlayer player, string reason)
             {
                 if (!showDisconnectMessage || (player.IsAdmin && !showAdminMessages))
    
     
  9. I cant seem to change the message that it is saying. Does anyone know how to do this?
     
  10. Wulf

    Wulf Community Admin

    Edit the oxide/lang file for it and reload the plugin.
     
  11. Did that, i even deleted it and re-added it. And it still keeps giving me the old "editted" one. i really cant seem to change it anymore. it looks like it is stuck on the one edit i once made
     
  12. After you edit lang file. Reload plugin if it doesn't help. Try restarting your server with your last editted lang file. If you're using some special chars save your lang file as UTF-8 format.
     
  13. Well tried that numurous times aswell. But that didnt work either. Lik i said i even deleted it. And when i put it bakc in it came back with the same msg as before :/
     
  14. Wulf

    Wulf Community Admin

    Could you upload the file here please? Upload, not paste.
     
  15. There you go
     
  16. Wulf

    Wulf Community Admin

    You don't edit the plugin, edit the oxide/lang messages.
     
  17. Figured it out when you said Lang File. I am new to this whole stuff. Thanks for helping me out in some way tho!
     
  18. Why did the editing of the Lang file have no change after reloading?
     
  19. That means you haven't change it on the right way,
    I do recommand to run it trough json validate The JSON Validator
    this gave your the error what isen't right about it
    when fixen that it should be working afther it
     
  20. I succeeded, and restarted the server and it took effect. It proves that reloading does not work.