PaiN submitted a new resource:
AFK System - Simple "Away From Keyboard" System
Read more about this resource...

PaiN AFK
Simple "Away From Keyboard" system
Total Downloads: 905 - First Release: Apr 21, 2015 - Last Update: Jul 4, 2016
- 5/5, 3 likes
-
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
-
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
Thanks btw. -
PaiN updated AFK System with a new update entry:
Some changes
-
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
-
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 -
-
PaiN updated AFK System with a new update entry:
Updater Support
-
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.
-
Like if u hit him it says "Player xxx is afk" ???
EDIT: I got it srygive me some time i will look into it
Last edited by a moderator: May 17, 2015 -
i mean if someon write "NAME what u do" than the msg come PLAYER XXXX is still afk
-
PaiN updated AFK System with a new update entry:
Added some new functions
-
PaiN updated AFK System with a new update entry:
Plugin Rename
-
PaiN updated PaiN AFK with a new update entry:
Forgot to change plugin version SORRY
-
if you go afk do your items continue to craft?
-
Wulf Community Admin
-
o ok ty
-
-
Wulf Community Admin
-
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?