Ir para conteúdo

Featured Replies

Postado
  • Autor

<globalevent name="shop" interval="30" event="script" value="shop.lua"/>

 

Não resolveu, pois já está db.query no shop.lua

Sign's


r6z42f.png
Feito por: Anne Motta

dxo51e.png
Feito por: Mim! kk ' Primeira Sign *-*




  • Respostas 14
  • Visualizações 810
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor

Não funfou...E se eu deletar a z_ots_comunication e criar outra table igual?! Vocês sabem como criar ?!

Sign's


r6z42f.png
Feito por: Anne Motta

dxo51e.png
Feito por: Mim! kk ' Primeira Sign *-*




  • 4 months later...
Postado

Tente esse.

 

 

 

  1. -- ### CONFIG ###
  2. -- time (in seconds) between connections to SQL database by shop script
  3. SQL_interval = 30
  4. -- ### END OF CONFIG ###
  5. function onThink(interval, lastExecution)
  6.     local result_plr = db.storeQuery("SELECT * FROM z_ots_comunication")
  7.     if result_plr ~= false then
  8.         repeat
  9.             local id = tonumber(result.getDataInt(result_plr, "id"))
  10.             local action = tostring(result.getDataString(result_plr, "action"))
  11.             local delete = tonumber(result.getDataInt(result_plr, "delete_it"))
  12.             local player = Player(tostring(result.getDataString(result_plr, "name")))
  13.             if player then
  14.                 local itemtogive_id = tonumber(result.getDataInt(result_plr, "param1"))
  15.                 local itemtogive_count = tonumber(result.getDataInt(result_plr, "param2"))
  16.                 local container_id = tonumber(result.getDataInt(result_plr, "param3"))
  17.                 local container_count = tonumber(result.getDataInt(result_plr, "param4"))
  18.                 local add_item_type = tostring(result.getDataString(result_plr, "param5"))
  19.                 local add_item_name = tostring(result.getDataString(result_plr, "param6"))
  20.                 local received_item = 0
  21.                 local full_weight = 0
  22.                 local itemType = ItemType(itemtogive_id)
  23.                 if add_item_type == 'container' then
  24.                     if itemType:isRune() then
  25.                         items_weight = container_count * itemType:getWeight()
  26.                     else
  27.                         items_weight = container_count * itemType:getWeight(itemtogive_count)
  28.                     end
  29.                     full_weight = items_weight + ItemType(container_id):getWeight()
  30.                 else
  31.                     if itemType:isRune() then
  32.                         full_weight = itemType:getWeight()
  33.                     else
  34.                         full_weight = itemType:getWeight(itemtogive_count)
  35.                     end
  36.                 end
  37.                 local free_cap = player:getFreeCapacity()
  38.                 if full_weight <= free_cap then
  39.                     if add_item_type == 'container' then
  40.                         local new_container = Game.createItem(container_id, 1)
  41.                         local iter = 0
  42.                         while iter ~= container_count do
  43.                             new_container:addItem(itemtogive_id, itemtogive_count)
  44.                             iter = iter + 1
  45.                         end
  46.                         received_item = player:addItemEx(new_container)
  47.                     else
  48.                         local new_item = Game.createItem(itemtogive_id, itemtogive_count)
  49.                         received_item = player:addItemEx(new_item)
  50.                     end
  51.                     if type(received_item) == 'number' and received_item == RETURNVALUE_NOERROR then
  52.                         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You received >> '.. add_item_name ..' << from OTS shop.')
  53.                         db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
  54.                         db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " ..id .. ";")
  55.                     else
  56.                         player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
  57.                     end
  58.                 else
  59.                     player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '>> '.. add_item_name ..' << from OTS shop 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.')
  60.                 end
  61.             end
  62.         until not result.next(result_plr)
  63.         result.free(result_plr)
  64.     end
  65.     return true
  66. end

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo