Hello im making a gmod gun game gamemode it is working, but when someone wins, example me, it respawns me and gives me the first gun again, but doesnt for my friend, but it also does it for bots as well, help please.
else if (p1:GetNWInt('level') == 30) then
p1:StripWeapon( "m9k_svu" )
PrintMessage( HUD_PRINTTALK, attacker:Name() .. " has won, starting a new round...")
for k, v in pairs( player.GetAll() ) do
v:StripWeapons()
v:SetNWInt('level', 0)
v:Spawn()
v:sleep(3)
v:Give( "tfa_luger" )
v:GiveAmmo( 969, "357" )
What is PLAYER:sleep(n)? And where are "end" keywords?
just ignore the sleep thing i got rid of that and my ends are there
CODE:
[url]http://pastebin.com/YNF25eRc[/url]
[editline]31st May 2015[/editline]
is there anything wrong with it?
As far as I know, weapons should be given in this hook [url]http://wiki.garrysmod.com/page/GM/PlayerLoadout[/url]
yes thats fine, its the:
for k, v in pairs( player.GetAll() ) do
v:StripWeapons()
v:SetNWInt('level', 0)
v:Spawn()
v:Give( "tfa_luger" )
v:GiveAmmo( 969, "357" )
end
lines thats the issue
I don't know what level addon you're using but mine doesn't use "v:SetNWInt('level', 0)" instead it uses v:getDarkRPVar("level") and v:setDarkRPVar("level", 0) so it could be
for k, v in pairs( player.GetAll() ) do
v:StripWeapons()
v:setDarkRPVar("level", 0)
v:Spawn()
v:Give( "tfa_luger" )
v:GiveAmmo( 969, "357" )
end
But I don't know which one you're using.
this isn dark rp or an addon its in my gamemodes init lua file
Not reading all of your code because it's not tabbed and I cba.. but at a glance, you have way too many [i]end[/i]s
see below for how if conditions work; it doesn't matter how many [i]elseif[/i]s you use, you'll only need to use 1 [i]end[/i] that closes off the initial [i]if[/i]
[lua]
if <condition> then
-- do stuff
elseif <condition> then
-- do other stuff
else
-- do other other stuff
end
[/lua]
well in notepad++ there are squares on the left showing which line of code need an end and all of the else ifs have a square, anyway, none of the answers are answering my question, everything works up until I get to the last level, i get a kill and it resets everyone like it should do, but only resets bots and me, anyone else, then it doesnt reset them.
Also consider using a table of levels and a for loop instead of 40+ elseifs.
[QUOTE=mattymoo142;47846216]well in notepad++ there are squares on the left showing which line of code need an end and all of the else ifs have a square, anyway, none of the answers are answering my question, everything works up until I get to the last level, i get a kill and it resets everyone like it should do, but only resets bots and me, anyone else, then it doesnt reset them.[/QUOTE]
Yes, you can ignore advice you are given, up to you I suppose.
Good luck fixing your problem.
Sorry, you need to Log In to post a reply to this thread.