Little help?

Well I have been trying to get this to work, no idea why it will not because I don’t get any errors in the console (relating to it)

This is in my shared.lua

[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() == 10) then
Kil:SetNWInt(“lvl”, 3)
elseif(Kil:Frags() == 15) then
Kil:SetNWInt(“lvl”, 4)
elseif(Kil:Frags() == 20) then
Kil:SetNWInt(“lvl”, 5)
RoundEnd(Kil)
end
end
hook.Add(“PlayerDie”, “LevelSystemDeath”, PlayerDie)
hook.Add(“PlayerDie”, “LevelSystemWeapon”, Loadout)

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

function Loadout(ply)
level = ply:GetNWInt(“lvl”)
if (level == 1) then
ply:StripWeapons()
ply:Give(“AlphaKnife”)
Msg(“Level 1”)
elseif(level == 2) then
ply:StripWeapons()
ply:Give(“DemonKnife”)
Msg(“Level 2”)
elseif(level == 3) then
ply:StripWeapons()
ply:Give(“FireKnife”)
Msg(“Level 3”)
elseif(level == 4) then
ply:StripWeapons()
ply:Give(“LightningKnife”)
Msg(“Level 4”)
elseif(level == 5) then
ply:StripWeapons()
ply:Give(“OmegaCrowbar”)
Msg(“Level 5”)
end
end[/lua]

What exactly isn’t it doing?

[editline]06:11PM[/editline]

Put it all in init.lua

Well it isn’t stripping weapons and giving the knives after a player dies.

Nope putting it in the init.lua doesnt work

Instead of doing
[lua]if ( level == 1 )[/lua]

Try
[lua]if level == 1[/lua]

[editline]06:28PM[/editline]

Wait, do this for the loadout function

[lua]function GM:PlayerLoadout(ply)[/lua]

Wakeboarder, that will make no difference whatsoever.

[editline]11:29PM[/editline]

Are you sure all those knife weapons even exist?

They are here [GAMEMODENAME]/entities/weapons/[knife names]

But should it not still strip the weapons even if they didn’t exist?

Try putting all the hook.Adds to the bottom of the file.

That made no difference

Anyone?

