Hello I have this code:
[url]http://pastebin.com/8pT763aq[/url]
So, on spawn I get a kill, then it gives me a deagle and ammo as it should do, but when I get a kill with the deagle, its confusing because it seems to only run line 143 and nothing else?.
Define WeaponList as WepList[math.random(1, #WepList)] only whenever you want to pick a new one. As it stands now, you are picking a new list each time. The only time you need to reference WepList is when you are creating a new list. Other than that, you should be referencing the randomly chosen list.
Also, you're missing the brackets surrounding whatever tables you want to use as the lists.
Would i be able to use:
if (SERVER) then
WeaponList = WepList[math.random(1, #WepList)]
end
and havnt i got the brackets at line 14,55,57 and 97?
[editline]9th June 2015[/editline]
But I cant see that the brackets are missing because my code is obviously recognizing that it needs to use the lists but I cant understand why it only gives a weapon and ammo once as that code is in the same if statement and is obviously being ran.
[QUOTE=mattymoo142;47914109]Would i be able to use:
if (SERVER) then
WeaponList = WepList[math.random(1, #WepList)]
end
and havnt i got the brackets at line 14,55,57 and 97?
[editline]9th June 2015[/editline]
But I cant see that the brackets are missing because my code is obviously recognizing that it needs to use the lists but I cant understand why it only gives a weapon and ammo once as that code is in the same if statement and is obviously being ran.[/QUOTE]
What I meant by the brackets is this:
[code]
--This is what you have:
table =
{
},
{
}
-- This is what you should have:
table = { -- The weapon tables need to be encased in a table.
{
},
{
}
}
[/code]
OK thank you, I will test it tonight, should it solve my problem and does
[Lua]
If (SERVER) then
Define weaponlist
End
[/lua]
Have to be in a function?
Ok, ive tested it, thankyou, it now chooses a random table, but it still only gives amoo when i get a kill at level 2.
New code:
[url]http://pastebin.com/5m7SVgCC[/url]
Sorry, you need to Log In to post a reply to this thread.