Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onAddItem(moveitem, tileitem, position)
- if tileitem:getId() == 2593 then
- if moveitem:getId() == 2595 then
- if moveitem:getItemCountById(2599) == 1 then
- local index = 0
- for i = 0, moveitem:getCapacity() - 1 do
- if moveitem:getItem(i) and moveitem:getItem(i):getId() == 2599 then
- index = i
- end
- end
- local label = moveitem:getItem(index)
- if not label then
- return true
- end
- local text = label:getAttribute(ITEM_ATTRIBUTE_TEXT)
- if text and text ~= "" then
- local p = getPlayer(getReceiver(text))
- if Player(p) then
- if p:getVocation():getId() == VOCATION_NONE then
- return false
- end
- end
- end
- end
- end
- end
- return true
- end
- function getReceiver(text)
- local t = {}
- for str in string.gmatch(text, "([^\n]+)") do
- table.insert(t, str)
- end
- return t[1]
- end
- function getPlayer(name)
- local player = false
- local resultId = db.storeQuery('SELECT * FROM `players`')
- if resultId ~= false then
- repeat
- local p = result.getDataString(resultId, "name")
- if p:lower() == name:lower() then
- player = name
- end
- until not result.next(resultId)
- result.free(resultId)
- end
- return player
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement