rE5vK8bu Posted February 26, 2016 Share Posted February 26, 2016 --table weaponInfo = { {name = "M4",id = 31,slot = 5,ammo = "M4 Mag",mag_size = 30,damage = 5000,model = 356,new_model = 1241,is_sniper = false}, {name = "Sniper",id = 34,slot = 6,ammo = "Sniper Mag",mag_size = 10,damage = 5000,model = 358,new_model = 1252,is_sniper = 1252}, } --function function getWeaponInfo(item) for _,v in ipairs(weaponInfo)do if item == v.name then return v.name,v.id,v.slot,v.ammo,v.mag_size,v.damage,v.model,v.new_model,v.is_sniper end end end The function will work if I use the script that way in a function? in disarray? local name,slot,mag_size,ammo = getWeaponInfo(currentweapon) Link to comment
Enargy, Posted February 26, 2016 Share Posted February 26, 2016 If you won't test it no, but visually its fine. Link to comment
Bonus Posted February 26, 2016 Share Posted February 26, 2016 What is currentweapon? If it's the name, why are you returning the name? You use return v.name (1), v.id (2), v.slot (3), v.ammo (4), v.mag_size (5) ... But you use: local name (1), slot (3), mag_size (5), ammo (4) The order is totally wrong. Link to comment
rE5vK8bu Posted February 26, 2016 Author Share Posted February 26, 2016 I do not want to create it: local name,id,slot,ammo,mag_size,damage,model,new_model,is_sniper = getWeaponInfo(getElementData(source,"current_weapon_1")) I want to create a main function. I do not want to create more functions from the table Link to comment
Bonus Posted February 26, 2016 Share Posted February 26, 2016 Who said anything about create?! This way its correct, because the order is right. 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