bad argument #2 to 'SetAmmo' (number expected, got no value)
1 replies, posted
I'm trying to give a player ammo via table insert.
Here's what i'm inserting:
[code]
table.insert( ply.SpawnEquipment.Ammo, "90, CombineCannon" )
[/code]
Here's my code for giving ammo:
[code]
local Ammo = Equipment.Ammo
for k,v in pairs(Ammo) do
ply:SetAmmo(v)
end
[/code]
Here's the actual table:
[code]
local sr = sr or {}
function srPlayerInitialSpawn( ply )
ply.SpawnEquipment.Ammo = {}
end
hook.Add( "PlayerInitialSpawn", "Loadoutspawn", sr.PlayerInitialSpawn )
[/code]
What i'm getting in console is:
bad argument #2 to 'SetAmmo' (number expected, got no value)
[QUOTE=sackcreator54;41916673]I'm trying to give a player ammo via table insert.
Here's what i'm inserting:
[code]
table.insert( ply.SpawnEquipment.Ammo, "90, CombineCannon" )
[/code]
Here's my code for giving ammo:
[code]
local Ammo = Equipment.Ammo
for k,v in pairs(Ammo) do
ply:SetAmmo(v)
end
[/code]
Here's the actual table:
[code]
local sr = sr or {}
function srPlayerInitialSpawn( ply )
ply.SpawnEquipment.Ammo = {}
end
hook.Add( "PlayerInitialSpawn", "Loadoutspawn", sr.PlayerInitialSpawn )
[/code]
What i'm getting in console is:
bad argument #2 to 'SetAmmo' (number expected, got no value)[/QUOTE]
You are trying to insert a string instead of two arguments. If you want two arguments do table.insert(table, {["a"] = firstarg, ["b"] = secondarg}), then use this in your for loop..
[lua]
for k,v in pairs(Ammo) do
ply:SetAmmo(v.a, v.b)
end
[/lua]
Sorry, you need to Log In to post a reply to this thread.