Ir para conteúdo

Featured Replies

Postado

O título diz tudo, quando compro itens no shop não para de enviar itens :@

 

shop.lua

 

function onThink(interval, lastExecution, thinkInterval)



    local result = db.getResult("SELECT * FROM shop_history WHERE `processed` = 0;")

    

        if(result:getID() ~= -1) then

            while(true) do

                cid = getCreatureByName(tostring(result:getDataString("player")))

                product = tonumber(result:getDataInt("product"))

                itemr = db.getResult("SELECT * FROM shop_offer WHERE `id` = "..product..";")

                    if isPlayer(cid) then

                        local id = tonumber(itemr:getDataInt("item"))

                        local tid = tonumber(result:getDataInt("id"))

                        local count = tonumber(itemr:getDataInt("count"))

                        local tipe = tonumber(itemr:getDataInt("type"))

                        local productn = tostring(itemr:getDataString("name"))

                            if isInArray({5,8},tipe) then

                                if getPlayerFreeCap(cid) >= getItemWeightById(id, count) then

                                    if isContainer(getPlayerSlotItem(cid, 3).uid) then

                                        received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, id,count)

                                        if received then

                                            doPlayerSendTextMessage(cid,19, "You have received >> "..productn.." << from our shop system")

                                            db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")

                                        else

                                            doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough space on container to receive >> "..productn.." <<")

                                        end

                                    else

                                        doPlayerSendTextMessage(cid,19, "Sorry, you don't have a container to receive >> "..productn.." <<")

                                    end

                                else

                                    doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough capacity to receive >> "..productn.." << (You need: "..getItemWeightById(id, count).." Capacity)")

                                end

                            elseif isInArray({6,7},tipe) then

                                    if tipe == 6 then

                                        bcap = 8

                                        bid = 1987

                                    elseif tipe == 7 then

                                        bcap = 20

                                        bid = 1988

                                    end

                                    if isItemRune(id) then

                                        count = 1

                                    end

                                    if getPlayerFreeCap(cid) >= (getItemWeightById(1987, 1) + getItemWeightById(id,count * bcap)) then

                                        local bag = doCreateItemEx(bid, 1)

                                            for i = 1,bcap do

                                                doAddContainerItem(bag, id, count)

                                            end

                                        received = doPlayerAddItemEx(1,getPlayerSlotItem(cid, 3).uid, bag)

                                        if received == RETURNVALUE_NOERROR then

                                            doPlayerSendTextMessage(cid,19, "You have received >> "..productn.." << from our shop system")

                                            db.executeQuery("UPDATE `shop_history` SET `processed`='1' WHERE id = " .. tid .. ";")

                                        else

                                            doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough space to receive >> "..productn.." <<")

                                        end

                                    else

                                        doPlayerSendTextMessage(cid,19, "Sorry, you don't have enough capacity to receive >> "..productn.." << (You need: "..getItemWeightById(id, count).." Capacity)")

                                    end

                            end

                    end

                itemr:free()

                if not(result:next()) then

                    break

                end

            end

            result:free()

        end

    return true

end



 

Globalevents.xml

 

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

 

Se precisarem de mais alguma coisa pra me ajudar avisa que eu edito.  Rep+ pra quem ajudar.

 

PS: É um servidor derivado de DBO (DBOmniverse)

 

 

  • Respostas 6
  • Visualizações 1.2k
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor

muda todos os db.executeQuery para db.Query

 

Fiz isso e continua dando erro.

 

apresenta algum erro na distro? qual distro vc usa?

 

Sim, fica aparecendo isso DIRETO!

 

er91Crx.png

Nem sei onde vê a versão da distro kk acho q é 0.4, é aqui que vê?

LwHM6GS.png

Postado

Usa esse script do shop:

 

SHOP_MSG_TYPE = 19

 
SQL_interval = 30
 
function onThink(interval, lastExecution)
    local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
    if(result_plr:getID() ~= -1) then
        while(true) do
            id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
            delete = tonumber(result_plr:getDataInt("delete_it"))
            cid = getCreatureByName(tostring(result_plr:getDataString("name")))
            if isPlayer(cid) == TRUE then
                local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
                local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
                local container_id = tonumber(result_plr:getDataInt("param3"))
                local container_count = tonumber(result_plr:getDataInt("param4"))
                local add_item_type = tostring(result_plr:getDataString("param5"))
                local add_item_name = tostring(result_plr:getDataString("param6"))
                local received_item = 0
                local full_weight = 0
                if add_item_type == 'container' then
                    full_weight = getItemWeightById(itemtogive_id, 1)
                end
                local free_cap = getPlayerFreeCap(cid)
                if full_weight <= free_cap then
                    if add_item_type == 'container' then
                        local new_container = doCreateItemEx(container_id, 1)
                        local iter = 0
                        while iter ~= container_count do
                            doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
                            iter = iter + 1
                        end
                        received_item = doPlayerAddItemEx(cid, new_container)
                    else
                        local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
                        received_item = doPlayerAddItemEx(cid, new_item)
                    end
                    if received_item == RETURNVALUE_NOERROR then
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                        db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
doPlayerSave(cid)
else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> The item '.. add_item_name ..' << that you just bought on the website couldnt be added. Han error has ocurred, please wait '.. SQL_interval ..' seconds.. Shop ID: '.. id ..'')
                    end
                else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> The item '.. add_item_name ..' << that you just bought on the website couldnt be added. Han error has ocurred, please wait '.. SQL_interval ..' seconds.. Shop ID: '.. id ..'')
                end
            end
            if not(result_plr:next()) then
                break
            end
        end
        result_plr:free()
    end
    return TRUE
end

 
Eu consegui resolver meu problema com ele!

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.6k

Informação Importante

Confirmação de Termo