[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() == 10 then
Kil:SetNWInt(“lvl”, 3)
elseif Kil:Frags() == 15 then
Kil:SetNWInt(“lvl”, 4)
elseif Kil:Frags() == 20 then
Kil:SetNWInt(“lvl”, 5)
RoundEnd(Kil)
end
end
hook.Add(“PlayerDeath”, “LevelSystemDeath”, PlayerDie)
hook.Add(“PlayerDeath”, “LevelSystemWeapon”, Loadout)

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

function Loadout(ply)
level = ply:GetNWInt(“lvl”)
if level == 1 then
ply:StripWeapons()
ply:Give(“AlphaKnife”)
Msg(“Level 1”)
elseif level == 2 then
ply:StripWeapons()
ply:Give(“DemonKnife”)
Msg(“Level 2”)
elseif level == 3 then
ply:StripWeapons()
ply:Give(“FireKnife”)
Msg(“Level 3”)
elseif level == 4 then
ply:StripWeapons()
ply:Give(“LightningKnife”)
Msg(“Level 4”)
elseif level == 5 then
ply:StripWeapons()
ply:Give(“OmegaCrowbar”)
Msg(“Level 5”)
end
end
[/lua]
Try that, death function was being called by “playerdie” which doesn’t exist.

you know the weapons you have told it to give them in GM:PlayerLoadout, are those the ACTUAL names of the weapons? because usually it’s something like


weapon_<weaponname>

or


<customtag>_<weaponname>

They are sweps that have been added in the gamemodes weapons folder

Sorry KennyB it still does not work. :’(

Are you sure you have the correct weapon names?

The reason you aren’t being given weapons is because you have not hooked “PlayerLoadout” anywhere.

Use this instead of your “Loadout” function:

[lua] function GM:PlayerLoadout(ply)
level = ply:GetNWInt(“lvl”)
if level == 1 then
ply:StripWeapons()
ply:Give(“AlphaKnife”)
Msg(“Level 1”)
elseif level == 2 then
ply:StripWeapons()
ply:Give(“DemonKnife”)
Msg(“Level 2”)
elseif level == 3 then
ply:StripWeapons()
ply:Give(“FireKnife”)
Msg(“Level 3”)
elseif level == 4 then
ply:StripWeapons()
ply:Give(“LightningKnife”)
Msg(“Level 4”)
elseif level == 5 then
ply:StripWeapons()
ply:Give(“OmegaCrowbar”)
Msg(“Level 5”)
end
end [/lua]

EDIT:

Ah hang on, I see you’ve used hook.Add for the Loadout function, just do

[lua]hook.Add(“PlayerLoadout”, “blargh”, Loadout)[/lua]

So it should be:

[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() == 10 then
Kil:SetNWInt(“lvl”, 3)
elseif Kil:Frags() == 15 then
Kil:SetNWInt(“lvl”, 4)
elseif Kil:Frags() == 20 then
Kil:SetNWInt(“lvl”, 5)
RoundEnd(Kil)
end
end
hook.Add(“PlayerDeath”, “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

function Loadout(ply)
level = ply:GetNWInt(“lvl”)
if level == 1 then
ply:StripWeapons()
ply:Give(“AlphaKnife”)
Msg(“Level 1”)
elseif level == 2 then
ply:StripWeapons()
ply:Give(“DemonKnife”)
Msg(“Level 2”)
elseif level == 3 then
ply:StripWeapons()
ply:Give(“FireKnife”)
Msg(“Level 3”)
elseif level == 4 then
ply:StripWeapons()
ply:Give(“LightningKnife”)
Msg(“Level 4”)
elseif level == 5 then
ply:StripWeapons()
ply:Give(“OmegaCrowbar”)
Msg(“Level 5”)
end
end
hook.Add(“PlayerDeath”, “LevelSystemWeapon”, Loadout)
hook.Add(“PlayerLoadout”, “OurLoadout”, Loadout)[/lua]

Thankyou very much for your help, it gives me the weapons now.

It gives me the weapon when I spawn but it will not strip my weapons so I still have the base guns. It also only gets my level after I die and gives me the next weapon when I respawn.

Though I presume these are problems with the player death hooks.

Well, if you didnt hook it, it would override = not give you any other weapons than that.

Okay! So I have got it to give me the different knives when I kill 5-10-15 ect but, when I get killed I respawn with the right knife but strip weapons will not work and I get the base guns aswell.

[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() == 10 then
Kil:SetNWInt(“lvl”, 3)
elseif Kil:Frags() == 15 then
Kil:SetNWInt(“lvl”, 4)
elseif Kil:Frags() == 20 then
Kil:SetNWInt(“lvl”, 5)
RoundEnd(Kil)
end
end
hook.Add(“PlayerDeath”, “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")
	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

function Loadout( victim, weapon, killer )
level = killer:GetNWInt(“lvl”)
if level == 1 then
killer:StripWeapons()
killer:Give(“AlphaKnife”)
Msg(“Level 1”)
elseif level == 2 then
killer:StripWeapons()
killer:Give(“DemonKnife”)
Msg(“Level 2”)
elseif level == 3 then
killer:StripWeapons()
killer:Give(“FireKnife”)
Msg(“Level 3”)
elseif level == 4 then
killer:StripWeapons()
killer:Give(“LightningKnife”)
Msg(“Level 4”)
elseif level == 5 then
killer:StripWeapons()
killer:Give(“OmegaCrowbar”)
Msg(“Level 5”)
end
end

function spawn(ply)
level = ply:GetNWInt(“lvl”)
if level == 1 then
ply:StripWeapons()
ply:Give(“AlphaKnife”)
Msg("Level 1
")
elseif level == 2 then
ply:StripWeapons()
ply:Give(“DemonKnife”)
Msg("Level 2
")
elseif level == 3 then
ply:StripWeapons()
ply:Give(“FireKnife”)
Msg("Level 3
")
elseif level == 4 then
ply:StripWeapons()
ply:Give(“LightningKnife”)
Msg("Level 4
")
elseif level == 5 then
ply:StripWeapons()
ply:Give(“OmegaCrowbar”)
Msg("Level 5
")
end
end

hook.Add(“PlayerDeath”, “LevelSystemWeapon”, Loadout)
hook.Add(“PlayerSpawn”,“Respawn”, spawn)[/lua]

Look at my post.

Please explain, this is my first attempt at a gamemode and lua.

[lua]function PlayerSpawn(ply)
level = ply:GetNWInt(“lvl”)
if level == 1 then
ply:StripWeapons()
ply:Give(“AlphaKnife”)
Msg("Level 1
")
elseif level == 2 then
ply:StripWeapons()
ply:Give(“DemonKnife”)
Msg("Level 2
")
elseif level == 3 then
ply:StripWeapons()
ply:Give(“FireKnife”)
Msg("Level 3
")
elseif level == 4 then
ply:StripWeapons()
ply:Give(“LightningKnife”)
Msg("Level 4
")
elseif level == 5 then
ply:StripWeapons()
ply:Give(“OmegaCrowbar”)
Msg("Level 5
")
end
end
[/lua]

Nope, that stops the gamemode from working.