Ir para conteúdo
  • 0
damatio

Website GESIOR- error ao entregar addon

Pergunta

damatio    0
damatio

Erro ao receber addon no TFS, ele só não entrega o addon, o item chega normal!

 

TFS 1.3

5c9e58de6f1fc_Semttulo.png.1b168bb895da3e701be0a29b3a5ec964.png

 

GlobalEvents/scripts/shop.lua

Spoiler

-- ### CONFIG ###
-- message to player "type", if delivery of item debugs client, it can be because of undefinied type (type that does not exist in your server LUA)
SHOP_MSG_TYPE = MESSAGE_EVENT_ADVANCE
-- ### END OF CONFIG ###
MESSAGE_ERROR_CONTACT = "[ERRO] Shop Donate. Contate o Administrador! Erro disponível no Console."

local MountsShop = {
    -- VIP Mounts
    [80099] = 104,
    -- Normal Mounts
    [80032] = 33,
    [80040] = 41,
    [80022] = 23,
    [80008] = 9,
    [80030] = 37,
    [80033] = 34,
    [80035] = 36,
    [80043] = 45,
    [80044] = 46,
    [80045] = 47,
    [80046] = 48,
    [80047] = 49,
    [80048] = 50,
    [80049] = 51,
    [80050] = 52,
    [80051] = 53,
    [80052] = 54,
    [80053] = 55,
    [80054] = 56,
    [80055] = 57,
    [80056] = 58,
    [80057] = 59,
    [80058] = 60,
    [80060] = 62,
    [80062] = 64,
    [80063] = 65,
    [80064] = 66,
    [80065] = 67,
    [80067] = 69,
    [80068] = 70,
    [80069] = 71,
    [80071] = 73,
    [80072] = 74,
    [80073] = 75,
    [80080] = 82,
    [80081] = 83,
    [80082] = 84,
    [80087] = 89,
    [80088] = 90,
    [80089] = 91
}

local AddonsShop = {
    [28452] = {f = 130, m = 138},
    [28453] = {f = 144, m = 148},
    [28454] = {f = 636, m = 637},
    [28455] = {f = 664, m = 665},
    [28457] = {f = 683, m = 684},
    [28458] = {f = 694, m = 695},
    [28456] = {f = 666, m = 667},
    [28461] = {f = 724, m = 725},
    [28462] = {f = 732, m = 733},
    [28464] = {f = 749, m = 750},
    [28465] = {f = 759, m = 760}
}

function onThink(interval)
    local resultId = db.storeQuery("SELECT * FROM z_ots_comunication")
    if resultId ~= false then
        repeat
            local transactionId = tonumber(result.getDataInt(resultId, "id"))
            local player = Player(result.getDataString(resultId, "name"))

            if player then
                local itemId = result.getDataInt(resultId, "param1")
                local itemCount = result.getDataInt(resultId, "param2")
                local containerId = result.getDataInt(resultId, "param3")
                local containerItemsInsideCount = result.getDataInt(resultId, "param4")
                local shopOfferType = result.getDataString(resultId, "param5")
                local shopOfferName = result.getDataString(resultId, "param6")

