I’m attempting to create a level/xp system for DarkRP. What I have so far in my script is working fine. I’m just having troubles with a serverside function.
I would like to make it so this function is always running, so it can check the next set of player experience needed.
The code works fine as a command, but I’m not quite sure on how to make this always running.
function LevelUp ( ply ) if ply:GetLevel() == 1 then ply:SetPData("xpneeded", CIV_LEVEL_ONE_REQUIRED) else if ply:GetLevel() == 2 then ply:SetPData("xpneeded", CIV_LEVEL_TWO_REQUIRED) else return"" end end end
Is there some sort of hook I can use?
I also tried to used a timer
timer.Create( "LevelCheck", 1, 0, LevelUp)
but I was given an error of
[ERROR] addons/darkrpmodification/lua/darkrp_modules/levelsystem/sv_levelsystem.lua:38: attempt to index global 'ply' (a nil value) 1. unknown - addons/darkrpmodification/lua/darkrp_modules/levelsystem/sv_levelsystem.lua:38 Timer Failed! [LevelCheck][@addons/darkrpmodification/lua/darkrp_modules/levelsystem/sv_levelsystem.lua (line 48)]