Page 1 of 1

Inventory Funtion :)

Posted: Thu Mar 31, 2011 7:32 am
by onehand2
hi
thx for reponsing me last couple times
here i got another question

i have 150backpack slots
i want to target npc if my backpack is over 140slots

how does the funtion work?

if ()??/ then
play:merchant("NPC_name")

couldnt find any clues on wiki :D

Thank you

Re: Inventory Funtion :)

Posted: Thu Mar 31, 2011 7:58 am
by rock5
Do you mean if you have that many rented? The non-rented slots 'Available' value equals 'false' so you could count the 'Available' values or just check the first slot of each bag. eg,

Code: Select all

local slots = 60 -- first 2 bags be don't need to check
for i = 121, 211, 30 do -- check the first slot of each bag
    if inventory.BagSlot[i].Available then 
        slots = slots + 30
    end
end

if slots > 140 then
    player:merchant("NPC_name")
end

Re: Inventory Funtion :)

Posted: Thu Mar 31, 2011 8:00 pm
by onehand2
ah...sorry i messed up...

i have 150backpack slots

i want to target npc after 140slots are filled with junkies :D

sorry LOL

Re: Inventory Funtion :)

Posted: Thu Mar 31, 2011 8:16 pm
by rock5
In that case count empties.

Code: Select all

if 10 > inventory:itemTotalCount("<EMPTY>","bags") then
    player:merchant("NPC_name")
end