-- DELIVER ITEM
                if shopOfferType == 'item' then
                    local newItemUID = doCreateItemEx(itemId, itemCount)
                    --  item does not exist, wrong id OR count
                    if not newItemUID then
                        player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
                        print('ERROR! Website Shop (' .. player:getName() .. ') - cannot create item - invalid item ID OR count - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount)
                        return true
                    end
                    -- change item UniqueID to object of class Item
                    local newItem = Item(newItemUID)
                    -- get player BACKPACK as container, so we can add item to it
                    local playerStoreInbox = player:getSlotItem(CONST_SLOT_BACKPACK)
                    -- cannot open BACKPACK, report problem
                    if not playerStoreInbox then
                        player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
                        print('ERROR! Website Shop (' .. player:getName() .. ') - cannot open player "BACKPACK" - it is not supported in your server OR variable "CONST_SLOT_BACKPACK" is not definied in LUA')
                        return true
                    end
                    -- add container with items to BACKPACK
                    receivedItemStatus = playerStoreInbox:addItemEx(newItem)
                    if type(receivedItemStatus) == "number" and receivedItemStatus == RETURNVALUE_NOERROR then
                        player:sendTextMessage(SHOP_MSG_TYPE, 'You received ' .. shopOfferName .. ' from Website Shop. You can find your item in BACKPACK (under EQ).')
                        db.asyncQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. transactionId)
                        db.asyncQuery("UPDATE `z_shop_history_item` SET `trans_state`= 'realized', `trans_real`=" .. os.time() .. " WHERE `id` = " .. transactionId)
                    else
                        player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
                        print('ERROR! Website Shop (' .. player:getName() .. ') - cannot add item to BACKPACK - unknown reason, is it\'s size limited and it is full? - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount)
                    end
-- DELIVER CONTAINER
                elseif shopOfferType == 'container' then
                    -- create empty container
                    local newContainerUID = doCreateItemEx(containerId, 1)
                    -- container item does not exist OR item is not Container
                    if not newContainerUID or not Container(newContainerUID) then
                        player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
                        print('ERROR! Website Shop (' .. player:getName() .. ') - cannot create container - invalid container ID - CONTAINER ID:' .. containerId)
                        return true
                    end
                    -- change container UniqueID to object of class Container
                    local newContainer = Container(newContainerUID)
                    -- add items to container
                    for i = 1, containerItemsInsideCount do
                        -- create new item
                        local newItemUID = doCreateItemEx(itemId, itemCount)
                        --  item does not exist, wrong id OR count
                        if not newItemUID then
                            player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
                            print('ERROR! Website Shop (' .. player:getName() .. ') - cannot create item - invalid item ID OR count - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount)
                            return true
                        end
                        -- change item UniqueID to object of class Item
                        local newItem = Item(newItemUID)
                        -- add item to container
                        local addItemToContainerResult = newContainer:addItemEx(newItem)
                        -- report error if it's not possible to add item to container
                        if type(addItemToContainerResult) ~= "number" or addItemToContainerResult ~= RETURNVALUE_NOERROR then
                            player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
                            print('ERROR! Website Shop (' .. player:getName() .. ') - cannot add item to container - item is not pickable OR variable "RETURNVALUE_NOERROR" is not definied in LUA - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount)
                            return true
                        end
                    end
                    -- get player BACKPACK as container, so we can add item to it
                    local playerStoreInbox = player:getSlotItem(CONST_SLOT_BACKPACK)
                    -- cannot open BACKPACK, report problem
                    if not playerStoreInbox then
                        player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
                        print('ERROR! Website Shop (' .. player:getName() .. ') - cannot open player "BACKPACK" - it is not supported in your server OR variable "CONST_SLOT_BACKPACK" is not definied in LUA')
                        return true
                    end
                    -- add container with items to BACKPACK
            
                    receivedItemStatus = playerStoreInbox:addItemEx(newContainer)
                    if type(receivedItemStatus) == "number" and receivedItemStatus == RETURNVALUE_NOERROR then
                        player:sendTextMessage(SHOP_MSG_TYPE, 'You received ' .. shopOfferName .. ' from Website Shop. You can find your item in BACKPACK (under EQ).')
                        db.asyncQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. transactionId)
                        db.asyncQuery("UPDATE `z_shop_history_item` SET `trans_state`= 'realized', `trans_real`=" .. os.time() .. " WHERE `id` = " .. transactionId)
                    else
                        player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
                        print('ERROR! Website Shop (' .. player:getName() .. ') - cannot add container with items to BACKPACK - unknown reason, is it\'s size limited and it is full? - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount .. ', CONTAINER ID:' .. containerId .. ', ITEMS IN CONTAINER COUNT:' .. containerItemsInsideCount)
                    end
-- DELIVER YOUR CUSTOM THINGS
                elseif shopOfferType == 'mount' then -- addon, mount etc.
                    player:addMount(itemId)
                    player:setStorageValue(itemId,1)
                    player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
                    player:sendTextMessage(SHOP_MSG_TYPE, 'You received ' .. shopOfferName .. ' from Website Shop.')
                    db.asyncQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. transactionId)
                    db.asyncQuery("UPDATE `z_shop_history_item` SET `trans_state`= 'realized', `trans_real`=" .. os.time() .. " WHERE `id` = " .. transactionId)    
                elseif shopOfferType == 'addon' then
                    player:addOutfit(AddonsShop[itemId].m, 3)
                    player:addOutfitAddon(AddonsShop[itemId].m, 3)
                    if (AddonsShop[itemId].f ~= 141) then
                        player:addOutfit(AddonsShop[itemId].f, 3)
                        player:addOutfitAddon(AddonsShop[itemId].f, 3)
                    end
                    player:setStorageValue(itemId,1)
                    player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
                    player:sendTextMessage(SHOP_MSG_TYPE, 'You received ' .. shopOfferName .. ' from Website Shop.')
                    db.asyncQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. transactionId .. ";")
                    db.asyncQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. transactionId .. ";")
               end
            end
        until not result.next(resultId)
        result.free(resultId)
    end

    return true
    end

 

Database

global1100.sql

Editado por damatio

Compartilhar este post


Link para o post

10 respostass a esta questão

Recommended Posts

  • 0
Gengo    19
Gengo

Ei brow, já reparou oq vc fez na linha 75 à 80?
Vc tenta fazer um result.getDataInt, porem a tabela z_ots_comunication está tudo como varchar, ou vc altera os campos da tabela com o tipo compativel que vc faz com result.getDataInt ou no script vc faz a conversão de string para int, ficando assim:
 

Spoiler

local itemId = tonumber(result.getDataString(resultId, "param1"))
local itemCount = tonumber(result.getDataString(resultId, "param2"))
local containerId = tonumber(result.getDataString(resultId, "param3"))
local containerItemsInsideCount = tonumber(result.getDataString(resultId, "param4"))
local shopOfferType = result.getDataString(resultId, "param5")
local shopOfferName = result.getDataString(resultId, "param6")

 

Obs: Creio que seja isso, pois é explicito o erro que está no console.

Editado por Gengo

Compartilhar este post


Link para o post
  • 0
damatio    0
damatio
2 horas atrás, Gengo disse:

Ei brow, já reparou oq vc fez na linha 75 à 80?
Vc tenta fazer um result.getDataInt, porem a tabela z_ots_comunication está tudo como varchar, ou vc altera os campos da tabela com o tipo compativel que vc faz com result.getDataInt ou no script vc faz a conversão de string para int, ficando assim:
 

  Ocultar conteúdo


local itemId = tonumber(result.getDataString(resultId, "param1"))
local itemCount = tonumber(result.getDataString(resultId, "param2"))
local containerId = tonumber(result.getDataString(resultId, "param3"))
local containerItemsInsideCount = tonumber(result.getDataString(resultId, "param4"))
local shopOfferType = result.getDataString(resultId, "param5")
local shopOfferName = result.getDataString(resultId, "param6")

 

Obs: Creio que seja isso, pois é explicito o erro que está no console.

O error saiu do console porem nao recebe o addon, ele fica parado no   z_ots :/

Compartilhar este post


Link para o post
  • 0
Gengo    19
Gengo
1 hora atrás, damatio disse:

O error saiu do console porem nao recebe o addon, ele fica parado no   z_ots :/

Como assim parado? Dê de mais detalhes sobre a situação, na tabela tem as coisas exatas para funcionar corretamente? Digo, vc cadastra na tabela x valores e espera que o shop faz outra coisas, e na hora de puxar da tabela, não tem compatibilidade com as informações que vc quer.

Compartilhar este post


Link para o post
  • 0
damatio    0
damatio
11 horas atrás, Gengo disse:

Como assim parado? Dê de mais detalhes sobre a situação, na tabela tem as coisas exatas para funcionar corretamente? Digo, vc cadastra na tabela x valores e espera que o shop faz outra coisas, e na hora de puxar da tabela, não tem compatibilidade com as informações que vc quer.

deixa eu te explicar melhor, e o seguinte, se eu comprar um item no shop e se meu char tiver offline, ele nao entrega o item certo ?, o item fica na database z_ots_comunication, quando eu logo o item cai no char e some da database z_ots_comunication, se eu nao me engano ele vai pra z_shophistoric algo assim, não me lembro muito bem o nome da database.

Já com o addon e diferente, após eu ter mudado o codigo que vc me mandou, o error no console sumiu, o addon nao entrega no char, ele fica parado na z_ots_comunication, creio eu que o error seja .

algo aqui

tfs 1.2/1.3

 elseif shopOfferType == 'addon' then
                    player:addOutfit(AddonsShop[itemId].m, 3)
                    player:addOutfitAddon(AddonsShop[itemId].m, 3)
                    if (AddonsShop[itemId].f ~= 141) then
                        player:addOutfit(AddonsShop[itemId].f, 3)
                        player:addOutfitAddon(AddonsShop[itemId].f, 3)
                    end
                    player:setStorageValue(itemId,1)
                    player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
                    player:sendTextMessage(SHOP_MSG_TYPE, 'You received ' .. shopOfferName .. ' from Website Shop.')
                    db.asyncQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. transactionId .. ";")
                    db.asyncQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. transactionId .. ";")
               end
            end
        until not result.next(resultId)
        result.free(resultId)
    end

    return true
    end

Compartilhar este post


Link para o post
  • 0
Gengo    19
Gengo

Teste usar 

db.executeQuery

Em vez de

db.asyncQuery

Compartilhar este post


Link para o post
  • 0
damatio    0
damatio
4 horas atrás, Gengo disse:

Teste usar 


db.executeQuery

Em vez de


db.asyncQuery

não deu, nem apareceu nada no console .-.

Compartilhar este post


Link para o post
  • 0
Gengo    19
Gengo

Então se o erro no console saiu, e essa substituição nao deu em nada, os dados que estão vindo do banco, nao confere com a tabela AddonsShop,  e nesse caso nao entrega o addon

Compartilhar este post


Link para o post
  • 0
Majesty    1755
Majesty

@damatio

Conseguiu resolver o problema? Se sim, retorne ao tópico e poste a solução.

Compartilhar este post


Link para o post
  • 0
damatio    0
damatio
17 minutos atrás, Majesty disse:

@damatio

Conseguiu resolver o problema? Se sim, retorne ao tópico e poste a solução.

não conseguir, ja tentei de tudo, não sei se e o tfs1.3  :x

 

Estava pensando em colocar addon doll, so quer ficaria feio,

qualquer coisa entra no meu site e ver no shop lá, tudo bonitnho.

http://89.ddns.net:8090/

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×