Experience Script?

Hello, can someone help me because I am not very good at LUA and I can’t find a tutorial. I was wondering how to write a script that gives you a certain amount of XP every 2 minutes or so and how I can use that XP to make a leveling system. The leveling system would then be used to allow higher levels into teams (1, 2, 3). I read the tutorial http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index94c7.html over and over. It seems like this can be made into a leveling system but I don’t know how. Help would be greatly appreciated. Thank you.

I would advice to do more simple stuff before beginning with this, make a few tools and scripted entities for example.

I have been doing simple stuff but I am really stuck when I get to this

Where are you stuck, did you make the file structure?


 -- Level Start

 -- The Level Your Charactor Starts On
 LEVEL_STARTAMOUNT = 1 -- Can be changed to your starting level
 function FirstSpawn ( ply )
	local level = play:GetPData("level") --- Get the saved level
	if level == nil then --If it doesn't exist set the player to the starting level
		ply:SetPData("level", LEVEL_STARTAMOUNT) -- Save It
		ply:SetLevel( Level_STARTAMOUNT ) -- Set it to the networked ints that can be called from the client too
	ply:SetLevel( level ) -- If not, set the netwroked ints to what we last saved
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", FirstSpawn )

function PrintLevel( ply )
	ply:ChatPrint("Your Level is: " .. ply:GetLevel())
function fPlayerDisconnect( ply )
	print("Player Disconnect: Level saved to SQLLite and TXT")


-- Start Level Fucntions

function meta:AddLevel(amount)
	local current_level = self:GetLevel()
	self:SetLevel( current_level + amount )
function meta:SetLevel(amount)
	self:SetNetworkedInt( "Level", amount )
function meta:SaveLevel()
	local level = self:GetLevel()
	self:SetPData("level", level)
function meta:SaveLevelTXT()
	file.Write(gmod.GetGamemode().Name .."/Level/".. string.gsub(self:SteamID(), ":", "_") ..".txt", self:GetLevelString())
function meta:TakeLevel(amount)
   --Add level function here
function meta:GetLevel()
	return self:GetNetworkedInt( "Level" )

What im stuck at is how do I make it that you gain xp and how you make it so each level requires more XP. Then I want to learn how to intergrate it with entities so you can only buy entities if your a certain level. same with teams

Do a check when they gain exp to see if their experience is greater than their current level * 10000 or something similar, if it is, increment their level. Do experience in whichever way you need to, if you wanted to have people earn experience by killing other players, just hook into PlayerDeath.

Add me on steam if you need help with the code.

is there anyway that I could make it so the player only gain points by killing certain teams? for instance if they kill the red team they loose points but if they kill the orange team they gain points?