hipolitalakaj Posted January 21, 2019 Posted January 21, 2019 Hi! I have an inventory system which have weaponindexByID and weaponModels table. I don't get it how can I reference to the weapon model if the weaponindexByID == 30 and the weaponModels == 1254 ? I get the "ok" in the outputchatbox if I reference to the weaponid like this: if weaponIndexByID[item_id] == 30 then outputChatBox("ok") end but I want to get the "ok" in the chatbox if the weaponIndexByID == 30 and the weaponModels == 1254 --- weaponModels table --- weaponModels = { [14] = {1254, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [15] = {356, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [16] = {339, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [18] = {336, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [22] = {358, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [24] = {353, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [23] = {357, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [28] = {349, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, [21] = {346, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}, } --- weaponIndexByID table --- weaponIndexByID = { [14] = 30, [15] = 31, [16] = 8, [17] = 24, [18] = 5, [19] = 4, [20] = 3, [21] = 22, [22] = 34, [23] = 33, [24] = 29, [25] = 28, [26] = 32, [27] = 23, [28] = 25, }
Moderators IIYAMA Posted January 21, 2019 Moderators Posted January 21, 2019 (edited) if weaponIndexByID[item_id] == 30 and weaponModels[item_id] -- Check if there is something at that index. (error prevention) and weaponModels[item_id][1] == 1254 -- then index twice to get access to the sub-table then outputChatBox("ko") end -- sub-table: {1254, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1} Edited January 21, 2019 by IIYAMA 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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