Leveling system

Im making my own leveling system for a game mode im making and i need it so when you get 5 kills you go to lvl 2 30 kills you go to lvl 3 50 kills you go to lvl 4 and 100 kills you go to lvl 5 and if you get to lvl 5 you are the winner and the game mode restarts, how would i do that?

[lua]hook.Add(“PlayerInitialSpawn”, “SetLevel”, function( ply )
ply:SetNWInt(“level”, 1) – On first spawn, set players level to 1
end)

function Levels( ply )

local BestScore = 100 – Defining local variables for later use
local BestPlayer

for k,v in pairs( player.GetAll() ) do – Looping trough a table of all players where v is an individual player.
local Frags = v:Frags() – Getting a player’s frags

if Frags == BestScore then            		-- If it's higher then the current BestScore then
	BestPlayer = v:GetName()     			-- And make the player the new BestPlayer
end

end

if ply:Frags() => 5 then – If a players frags are equal to or greater than 5 then…

ply:SetNWInt("level", 2) 					-- Set his level to 2

elseif ply:Frags() == 30 then – And so on …

ply:SetNWInt("level", 3)

elseif ply:Frags() == 50 then

ply:SetNWInt("level", 4)

elseif ply:Frags() == 100 then

ply:SetNWInt("level", 5)
for k, v in pairs(player.GetAll()) do
	v:Freeze( true )
	v:ChatPrint("Player "..BestPlayer.." has won the game")
	-- Probably add a timer which changes the map here?
	end
end

end[/lua]

Untested, but should work.

[lua]
hook.Add(“PlayerInitialSpawn”, “SetLevel”, function( ply )
ply:SetNWInt(“lvl”, 1)
end)

local rounds = 3

local function PlayerDie(Vic, Inf, Kil)
if(Kil:Frags() == 5) then
Kil:SetNWInt(“lvl”, 2)
elseif(Kil:Frags() == 30) then
Kil:SetNWInt(“lvl”, 3)
elseif(Kil:Frags() == 50) then
Kil:SetNWInt(“lvl”, 4)
elseif(Kil:Frags() == 100) then
Kil:SetNWInt(“lvl”, 5)
RoundEnd(Kil)
end
end
hook.Add(“PlayerDie”, “LevelSystemDeath”, PlayerDie)
local function RoundEnd(ply)
rounds = rounds - 1

for k, v in pairs(player.GetAll()) do 
	v:Lock()
	v:ChatPrint("Player "..ply:Nick().." has won the game")  
end

if(rounds == 0) then
	timer.Simple(10, function()
		RunConsoleCommand("changelevel", "gm_construct") -- Make your own rotation system
	end)
else
	timer.Simple(2, function()
		RoundRestart()
	end)
end

end

local function RoundRestart()
game.CleanUpMap()
for k, v in pairs(player.GetAll()) do
v:Spawn()
v:SetFrags(0)
v:SetDeaths(0)
v:ChatPrint(“New round in 5 seconds”)
end

timer.Simple(5, function()
	for k, v in pairs(player.GetAll)) do
		v:UnLock()
	end
end)

end
[/lua]

That will actually work, but yet again it is untested

Looks like your not since you just got all the code

This will work better than mine, but only because I typed mine in like 1 minute, after all, i’m not gonna script this guys gamemode

I did it in about 2, btw the function levels doesnt get called and your if is wrong

Fixed

I doubt you’re THAT good at lua.

It didnt work anyway and it was clearly like 10 mins or so because he had to find some other code to C&P

Why?

And Flawless, please, stop thinking you are better than everyone else seriously, okay, i’m not very good at lua, but i’m trying to help.

Just ignore Flawless, and its not that much code and if you’ve done anything like that it’s not that hard to type it in a minute.

-snip-

I need no reason.

This seems more like you.

How about we stop raging? :smiley:

NEVER! This is facepunch you have to rage apparently.

-snip-

We only have to rage because King Flawless always starts a ragefest on his first post in a thread

Holy shit how about you all stop trying to prove who’s e-dick is bigger.
You gave the guy some code, works or not it is still a basic understanding for him to learn from, if it doesn’t work then good it will hopefully force him to try and fix it himself.

And King Flawless, you’re not better than these guys, you’re probably at the same level as OP.

NETWORKED INT’s!!! :derp:

I simply edited the guy i forgots code :c