PaiN AFK

Simple "Away From Keyboard" system

Total Downloads: 905 - First Release: Apr 21, 2015 - Last Update: Jul 4, 2016

5/5, 3 likes
  1. PaiN submitted a new resource:

    AFK System - Simple "Away From Keyboard" System

    Read more about this resource...
     
  2. Wulf

    Wulf Community Admin

    Some improvements and recommendations:
    Code:
    PLUGIN.Title        = "AFK System"
    PLUGIN.Description  = "Basic command-based AFK system."
    PLUGIN.Author       = "Merka"
    PLUGIN.Version      = V(1, 0, 0)local afkData = {}function PLUGIN:LoadDefaultConfig()
        self.Config.Messages = self.Config.Messages or {}
        self.Config.Messages.IsAfk = self.Config.Messages.IsAfk or "{player} went AFK"
        self.Config.Messages.IsNotAfk = self.Config.Messages.IsNotAfk or "{player} is no longer AFK"
        self:SaveConfig()
    endfunction PLUGIN:Init()
        command.AddChatCommand("afk", self.Plugin, "cmdAfk")
        afkData = datafile.GetDataTable("afksystem")
        self:LoadDefaultConfig()
    endfunction PLUGIN:cmdAfk(player)
        local userId = rust.UserIDFromPlayer(player)
        if afkData[userId] then
            afkData[userId] = nil
            local message = string.gsub(self.Config.Messages.IsNotAfk, "{player}", player.displayName)
            rust.BroadcastChat(message)
            player:EndSleeping()
        else
            afkData[userId] = true
            local message = string.gsub(self.Config.Messages.IsAfk, "{player}", player.displayName)
            rust.BroadcastChat(message)
            player:StartSleeping()
        end
        datafile.SaveDataTable("afksystem")
    end
     
  3. Yeah u are right but i want writing this plugin with my "brain"
    didnt know that there was "player:EndSleeping()"

    Good that you've changed my messages bcs my english is not so good :/
    I didnt think about that :p
    Thanks btw.
     
  4. PaiN updated AFK System with a new update entry:

    Some changes

     
  5. You should consider handling the message of a player coming back from being afk differently because you are unable to type when you are sleeping so basically the player has to wake up first which is already sign of the player not being afk anymore so you could easily capture this with the hook that was added for this purpose. You might want to have a look at http://oxidemod.org/threads/make-players-sleep-lua.7435/page-2.
    Code:
    OnPlayerSleepEnded(BasePlayer player)
     - Called from BasePlayer.EndSleeping()
     - No return behavior
     - Called when a player awakes
     
  6. xD man useless post bcs Wulf recommended me to do these things :) i'm using OnPlayerSleepEnded it looks like
    Code:
    function PLUGIN:OnPlayerSleepEnded(player)
        local userID = rust.UserIDFromPlayer(player)
        local message = string.gsub(self.Config.Messages.IsNotAfk, "{player}", self.Config.Settings.PluginPrefix.." "..player.displayName)
        if afkData[userID] then
        rust.BroadcastChat(message)
        afkData[userID] = nil
        end
    end
    
     
    Last edited by a moderator: Mar 8, 2016
  7. Doesn't take away that you don't need 5 lines from inside the afk command function :)
     
  8. Could you be so kind and add a feature if a Players Name is written the System says "Player XXX is afk" ? If its possible.
     
  9. Give me an example please
    Like if u hit him it says "Player xxx is afk" ???

    EDIT: I got it sry :p give me some time i will look into it
     
    Last edited by a moderator: May 17, 2015
  10. i mean if someon write "NAME what u do" than the msg come PLAYER XXXX is still afk
     
  11. PaiN updated AFK System with a new update entry:

    Added some new functions

     
  12. PaiN updated AFK System with a new update entry:

    Plugin Rename

     
  13. if you go afk do your items continue to craft?
     
  14. Wulf

    Wulf Community Admin

    It puts the player asleep, so doubt it.
     
  15. you can craft while afk, you cannot craft while in /afk - there's a difference.
     
  16. Wulf

    Wulf Community Admin

    Yes, but in regards to this plugin, you can't. I believe the question was regarding this plugin.
     
  17. That was be cool if that plugin kicked players who does'nt type /afk after 5 or more minutes they left the computer.
    (sorry for my English, I speak Ukrainian every day) ))
    isn't on this site plugin like this? but which can kick afk players by time?