Advertisement
Guest User

Untitled

a guest
Aug 10th, 2014
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | None | 0 0
  1. function getItemsInContainer(cont, sep)
  2.     local text = ""
  3.     local tsep = ""
  4.     local count = ""
  5.     for i=1, sep do
  6.         tsep = tsep.."-"
  7.     end
  8.     tsep = tsep..">"
  9.     for i=0, getContainerSize(cont.uid)-1 do
  10.         local item = getContainerItem(cont.uid, i)
  11.         if isContainer(item.uid) == FALSE then
  12.             if item.type > 1 then
  13.                 count = " ("..item.type.."x)"
  14.             end
  15.             text = text.."\n"..tsep..getItemName(item.itemid)..""..count.." ("..item.itemid..")"
  16.         else
  17.             if getContainerSize(item.uid) > 0 then
  18.                 text = text.."\n"..tsep..getItemName(item.itemid).." ("..item.itemid..")"
  19.                 text = text..getItemsInContainer(item, sep+2)..""
  20.             else
  21.                 text = text.."\n"..tsep..getItemName(item.itemid).." ("..item.itemid..")"
  22.             end
  23.         end
  24.     end
  25.     return text
  26. end
  27.  
  28. function onSay(cid, words, param)
  29.     if(param == '') then
  30.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
  31.         return false
  32.     end
  33.     local slotName = {"Head", "Amulet", "Backpack", "Armor", "Right Hand", "Left Hand", "Legs", "Feet", "Ring", "Ammo Slot"}
  34.     local t = param:split(', ')
  35.     if getPlayerGroupId(cid) >= 3 then
  36.         id = getItemIdByName(t[1])
  37.         if not id then
  38.             doPlayerSendCancel(cid, "The "..t[1].." not exist. ")
  39.             return false
  40.         end
  41.         local resultID = db.storeQuery("SELECT name FROM players WHERE id IN (SELECT player_id FROM player_items WHERE itemtype = ".. id.. ");")
  42.         local msg = "Search results by item ".. getItemName(id) .." in your database:\n\n"
  43.         if resultID then
  44.             while true do
  45.                 local name = result.getDataString(resultID, 'name')
  46.                 msg = msg .. name .."\n"
  47.                 if not result.next(resultID) then
  48.                     break
  49.                 end
  50.             end
  51.         else
  52.             msg = msg .. "The item was not found in any player."
  53.         end
  54.         doShowTextDialog(cid, id, msg)
  55.     end
  56.     return true
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement