Jump to content

setElementData as a table .


PaiN^

Recommended Posts

Posted
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 !

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...