Advertisement
Alscara

mailcheck

Aug 10th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. function onAddItem(moveitem, tileitem, position)
  2.     if tileitem:getId() == 2593 then
  3.         if moveitem:getId() == 2595 then
  4.             if moveitem:getItemCountById(2599) == 1 then
  5.                 local index = 0
  6.                 for i = 0, moveitem:getCapacity() - 1 do
  7.                     if moveitem:getItem(i) and moveitem:getItem(i):getId() == 2599 then
  8.                         index = i
  9.                     end
  10.                 end
  11.                 local label = moveitem:getItem(index)
  12.                 if not label then
  13.                     return true
  14.                 end
  15.                 local text = label:getAttribute(ITEM_ATTRIBUTE_TEXT)
  16.                 if text and text ~= "" then
  17.                     local p = getPlayer(getReceiver(text))
  18.                     if Player(p) then
  19.                         if p:getVocation():getId() == VOCATION_NONE then
  20.                             return false
  21.                         end
  22.                     end
  23.                 end
  24.             end
  25.         end
  26.     end
  27.     return true
  28. end
  29.  
  30. function getReceiver(text)
  31.     local t = {}
  32.     for str in string.gmatch(text, "([^\n]+)") do
  33.         table.insert(t, str)
  34.     end
  35.     return t[1]
  36. end
  37.  
  38. function getPlayer(name)
  39.     local player = false
  40.     local resultId = db.storeQuery('SELECT * FROM `players`')
  41.     if resultId ~= false then
  42.         repeat
  43.             local p = result.getDataString(resultId, "name")
  44.             if p:lower() == name:lower() then
  45.                 player = name
  46.             end
  47.         until not result.next(resultId)
  48.         result.free(resultId)
  49.     end
  50.     return player
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement