Jump to content

How can I reference to weapon model?


hipolitalakaj

Recommended Posts

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,
}

 

Link to comment
  • Moderators

 

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 by IIYAMA
  • Thanks 1
Link to comment

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...