Advertisement
admauriaot

SHOP.LUA AURIA

Mar 7th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. -- <globalevent name="shop" interval="30000" script="others/shop.lua"/>
  2.  
  3. function onThink(interval, lastExecution)
  4.  
  5. local queryShop = db.storeQuery('SELECT * FROM `z_ots_comunication`')
  6. if queryShop ~= false then
  7. repeat
  8. local id, player = result.getNumber(queryShop, 'id'), Player(result.getString(queryShop, 'name'))
  9. if player then
  10. local item_id, item_count = result.getNumber(queryShop, 'param1'), result.getNumber(queryShop, 'param2')
  11. local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
  12. local offer_type = result.getString(queryShop, 'param5')
  13. local item_name = result.getString(queryShop, 'param6')
  14.  
  15. -- ITEM
  16. if offer_type == 'item' then
  17. player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
  18. player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do WebShop em seu depot.')
  19.  
  20. -- ITEM NEWS
  21.  
  22. elseif offer_type == 'novos' then
  23. player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
  24. player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do WebShop em seu depot.')
  25.  
  26. -- ITEM UMBRAL
  27.  
  28. elseif offer_type == 'umbral' then
  29. player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
  30. player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do WebShop em seu depot.')
  31.  
  32.  
  33. -- ITEM CUSTOM
  34.  
  35. elseif offer_type == 'custom' then
  36. player:getInbox():addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
  37. player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do WebShop em seu depot.')
  38.  
  39. -- CONTAINER
  40. elseif offer_type == 'container' then
  41. local container_id, container_count = result.getNumber(queryShop, 'param3'), result.getNumber(queryShop, 'param4')
  42. local i, new_container = 0, player:getInbox():addItem(container_id, 1, INDEX_WHEREEVER, FLAG_NOLIMIT)
  43. while i ~= container_count do
  44. new_container:addItem(item_id, item_count, INDEX_WHEREEVER, FLAG_NOLIMIT)
  45. i = i + 1
  46. end
  47.  
  48. player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..' << do WebShop em seu depot.')
  49.  
  50. -- ADDON
  51. elseif offer_type == 'addon' then
  52. player:addOutfitAddon(item_id, 3)
  53. player:addOutfitAddon(item_count, 3)
  54. player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')
  55.  
  56. -- MOUNT
  57. elseif offer_type == 'mount' then
  58. player:addMount(item_id)
  59. player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'Voce recebeu >> '.. item_name ..'.')
  60. end
  61.  
  62. db.asyncQuery('DELETE FROM `z_ots_comunication` WHERE `id` = ' .. id)
  63. db.asyncQuery('UPDATE `z_shop_history_item` SET `trans_state` = \'realized\', `trans_real` = ' .. os.time() .. ' WHERE id = ' .. id)
  64. end
  65.  
  66. until not result.next(queryShop)
  67. result.free(queryShop)
  68. end
  69.  
  70. return true
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement