AFK

Kicks players that are AFK (away from keyboard) for too long

Total Downloads: 890 - First Release: May 20, 2016 - Last Update: Sep 5, 2016

5/5, 5 likes
  1. I've added Russian translation
    Code:
                // Russian
                lang.RegisterMessages(new Dictionary<string, string>
                {
                    ["KickedForAfk"] = "Если вы не начнёте выполнять какие-либо действия, вы будете кикнуты из-за AFK через {0} мин.",
                    //["NoLongerAfk"] = "Вы больше не в AFK",
                    //["YouWentAfk"] = "Вы вошли в режим AFK"
                }, this, "ru");
     
  2. How can I reference GrandExchange.cs while using AFK.cs to pay players for playing on server. I think that if I could insert a way to pay players that are not afk but are still on line at the time the AFK.cs checks for afk players, it would kill two birds with one stone.....get Gold for playing or get kicked for being afk as a result of a check that is already in place by the Plugin.
     
  3. Wulf

    Wulf Community Admin

    You'd need to write a plugin to links them both or add a check in GrandExchange to see if player IsAfk or not.
     
  4. what would a check look like. Here is how I think I am trying to add a message after your plugin checks for afk players.I realize without GrandExchange being linked the giveGold stuff would not work , but I cant even get a message to work.

    #region AFK Checking

    void OnUserConnected(IPlayer player) => AfkCheck(player);

    readonly Hash<string, GenericPosition> lastPosition = new Hash<string, GenericPosition>();
    readonly Dictionary<string, Timer> afkTimer = new Dictionary<string, Timer>();

    void AfkCheck(IPlayer player)
    {
    if (HasPermission(player.Id, permExcluded)) return;

    ResetPlayer(player.Id);
    lastPosition[player.Id] = player.Position();

    afkTimer.Add(player.Id, timer.Every(afkLimitMinutes * 60, () =>
    {
    if (!IsPlayerAfk(player));

    // (
    // PrintToChat("Payday!");
    // )

    // var (player) = !IsPlayerAfk(player));
    // var playerGold = _playerWallet[player.Id];
    // var goldAmount = (afkLimitMinutes * 60);
    // GiveGold(player,goldAmount);
    // // Notify everyone
    // PrintToChat(player, "[00FF00]" + goldAmount.ToString() + "[FFFF00] gold[FFFFFF] collected.");
    // PrintToChat(player, "[00FF00]" + Has not been AFK.");
    // PrintToChat("Payday!."));
    // player.Message(Lang("PayforPlay", player.Id));
    //
    // SaveTradeData();
    return;
    //else
    //player.Message(Lang("YouWentAfk", player.Id));

    if (kickAfkPlayers)
    {
    // TODO: Send timed message/warning to player before kick

    player.Kick(Lang("KickedForAfk", player.Id, afkLimitMinutes));
    }
    }));
    }
     
  5. Wulf

    Wulf Community Admin

    Don't add it to this plugin, just write a new plugin that calls this plugin and the other plugin. Keeps it cleaner. If you need help developing one, I'd suggest posting in the Reign of Kings Development section.
     
  6. I couldn't even get your plugin to send a message in chat when the plugin does a check someone is not AFK , chances of me writing a new plugin are pretty slim at this time. I am still trying to see how plugins work, maybe I should have asked the question differently and kept it simple. My goal is to be able to write plugins but I am still at the hacking up and dissecting everyone else's plugins to see how they work.

    I finally got it to send a message. I think it has something to do with posting in forums then things start working all of the sudden.....lol
     
  7. (21:54:24) | Failed to call hook 'OnServerInitialized' on plugin 'AFK v1.1.5' (NullReferenceException: )
     
  8. Wulf

    Wulf Community Admin

    Please check your logs for the full error.
     
  9. Code:
    (21:46:42) | Failed to run a 600.00 timer in 'AFK v1.1.5' (NullReferenceException: )
    (21:48:50) | Waiting for another application to stop using script: AFK
    (21:48:51) | Reload requested for plugin which is already loading: AFK
    (21:48:52) | AFK was compiled successfully in 2287ms
    (21:48:52) | Unloaded plugin AFK v1.1.5 by Wulf/lukespragg
    (21:48:52) | Loaded plugin AFK v1.1.5 by Wulf/lukespragg
    (21:48:52) | Failed to call hook 'OnServerInitialized' on plugin 'AFK v1.1.5' (NullReferenceException: )
    (22:07:53) | Protocol: 1956
    Build Version: 1142.92
    Build Date: Thursday, January 26, 2017 9:59:37 PM
    Unity Version: 5.4.2f2
    Changeset: 18566
    Branch: /main
    Oxide Version: 2.0.2994
     
  10. Wulf

    Wulf Community Admin

    That isn't the full error, could you upload your latest oxide/logs please?
     
  11. Code:
    21:46 [Error] Failed to run a 600.00 timer in 'AFK v1.1.5' (NullReferenceException: )
    21:46 [Stacktrace]   at (wrapper managed-to-native) UnityEngine.Component:get_transform ()
      at Oxide.Game.Rust.Libraries.Covalence.RustPlayer.Position () [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.IsPlayerAfk (IPlayer player) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK+<AfkCheck>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0
      at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00000] in <filename unknown>:0
    9:48 PM [Warning] Waiting for another application to stop using script: AFK
    21:48 [Debug] Reload requested for plugin which is already loading: AFK
    21:48 [Info] AFK was compiled successfully in 2287ms
    21:48 [Info] Unloaded plugin AFK v1.1.5 by Wulf/lukespragg
    21:48 [Info] Loaded plugin AFK v1.1.5 by Wulf/lukespragg
    21:48 [Error] Failed to call hook 'OnServerInitialized' on plugin 'AFK v1.1.5' (NullReferenceException: )
    21:48 [Stacktrace]   at (wrapper managed-to-native) UnityEngine.Component:get_transform ()
      at Oxide.Game.Rust.Libraries.Covalence.RustPlayer.Position () [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.AfkCheck (IPlayer player) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.OnServerInitialized () [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (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 
     
  12. Hello,

    this plugin is broken...
    Code:
    {
      "AfkLimitMinutes": 10,
      "KickAfkPlayers": true
    }
    Code:
    (16:25:02) | [Death Notes] Redsun a été déchiqueté par Tanki avec un(e) roquette à haute vélocitée
    (16:25:02) | Redsun[171417/76561198050287733] was killed by Tanki[714503/76561197984580089]
    Redsun has been kicked 1min after killed by me.

    oxide.version:
    Code:
     Protocol: 1975
    Build Version: 1191.73
    Build Date: Thursday, March 16, 2017 5:36:31 PM
    Unity Version: 5.4.2f2
    Changeset: 19742
    Branch: /main
    Oxide Version: 2.0.3149
    AFK 1.1.5 no modified.
     
  13. Wulf

    Wulf Community Admin

    If the player doesn't move within the amount of time set, they'd be kicked.
     
  14. Wulf time is set to 10 minutes and get kicked after 1 minute?

    and he move, so...
     
  15. Code:
    Failed to call hook 'OnUserDisconnected' on plugin 'AFK v1.1.5' (NullReferenceException: Object reference not set to an instance of an object)
      at Oxide.Plugins.AFK.OnUserDisconnected (IPlayer player) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.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
     
  16. @Wulf I just get this message while uploading the plugin on my server
    Code:
    Failed to call hook 'OnUserConnected' on plugin 'AFK v1.1.5' (NullReferenceException: Object reference not set to an instance of an object)
    (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)  at Oxide.Game.Hurtworld.Libraries.Player.Position (.PlayerSession session) [0x00000] in <filename unknown>:0
      at Oxide.Game.Hurtworld.Libraries.Covalence.HurtworldPlayer.Position () [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.AfkCheck (IPlayer player) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.OnUserConnected (IPlayer player) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.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 
    I've to say I'm using it on the Itemv2 server
     
  17. Wulf

    Wulf Community Admin

    Which Oxide build?
     
  18. oxide 2.0.3628 for 0.4.8.0 (85)
     
  19. Code:
    (12:02:53) | Failed to run a 600.00 timer in 'AFK v1.1.5' (NullReferenceException: )
      at (wrapper managed-to-native) UnityEngine.Component:get_transform ()
      at Oxide.Game.Rust.Libraries.Player.Position (.BasePlayer player) [0x00000] in <filename unknown>:0
      at Oxide.Game.Rust.Libraries.Covalence.RustPlayer.Position () [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK.IsPlayerAfk (IPlayer player) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.AFK+<AfkCheck>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0
      at Oxide.Core.Libraries.Timer+TimerInstance.FireCallback () [0x00000] in <filename unknown>:0
    Latest oxide
     
  20. This plugin keeps kicking me after a few seconds...I uninstalled the plugin and I keep getting kicked?? What the heck, how's that possible of I removed the plugin from the plugins folder?