PaiN^ Posted May 4, 2013 Share Posted May 4, 2013 setElementData ( source, 'WeaponsSelection', { ['w1'] = a1, ['w2'] = a2, ['w3'] = a3 } ) local packeg = getElementData ( source, 'WeaponsSelection' ) if packeg then for k,v in next, packeg do giveWeapon ( source, tonumber( k ), v ) giveWeapon ( source, tonumber( k ), v ) giveWeapon ( source, tonumber( k ), v ) end else outputChatBox ( 'dsadsad', source ) end w1, w2, w3 = are defined as weapon id's a1, a2, a3 = are defined as ammo ( int values ) WARNING: ***:42: Bad argument @ 'giveWeapon' [Expected weapon-type at argument 2, got nil] * Note : I use the w1, w2, a1, a2 ... some where else in the script, And it works, It don't work when i try to get it from the element data ! Link to comment
DiSaMe Posted May 4, 2013 Share Posted May 4, 2013 k is the key in your loop. That means, it has values 'w1', 'w2' and 'w3' during iterations.The problem is that you try converting these values to numbers. That fails and tonumber function returns nil. Link to comment
PaiN^ Posted May 4, 2013 Author Share Posted May 4, 2013 Oh, it's working ! Thank you for the help and info . Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now