1. @Mughisi - You Sir are a genius. I was clearly trying to re-invent the wheel. That makes complete sense. Just testing it now. Thanks for the input

    @Shiyoda - Thanks for the input, you seem to have removed some of the settings which remove the user defined variables at disconnect. These will stay in memory until server is restarted unless I am reading it wrong.

    Update to follow using simplified method of outputting JSON table entries from multiplelinemessage as per suggestion from @Mughisi
     
  2. @Loup-des-Neiges I've tried to reproduce your error and maybe it works now. Please make sure you have restarted your server. The error occurs if your server reloads the Plugin:
    Code:
    XX:XX AM/PM [Info] Loaded plugin User Connection Notification (v1.0.8) by Taffy
    Added "if (self.DisplayedWelcome[DName] ~= nil)":
    Code:
    function PLUGIN:OnPlayerDisconnected(ply,connection)
        DName = ( ply.displayName )
        if (ply.displayName and self.Config.ShowDisconnected) then
            allusermsg = (self.Config.AllUserMessageBye)
            allusermsg = allusermsg:gsub("USERNAME",DName)
            global.ConsoleSystem.Broadcast("chat.add \"" .. self.Config.ChatName .. "\" \"" .. allusermsg .. "\"")
        else return
        end
        if (self.DisplayedWelcome[DName] ~= nil) then
            self.DisplayedWelcome[DName] = nil
        end
    end
    Changed "if self.DisplayedWelcome[DName].DName ~= nil then" to "if self.DisplayedWelcome[DName] ~= nil then":
    Code:
    function PLUGIN:OnRunCommand( arg , ply , cmd )
        -- Sanity checks
        if (not arg) then return end
        if (not arg.connection) then return end
        if (not arg.connection.player) then return end
        if (not arg.cmd) then return end
        if (not arg.cmd.name) then return end
        local ply = arg.connection.player
        DName = ( ply.displayName )
        if (arg.cmd.name == "wakeup") then -- user has pressed the wake up button
            --print ("wakeup button pressed") 
            if self.DisplayedWelcome[DName] ~= nil then
                if self.DisplayedWelcome[DName].LineCompare > LineCount then
                    print ("error in calculation, linecompare is greater than linecount : " .. self.DisplayedWelcome[DName].LineCompare)
                else
                    while self.DisplayedWelcome[DName].LineCompare <= LineCount do
                        LineNo="Line" ..(self.DisplayedWelcome[DName].LineCompare)
                        usermsg = (self.Config.UserMessages[LineNo])
                        usermsg = usermsg:gsub("USERNAME",DName)
                        ply:SendConsoleCommand("chat.add \""..self.Config.ChatName.."\" \""..usermsg.."\"")  -- sends the message to the connecting player
                        self.DisplayedWelcome[DName].LineCompare = self.DisplayedWelcome[DName].LineCompare + 1
                    end
                end
            end
        end
    end
    [DOUBLEPOST=1414801650][/DOUBLEPOST]@Taffy If you find an other Solution it would be great. :) Added these lines back... my fault :D

    Lines:
    Code:
    if (self.DisplayedWelcome[DName] ~= nil) then
        self.DisplayedWelcome[DName] = nil
    end
     

    Attached Files:

    Last edited by a moderator: Nov 1, 2014
  3. Taffy updated Welcome Message and Notifications with a new update entry:

    Bugfix and restructure - Less variables to balls it all up

     
  4. 11:58 PM [Error] usernotification: [string "usernotification.lua"]:77: attempt to index global 'usermsg' (a nil value)
    at NLua.Lua.ThrowExceptionFromError (Int32 oldTop) [0x00000] in <filename unknown>:0
    at NLua.Lua.CallFunction (System.Object function, System.Object[] args, System.Type[] returnTypes) [0x00000] in <filename unknown>:0
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
     
  5. Post your config, might provide a clue
     
  6. {
    "ChatName": "SERVER",
    "ShowConnected": true,
    "AllUserMessage": "USERNAME has connected",
    "MultipleLineMessage": [
    "Hi USERNAME! Welcome to the server",
    "Enjoy you time with us."
    ],
    "ShowDisconnected": true,
    "AllUserMessageBye": "USERNAME has disconnected"
    }[DOUBLEPOST=1414883714][/DOUBLEPOST]It's just Default. I haven't changed anything at all.
     
  7. Weird. Unable to recreate myself. Edited config, deleted config, no issues. Is it happening all the time? Perhaps unload the plugin, delete the config and then reload.
     
  8. Oh god... You can make normal code?
    Why from config loaded only message, except chat prefix and settings?? New version baddest that prev, developero_O
     
  9. Way to provide constructive criticism! If you don't like it, don't use it!
     
  10. Im fixed this so quickly so you can drink cup of tea. Other users need the stable plugin, not this.
     
  11. Taffy updated Welcome Message and Notifications with a new update entry:

    Additions and bugfix

     
  12. Hey Taffy, great job on the update, not sure if this is allowed or if just set the way it is:

    1. The name SERVER cant be changed
    2. Where it says "USERNAME has connected" or "USERNAME has disconnected" anything inside of those fields can't be changed, is this the way its supposed to be or can this be changed?

    I deleted the old config and restarted the server, then made changes, saved and restarted again and in Rust it loads the default.

    Cheers
     
  13. Hi,

    1. The name seems to only work for broadcast messages like when someone disconnects or connects. Not found a way to change it for when just sending a chat message to an individual user. Are you saying its not taking the change at all or just when it shows the welcome message (broadcast)?
    2. You should be able to change any of the text in there mate. I will take another look at it sorry
     
  14. I changed it and it didnt pickup any of the changes I have just deleted it and placed the plugin back restarted, edited config, save, restarted and it doesnt pick up the new changes.

    Maybe I made a mistake:

    Code:
    {
      "AllUserMessageBye": "USERNAME has left this realm",
      "ChatName": "ALMIGHTY",
      "MultipleLineMessage": [
        "Gday USERNAME! No Griefing | Respect | Have Fun",
        "Commands",
        "/kit starter",
        "/location",
        "/remove"
      ],
      "ShowDisconnected": "true",
      "ShowWelcomeMessage": "true",
      "AllUserMessage": "USERNAME has joined this realm",
      "ShowConnected": "true"
    }
     
  15. All changeable -_-
    My code example:
    Code:
    function PLUGIN:SendMessage(prefix, message, target)
        message = UnityEngine.StringExtensions.QuoteSafe(message);    if (target) then
            target:SendConsoleCommand("chat.add \"" .. prefix .. "\""  .. message);
        else
            global.ConsoleSystem.Broadcast("chat.add \"" .. prefix .. "\""  .. message);
        end
    end
    
     
  16. Ummm kpoIIIkaeHo7

    Chat add? Whats that to do with notifications?
     
  17. Thanks, will take a look at implementing
    [DOUBLEPOST=1415120539][/DOUBLEPOST]
    Sorry, typo on code which would have effected the userconnect message. I will copy your config onto my server now and see how it goes
     
  18. This is interested ALMIGHTY says jf3000 is connected but then goes back to SERVER with the rest of the messages. Just says connected doesn't mention anything else :(