maxafktime = 45
maxafkkicktime = 300
ulib = 0
--Also you can't get kicked if it is listen server and your host.
--Originally for SAM
--SAM REDO STARTED
t58 = {}
if ulib == 1 then
assert( _file.Exists( "lua/ULib/init.lua" ), "Optional Ulib support needs Ulib *duh*" )
_OpenScript( "ULib/init.lua" )
assert( ULib.VERSION >= 1, "AFK Mod requires 1.0 +" )
local ucl = ULib.mainUcl
end
function t58.createSVar( svarname , var )
t58[svarname] = {}
t58[svarname].var = var
end
function t58.svar( svarname )
local svartemp = t58[svarname].var
return svartemp
end
--SAM REDO ENDED
t58.createSVar( "maxafktime" , maxafktime ); --Svars measured in seconds
t58.createSVar( "maxafkkicktime" , maxafkkicktime ); --5 Minutes
afkon = true
afk = {}
for i=1, _MaxPlayers() do
afk[i] = {};
afk[i].time = 0
afk[i].active = 0
afk[i].run = 0 --Made for my rule display, feel free to use it in any of yours
end
--Thanks to foszor!
--http://gmod.foszor.com/luabin/?snip=2
nextthink = 0;
function afkthinktimer()
if ( _CurTime() < nextthink ) then return; end
nextthink = nextthink + 1; --Don't get the guys FPS involved
afk.tick()
end
AddThinkFunction( afkthinktimer );
function afk.tick()
for i=1, _MaxPlayers() do
afk[i].time = afk[i].time +1
if afk[i].time == t58.svar("maxafktime") then -- It equals it
afk[i].active = 1 --3rd Party mod support. Read it I'm nice lol make sure to do a nil check to make sure the script is on.
afk.initgui(i) -- No more flashy screen
afk.gui(i) --They need that one secound.
elseif afk[i].time >= t58.svar("maxafktime") then -- What will most likely happen
afk.gui(i) -- Call de GUI!
if afk[i].time >= t58.svar("maxafkkicktime") then --Eeek hes gonna get kicked!
afk.kick(i) -- WHY JUDGE WHY!
end end end end
function afk.kick(Client)
if ulib == 0 then
if ( not _IsDedicatedServer() ) then
if Client >= 1 then
_ServerCommand("kickid ".._PlayerInfo(Client,"networkid").."\n")
end
if ulib == 1 then
if ucl:query( Client, ACCESS_IMMUNITY ) == false then
_ServerCommand("kickid ".._PlayerInfo(Client,"networkid").."\n")
end
end
end
end
end
function afk.initgui(Client)
_GModRect_Start("gmod/white")
_GModRect_SetPos(0, 0, 1, 1)
_GModRect_SetColor(52, 52, 52, 200)
_GModRect_SetTime(99999, 0, 0)
_GModRect_Send(Client,1005)
_GModText_Start("TargetID");
_GModText_SetEntityOffset(vector3(0,0,50))
_GModText_SetEntity(Client)
_GModText_SetColor(000, 180, 255, 255)
_GModText_SetTime(99999,1,1);
_GModText_SetText("AFK");
_GModText_Send(0, 1006+Client);
end
function afk.gui(Client)
_GModText_Start("ImpactMassive")
_GModText_SetPos(0.40 , 0.45)
_GModText_SetColor(000, 180, 255, 255)
_GModText_SetTime(99999, 0, 0)
_GModText_SetText("You have been afk for "..afk[Client].time.." seconds.")
_GModText_AllowOffscreen( false );
_GModText_Send(Client,1004)
end
function afk.zip(Client)
afk[Client].time = 0
if afk[Client].active == 1 then
afk[Client].active = 0
_GModRect_Hide(Client,1005,1,0);
_GModText_Hide(Client,1004);
_GModText_Hide(Client,1006+Client);
end
end
HookEvent("eventKeyPressed",afk.zip)
I can't find anything on Main UCL in the file besides
ULib.mainUcl = ULib.ucl:newFromFile( ULib.DEFAULT_UCL_FILE )