Hello, I cannot seem to get my table to work:
It just respawns me, which to me seems like it doesnt add 1 to level and just runs if (level == #WepList)
function GM:PlayerDeath(attacker)
local WepList = {
{
'tfa_luger',
'tfa_deagle',
'weapon_three',
'tfa_ragingbull',
'tfa_glock',
'tfa_colt1911',
'tfa_hk45',
'tfa_sig_p229r',
'tfa_mp5',
'tfa_bizonp19',
'tfa_kac_pdw',
'tfa_magpulpdr',
'tfa_mp5sd',
'tfa_honeybadger',
'tfa_mp9',
'tfa_bf4_ak5c',
'tfa_bf4_asval',
'tfa_bf4_aek971',
'tfa_bf4_ak12',
'tfa_vector',
'tfa_bf4_338',
'tfa_mp7',
'm9k_dragunov',
'm9k_intervention',
'm9k_m24',
'm9k_barret_m82',
'm9k_aw50',
'm9k_sl8',
'm9k_svt40',
'm9k_svu',
'm9k_spas12',
'm9k_usas',
'm9k_remington870',
'm9k_remington7615p',
'm9k_m249lmg',
'm9k_pkm',
'm9k_dbarrel',
'm9k_1887winchester',
'm9k_1897winchester',
'm9k_ares_shrike'
}
}
if (level == #WepList) then
for k, v in pairs( player.GetAll() ) do
v:StripWeapons()
v:SetNWFloat('level', 1)
v:Spawn()
return
end
local level = attacker:GetNWFloat('level',1)
attacker:StripWeapon(WepList[level])
attacker:Give(WepList[level+1])
attacker:GiveAmmo(weapons.Get(WepList[level+1]).Primary.Ammo)
level = attacker:SetNWFloat ('level', attacker:GetNWFloat ('level') + 1)
end
end
You have a table inside table, so #WepList will return 1 in your case.
What you want is more or less something like this:
[code]
function GM:PlayerDeath(attacker)
local WepList = {
'tfa_luger',
'tfa_deagle',
'weapon_three',
'tfa_ragingbull',
'tfa_glock',
'tfa_colt1911',
'tfa_hk45',
'tfa_sig_p229r',
'tfa_mp5',
'tfa_bizonp19',
'tfa_kac_pdw',
'tfa_magpulpdr',
'tfa_mp5sd',
'tfa_honeybadger',
'tfa_mp9',
'tfa_bf4_ak5c',
'tfa_bf4_asval',
'tfa_bf4_aek971',
'tfa_bf4_ak12',
'tfa_vector',
'tfa_bf4_338',
'tfa_mp7',
'm9k_dragunov',
'm9k_intervention',
'm9k_m24',
'm9k_barret_m82',
'm9k_aw50',
'm9k_sl8',
'm9k_svt40',
'm9k_svu',
'm9k_spas12',
'm9k_usas',
'm9k_remington870',
'm9k_remington7615p',
'm9k_m249lmg',
'm9k_pkm',
'm9k_dbarrel',
'm9k_1887winchester',
'm9k_1897winchester',
'm9k_ares_shrike'
}
if ( level == #WepList ) then
for k, v in pairs( player.GetAll() ) do
v:StripWeapons()
v:SetNWFloat( 'level', 1 )
v:Spawn()
return
end
local level = attacker:GetNWFloat('level',1)
attacker:StripWeapon(WepList[level])
attacker:Give(WepList[level+1])
attacker:GiveAmmo(weapons.Get(WepList[level+1]).Primary.Ammo)
level = attacker:SetNWFloat ('level', attacker:GetNWFloat ('level') + 1)
end
end[/code]
[QUOTE=Robotboy655;47879282]You have a table inside table, so #WepList will return 1 in your case.
What you want is more or less something like this:
[code]
function GM:PlayerDeath(attacker)
local WepList = {
'tfa_luger',
'tfa_deagle',
'weapon_three',
'tfa_ragingbull',
'tfa_glock',
'tfa_colt1911',
'tfa_hk45',
'tfa_sig_p229r',
'tfa_mp5',
'tfa_bizonp19',
'tfa_kac_pdw',
'tfa_magpulpdr',
'tfa_mp5sd',
'tfa_honeybadger',
'tfa_mp9',
'tfa_bf4_ak5c',
'tfa_bf4_asval',
'tfa_bf4_aek971',
'tfa_bf4_ak12',
'tfa_vector',
'tfa_bf4_338',
'tfa_mp7',
'm9k_dragunov',
'm9k_intervention',
'm9k_m24',
'm9k_barret_m82',
'm9k_aw50',
'm9k_sl8',
'm9k_svt40',
'm9k_svu',
'm9k_spas12',
'm9k_usas',
'm9k_remington870',
'm9k_remington7615p',
'm9k_m249lmg',
'm9k_pkm',
'm9k_dbarrel',
'm9k_1887winchester',
'm9k_1897winchester',
'm9k_ares_shrike'
}
if ( level == #WepList ) then
for k, v in pairs( player.GetAll() ) do
v:StripWeapons()
v:SetNWFloat( 'level', 1 )
v:Spawn()
return
end
local level = attacker:GetNWFloat('level',1)
attacker:StripWeapon(WepList[level])
attacker:Give(WepList[level+1])
attacker:GiveAmmo(weapons.Get(WepList[level+1]).Primary.Ammo)
level = attacker:SetNWFloat ('level', attacker:GetNWFloat ('level') + 1)
end
end[/code][/QUOTE]
Thank you so much! I see now
Sorry, you need to Log In to post a reply to this thread.