Advertisement
Guest User

Untitled

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