pressed = 0 item_state = {} already_in_inv = 0 function inv_gen_item_init_name(e,name) iq = string.find(name, ",") item_name[e] = string.sub(name,1,iq-1) item_quantity[e] = string.sub(name,iq+1) it = string.find(string.lower(item_name[e]), "ammo") if it ~= nil then item_type[e] = "ammo" item_weight[e] = item_quantity[e]/10 --individually adjusts ammo weight as no strength property for them end it = string.find(string.lower(item_name[e]), "health") if it ~= nil then item_type[e] = "health" end it = string.find(string.lower(item_name[e]), " key") if it ~= nil then item_type[e] = "key" end it = string.find(string.lower(item_name[e]), "drink") if it ~= nil then item_type[e] = "drink" end it = string.find(string.lower(item_name[e]), "food") if it ~= nil then item_type[e] = "food" end --change the path here to match your inventory images location item_image[e] = LoadImage("scriptbank\\images\\inventory\\"..item_name[e]..".png") item_sprite[e] = CreateSprite(item_image[e]) SetSpriteSize(item_sprite[e],slot_sizex,slot_sizey) SetSpriteDepth(item_sprite[e],9) SetSpritePosition(item_sprite[e],200,200) item_state[e] = "wait" end --name must be the image name followed by a , and the item quantity --strength property = the item weight (if no strength available than the item is as heavy as the quantity value) function inv_gen_item_main(e) if item_weight[e] == nil then if g_Entity[e]['health'] == nil then item_weight[e] = item_quantity[e] else item_weight[e] = g_Entity[e]['health'] end end if item_state[e] == "wait" then if PlayerLooking(e,85,6) == 1 then PromptLocal(e,"Collect "..item_quantity[e].." x "..item_name[e].."? *E*") if g_KeyPressE == 1 and pressed == 0 then pressed = 1 if current_weight + item_weight[e] <= max_weight then already_in_inv = 0 for a = 1, current_slot do if item_name[slot_taken[a]] == item_name[e] then item_quantity_held[item_name[e]] = item_quantity_held[item_name[e]]+item_quantity[e] current_weight = current_weight + item_weight[e] already_in_inv = 1 item_state[e] = "destroy" break end end if already_in_inv == 0 then slot_taken[current_slot] = e item_quantity_held[item_name[e]] = item_quantity[e] current_slot = current_slot + 1 current_weight = current_weight + item_weight[e] item_state[e] = "carried" end if item_type[e] == "ammo" or item_type[e] == "key" then PlaySound(e,0) else PlaySound(e,1) end else PromptDuration("Item too heavy, free "..item_weight[e].." space to carry it",2000) end end end elseif item_state[e] == "carried" then CollisionOff(e) Hide(e) SetPosition(e,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ) elseif item_state[e] == "destroy" then Destroy(e) end if g_KeyPressE == 0 then pressed = 0 end end