Adding custom hook help

So i use the Free DarkRP leveling system http://steamcommunity.com/sharedfiles/filedetails/?id=270216963

What I am trying to do is create a hook or function that when a player goes afk they wont earn exp. I dont know much of lua but I think I might be on the right track. If the hook is right do i need to define one for if they leave afk? Also where would i need to add the hook at?
Thanks for any help provided!


local function StartAFKOnPlayer(ply)
	LevelSystemConfiguration.Timertime = 300
end
hook.Add("PlayerInitialSpawn", "StartAFKOnPlayer", StartAFKOnPlayer)

[editline]23rd July 2014[/editline]

Or would it be more along the lines of this. I have no idea what the difference is between the two.


if ply.DarkRPVars.AFK then
                LevelSystemConfiguration.Timertime = 0
        else
                LevelSystemConfiguration.Timetime = 300
end
end

Sorry about that, Ive never used facepunch before. Im kinda new to all this

This tag ----> [“CODE][/CODE”](without ") can make magic. Seriously can you use the code tags or lua tags?

Just as a note for the future, you can put unparsed tags with [noparse][noparse][/noparse].

[noparse]




[/noparse]



if ply.DarkRPVars.AFK then
LevelSystemConfiguration.Timertime = 0
else
LevelSystemConfiguration.Timetime = 300
end
end




local function StartAFKOnPlayer(ply)
LevelSystemConfiguration.Timertime = 300
end
hook.Add("PlayerInitialSpawn", "StartAFKOnPlayer", StartAFKOnPlayer)


Any idea if im on the right track? And sorry about the code box. I didnt know how to do that. I will note it for future reference :slight_smile: