admauriaot

SHOP OTLAND

Mar 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.91 KB | None | 0 0
  1. -- ### CONFIG ###
  2. -- message send to player by script "type" (types you can check in "global.lua")
  3. SHOP_MSG_TYPE = 18
  4. -- time (in seconds) between connections to SQL database by shop script
  5. SQL_interval = 30
  6. -- ### END OF CONFIG ###
  7. function onThink(interval, lastExecution)
  8. local result_plr = db.storeQuery("SELECT * FROM z_ots_comunication")
  9. if(result_plr ~= false) then
  10. repeat
  11. local id = tonumber(result.getDataInt(result_plr, "id"))
  12. local action = tostring(result.getDataString(result_plr, "action"))
  13. local delete = tonumber(result.getDataInt(result_plr, "delete_it"))
  14. local cid = getPlayerByName(tostring(result.getDataString(result_plr, "name")))
  15. if(cid) then
  16. local itemtogive_id = tonumber(result.getDataInt(result_plr, "param1"))
  17. local itemtogive_count = tonumber(result.getDataInt(result_plr, "param2"))
  18. local container_id = tonumber(result.getDataInt(result_plr, "param3"))
  19. local container_count = tonumber(result.getDataInt(result_plr, "param4"))
  20. local add_item_type = tostring(result.getDataString(result_plr, "param5"))
  21. local add_item_name = tostring(result.getDataString(result_plr, "param6"))
  22. local received_item = 0
  23. local full_weight = 0
  24.  
  25. -- Script para addons e montaria full pelo Gesior --
  26. if(add_item_type == 'mounts') then
  27. local player = Player(cid)
  28. if (getPlayerStorageValue(cid,itemtogive_id) == -1) then
  29. doPlayerAddMount(cid, itemtogive_id)
  30. setPlayerStorageValue(cid,itemtogive_id,1)
  31. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
  32. doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received '.. add_item_name ..' from Th3 Insanity Shop.')
  33. db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
  34. db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
  35. else
  36. doPlayerSendTextMessage(cid,25,"You Already have this Mount.")
  37. end
  38. return TRUE
  39.  
  40. end
  41. -- fim do script --
  42. -- Script para addons e montaria full pelo Gesior --
  43. if(add_item_type == 'addons') then
  44. local player = Player(cid)
  45. if (getPlayerStorageValue(cid,itemtogive_id) == -1) then
  46. doPlayerAddOutfit(cid, itemtogive_id, 3)
  47. doPlayerAddOutfit(cid, container_id, 3)
  48. setPlayerStorageValue(cid,itemtogive_id,1)
  49. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
  50. doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received '.. add_item_name ..' from Th3 Insanity Shop.')
  51. db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
  52. db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
  53. else
  54. doPlayerSendTextMessage(cid,25,"You Already have this Outfit.")
  55. end
  56. return TRUE
  57. end
  58. -- fim do script --
  59.  
  60.  
  61.  
  62. if(add_item_type == 'container') then
  63. container_weight = getItemWeight(container_id, 1)
  64. if(isItemRune(itemtogive_id)) then
  65. items_weight = container_count * getItemWeight(itemtogive_id, 1)
  66. else
  67. items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
  68. end
  69. full_weight = items_weight + container_weight
  70. else
  71. full_weight = getItemWeight(itemtogive_id, itemtogive_count)
  72. if(isItemRune(itemtogive_id)) then
  73. full_weight = getItemWeight(itemtogive_id, 1)
  74. else
  75. full_weight = getItemWeight(itemtogive_id, itemtogive_count)
  76. end
  77. end
  78. local free_cap = getPlayerFreeCap(cid)
  79. if(full_weight <= free_cap) then
  80. if(add_item_type == 'container') then
  81. local new_container = doCreateItemEx(container_id, 1)
  82. local iter = 0
  83. while(iter ~= container_count) do
  84. doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
  85. iter = iter + 1
  86. end
  87. received_item = doPlayerAddItemEx(cid, new_container)
  88. else
  89. local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
  90. received_item = doPlayerAddItemEx(cid, new_item)
  91.  
  92. end
  93. if(type(received_item) == "number" and received_item == RETURNVALUE_NOERROR) then
  94. doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received '.. add_item_name ..' from Th3 Insanity Shop.')
  95. db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
  96. db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
  97. else
  98. doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, ' '.. add_item_name ..' from Th3 Insanity is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
  99. end
  100. else
  101. doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, ' '.. add_item_name ..' Th3 Insanity is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
  102. end
  103. end
  104. until not result.next(result_plr)
  105. result.free(result_plr)
  106. end
  107. return true
  108. end
Add Comment
Please, Sign In to add comment