Advertisement
Guest User

Untitled

a guest
May 24th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.50 KB | None | 0 0
  1. function onThink(interval, lastExecution, thinkInterval)
  2.  
  3. local result = db.getResult("SELECT * FROM shop_history WHERE `processed` = 0;")
  4.  
  5. if(result:getID() ~= -1) then
  6. while(true) do
  7. cid = getCreatureByName(tostring(result:getDataString("player")))
  8. product = tonumber(result:getDataInt("product"))
  9. print(product)
  10. itemr = db.getResult("SELECT * FROM shop_offer WHERE `id` = "..product..";")
  11. if isPlayer(cid) then
  12.  
  13. local um_um = {1,2,3,4,5,6,7,8,9,0}
  14. um = um_um[math.random(1, #um_um)]
  15.  
  16. local dois_dois = {1,2,3,4,5,6,7,8,9,0}
  17. dois = dois_dois[math.random(1, #dois_dois)]
  18.  
  19. local tres_tres = {1,2,3,4,5,6,7,8,9,0}
  20. tres = tres_tres[math.random(1, #tres_tres)]
  21.  
  22. local quatro_quatro = {1,2,3,4,5,6,7,8,9,0}
  23. quatro = quatro_quatro[math.random(1, #quatro_quatro)]
  24.  
  25. local cinco_cinco = {1,2,3,4,5,6,7,8,9,0}
  26. cinco = cinco_cinco[math.random(1, #cinco_cinco)]
  27.  
  28. local seis_seis = {1,2,3,4,5,6,7,8,9,0}
  29. seis = seis_seis[math.random(1, #seis_seis)]
  30.  
  31. local worldname = "Nto New Season" ----- CONFIGURE AQUI
  32. local id = tonumber(itemr:getDataInt("item"))
  33. local tid = tonumber(result:getDataInt("id"))
  34. local count = tonumber(itemr:getDataInt("count"))
  35. local tipe = tonumber(itemr:getDataInt("type"))
  36. local productn = tostring(itemr:getDataString("name"))
  37.  
  38. local voc = tonumber(itemr:getDataInt("vocation"))
  39. local look = tonumber(itemr:getDataInt("looktype"))
  40. local outfit = {lookType = look}
  41. if isInArray({5,8},tipe) then
  42. if(voc == 0) then
  43. if getPlayerFreeCap(cid) >= getItemWeightById(id, count) then
  44. if isContainer(getPlayerSlotItem(cid, 3).uid) then
  45. received = doPlayerAddItem(cid, id, count, false)
  46. if received then
  47. doItemSetAttribute(received, "description", ''.. productn ..' by ' .. getCreatureName(cid) .. ' [Serial:' .. um .. '' .. dois .. '' .. tres .. '' .. quatro .. '' .. cinco .. '' .. seis .. '].')
  48. doPlayerSendTextMessage(cid,19, "System: ".. getCreatureName(cid) .." Recebeu | "..productn.." | que comprou no Shop, Obrigado ")
  49. doPlayerSave(cid)
  50. doPlayerSendTextMessage(cid,19, "System: Seu personagem ".. getCreatureName(cid) .." foi salvo para manter nossi sistema e voce seguro!")
  51. db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")
  52. f = io.open("data/logs/Shop.txt", "a+")
  53. f:write("Player : '".. productn .." by ".. getCreatureName(cid) .." [Serial: ".. um .."".. dois .."".. tres .."".. quatro .."".. cinco .."".. seis .."] Item : "..productn.." - "..getCreatureName(cid).."- " .. os.date("%d %B %Y - %X.", os.time ()) .."\n---------------------------------------------------------\n")
  54. f:close()
  55. else
  56. doPlayerSendTextMessage(cid,19, "System: Desculpe, ".. getCreatureName(cid) .." voce não tem espaço para receber o item >> "..productn.." <<")
  57. end
  58. else
  59. doPlayerSendTextMessage(cid,19, "System: Desculpe, ".. getCreatureName(cid) .." voce não tem espaço para receber >> "..productn.." <<")
  60. end
  61. else
  62. doPlayerSendTextMessage(cid,19, "System: Desculpe, ".. getCreatureName(cid) .." voce não tem cap para receber >> "..productn.." << (voce precisa: "..getItemWeightById(id, count).." Capacidade)")
  63. end
  64. else
  65. doPlayerSendTextMessage(cid,19, "System: ".. getCreatureName(cid) .." Recebeu | "..productn.." | usando nosso Shop, Obrigado Volte Sempre!")
  66. db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")
  67. doCreatureChangeOutfit(cid, outfit)
  68. doPlayerSetVocation(cid, voc)
  69. doPlayerSave(cid)
  70. doPlayerSendTextMessage(cid,19, "System: Seu personagem ".. getCreatureName(cid) .." foi salvo para manter nosso sistema e voce seguro!")
  71. end
  72. elseif isInArray({6,7},tipe) then
  73. if tipe == 6 then
  74. bcap = 8
  75. bid = 1987
  76. elseif tipe == 7 then
  77. bcap = 20
  78. bid = 1988
  79. end
  80. if isItemRune(id) then
  81. count = 1
  82. end
  83. if getPlayerFreeCap(cid) >= (getItemWeightById(1987, 1) + getItemWeightById(id,count * bcap)) then
  84. local bag = doCreateItemEx(bid, 1)
  85. for i = 1,bcap do
  86. doAddContainerItem(bag, id, count)
  87. end
  88. received = doPlayerAddItemEx(getPlayerSlotItem(cid, 3).uid, bag)
  89. --received = doPlayerSendMailByName(getCreatureName(cid).uid, bag, getPlayerTown(cid), worldname)
  90. if received == RETURNVALUE_NOERROR then
  91. doItemSetAttribute(received, "description", ''.. productn ..' by ' .. getCreatureName(cid) .. ' [Serial:' .. um .. '' .. dois .. '' .. tres .. '' .. quatro .. '' .. cinco .. '' .. seis .. '].')
  92. doPlayerSendTextMessage(cid,19, "System: ".. getCreatureName(cid) .." recebeu >> "..productn.." << do nosso sistema de loja")
  93. doPlayerSave(cid)
  94. doPlayerSendTextMessage(cid,19, "System: Seu personagem ".. getCreatureName(cid) .." foi salvo para manter nosso sistema e voce seguro!")
  95. db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")
  96. f = io.open("data/logs/Shop.txt", "a+")
  97. f:write("Player : '".. productn .." by ".. getCreatureName(cid) .." [Serial: ".. um .."".. dois .."".. tres .."".. quatro .."".. cinco .."".. seis .."] Item : "..productn.." - "..getCreatureName(cid).."- " .. os.date("%d %B %Y - %X.", os.time ()) .."\n---------------------------------------------------------\n")
  98. f:close()
  99. else
  100. doPlayerSendTextMessage(cid,19, "System: Desculpe, ".. getCreatureName(cid) .." voce não tem espaço suficiente para receber o item >> "..productn.." <<")
  101. end
  102. else
  103. doPlayerSendTextMessage(cid,19, "System: Desculpe, ".. getCreatureName(cid) .." voce não tem capacidade suficiente para receber o item >> "..productn.." << (voce precisa: "..getItemWeightById(id, count).." Capacidade)")
  104. end
  105. end
  106. end
  107. itemr:free()
  108. if not(result:next()) then
  109. break
  110. end
  111. end
  112. result:free()
  113. end
  114. return true
  115. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement