Ir para conteúdo
  • Cadastre-se

(Resolvido)Shop não entrega itens


Ir para solução Resolvido por Brum,

Posts Recomendados

Olá Mens, 

to com esse b.o aqui, alguem sabe por onde eu começo?

 

o impressionante é que a Premium Chega, mas os itens adicionados, NÂO

 

tem algum jeito de eu usar o script da premium, editar e colocar outro item-copia?

 

vou postar alguns arquivos do gift-sistem

 

Screenshot_1.thumb.jpg.971419d9441a6370659fad9ecf538359.jpg

 

 

 

 

gesior-shop-system

Citar

--[[
    Gesior Shop System v2.0
    
    Originally written by Gesior, modified by slawkens for MyAAC.    
    Converted to Revscriptsys by Majesty.
    
    change interval 30000 to 30 if other values in this file are low
]]--

local messageType = MESSAGE_EVENT_ORANGE
local displayExecutionTime = true -- how time script took in console (true/false)

-- don't edit anything below this line
if(displayExecutionTime) then
    function doSecondsFormat(i)
        local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1.%2", 1), 0
        repeat
            str, found = string.gsub(str, "(%d)(%d%d%d),", "%1.%2,", 1)
        until found == 0
        return str
    end
end

if(not messageType) then
    messageType = MESSAGE_STATUS_CONSOLE_ORANGE
    if(not messageType) then
        messageType = MESSAGE_INFO_DESCR
    end
end

if(not getPlayerByName) then
    function getPlayerByName(name) local p = Player(name) return p ~= nil and p:getId() or false end
end


if(not isPlayer) then
    function isPlayer(cid) return Player(cid) ~= nil end
end

if(not doPlayerSave) then
    function doPlayerSave(cid)
        if(Player and type(Player) == "table" and Player.save and type(Player.save) == "function") then
            local player = Player(cid)
            if(player) then
                player:save()
            end
        end
        
        return true
    end
end

function getResults()
    if(db.storeQuery ~= nil and result.free ~= nil) then -- TFS 1.0+
        local resultId = db.storeQuery("SELECT * FROM z_ots_comunication;")
        if(resultId == false) then
            return false
        end
        
        local results = {}
        repeat
            local tmp = {}
            tmp.name = result.getDataString(resultId, "name")
            
            -- better performance when no player found
            tmp.exist = false
            tmp.cid = getPlayerByName(tmp.name)
            if(tmp.cid and isPlayer(tmp.cid)) then
                tmp.exist = true
                
                tmp.id = result.getDataInt(resultId, "id")
                tmp.action = result.getDataString(resultId, "action")
                tmp.delete_it = result.getDataInt(resultId, "delete_it")
                
                tmp.param1 = result.getDataInt(resultId, "param1")
                tmp.param2 = result.getDataInt(resultId, "param2")
                tmp.param3 = result.getDataInt(resultId, "param3")
                tmp.param4 = result.getDataInt(resultId, "param4")
                tmp.param5 = result.getDataString(resultId, "param5")
                tmp.param6 = result.getDataString(resultId, "param6")
            end
            
            table.insert(results, tmp)
        until not result.next(resultId)
        result.free(resultId)
        
        return results
    else -- TFS 0.3
        if(db.getResult ~= nil) then
            local result_plr = db.getResult("SELECT * FROM z_ots_comunication;")
            if(result_plr:getID() == -1) then
                return false
            end

            local results = {}
            repeat
                local tmp = {}
                tmp.name = tostring(result_plr:getDataString("name"))

                -- better performance when no player found
                tmp.exist = false
                tmp.cid = getPlayerByName(tmp.name)
                if(tmp.cid and isPlayer(tmp.cid)) then
                    tmp.exist = true

                    tmp.id = tonumber(result_plr:getDataInt("id"))
                    tmp.action = tostring(result_plr:getDataString("action"))
                    tmp.delete_it = tonumber(result_plr:getDataInt("delete_it"))
                    
                    tmp.param1 = tonumber(result_plr:getDataInt("param1"))
                    tmp.param2 = tonumber(result_plr:getDataInt("param2"))
                    tmp.param3 = tonumber(result_plr:getDataInt("param3"))
                    tmp.param4 = tonumber(result_plr:getDataInt("param4"))
                    tmp.param5 = tostring(result_plr:getDataString("param5"))
                    tmp.param6 = tostring(result_plr:getDataString("param6"))
                end
                
                table.insert(results, tmp)
            until not(result_plr:next())

            result_plr:free()
            return results
        else
            print('[ERROR - gesior-shop-system.lua] Your distribution is not supported')
        end
    end
    
    return false
end

function doQuery(query)
    if(db.asyncQuery ~= nil) then
        db.asyncQuery(query)
    elseif(db.query ~= nil) then
        db.query(query)
    elseif(db.executeQuery ~= nil) then
        db.executeQuery(query)
    else
        return false
    end
    
    return true
end

if(not getItemWeightById) then
    getItemWeightById = getItemWeight
end

if(not doCreateItemEx) then
    function doCreateItemEx(itemid, count)
        if(Game and type(Game) == "table" and Game.createItem and type(Game.createItem) == "function") then
            local item = Game.createItem(itemid, count)
            if item then
                return item:getUniqueId()
            end
            return false
        else
            print("[ERROR - gesior-shop-system] Error code: 1. Please contact slawkens at www.otland.net")
        end
    end
end

local gesiorShopSystem = GlobalEvent("GesiorShopSystem")
function gesiorShopSystem.onThink(interval)
    if(interval > 1000) then
        interval = interval / 1000
    end

    local started = os.mtime and os.mtime() or os.time()
    local addedItems, waitingItems = 0, 0
    local added = false

    local results = getResults()
    if(not results) then
        return true
    end
    
    for i, v in ipairs(results) do
        added = false
        local id = v.id
        local action = v.action
        local delete = v.delete_it

        if(v.exist) then
            local cid = v.cid
            local param1, param2, param3, param4 = v.param1, v.param2, v.param3, v.param4
            local add_item_type = v.param5
            local add_item_name = v.param6
            local received_item, full_weight, items_weight, item_weigth = 0, 0, 0, 0
            local item_doesnt_exist = false

            if(add_item_type == 'container' or add_item_type == 'item') then
                local item_weigth = getItemWeightById(param1, 1)
                if(type(item_weigth) == 'boolean') then -- item doesn't exist
                    print("[ERROR - gesior-shop-system] Invalid item id: " .. param1 .. ". Change/Fix `itemid1` in `z_shop_offers` then delete it from `z_ots_comunication`")
                    item_doesnt_exist = true
                else
                    if(add_item_type == 'container') then
                        container_weight = getItemWeightById(param3, 1)
                        if(type(container_weight) == 'boolean') then -- container item doesn't exist
                            print("[ERROR - gesior-shop-system] Invalid container id: " .. param3 .. ". Change/Fix `itemid2` in `z_shop_offers` then delete it from `z_ots_comunication`")
                            item_doesnt_exist = true
                        else
                            if(isItemRune(param1)) then
                                items_weight = param4 * item_weigth
                            else
                                items_weight = param4 * getItemWeightById(param1, param2)
                            end
                            
                            full_weight = items_weight + container_weight
                        end
                    elseif(add_item_type == 'item') then
                        full_weight = getItemWeightById(param1, param2)
                        if(isItemRune(param1)) then
                            full_weight = getItemWeightById(param1, 1)
                        end
                    end
                end
                
                if(not item_doesnt_exist) then
                    local free_cap = getPlayerFreeCap(cid)
                    if(full_weight <= free_cap) then
                        if(add_item_type == 'container') then
                            local new_container = doCreateItemEx(param3, 1)
                            for x = 1, param4 do
                                doAddContainerItem(new_container, param1, param2)
                            end
                            received_item = doPlayerAddItemEx(cid, new_container)
                        else
                            local new_item = doCreateItemEx(param1, param2)
                            received_item = doPlayerAddItemEx(cid, new_item)
                        end

                        if(received_item == RETURNVALUE_NOERROR) then
                            doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                            doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                            doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                            doPlayerSave(cid)
                            added = true
                        else
                            doPlayerSendTextMessage(cid, messageType, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. interval ..' seconds to get it.')
                        end
                    else
                        doPlayerSendTextMessage(cid, messageType, '>> '.. 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 '.. interval ..' seconds to get it.')
                    end
                end
            elseif(add_item_type == 'addon') then
                doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
                doPlayerAddOutfit(cid, param1, param3)
                doPlayerAddOutfit(cid, param2, param4)
                doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                doPlayerSave(cid)
                added = true
            elseif(add_item_type == 'mount') then
                if(not doPlayerAddMount) then
                    print("[ERROR - gesior-shop-system] Your server doesn't support mounts. Remove all items in database from your `z_shop_offers` table where `offer_type` = mount and also in `z_ots_comunication` where `param5` = mount.")
                else
                    doPlayerAddMount(cid, param1)
                    doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)

                    doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                    doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                    doPlayerSave(cid)
                    added = true
                end
            end
        end

        if(added) then
            addedItems = addedItems + 1
        else
            waitingItems = waitingItems + 1
        end
    end

    local message = ">> Shopsystem, added " .. addedItems .. " items. Still waiting with " .. waitingItems .. " items."

    if(displayExecutionTime) then
        local done, str = os.time() - started, ""
        if(os.mtime) then
            done = os.mtime() - started
            if(done < 100) then
                str = "0.0" .. done
            elseif(done < 1000) then
                str = "0." .. done
            else
                str = doSecondsFormat(done)
                if(str:len() == 0) then str = "0.0" end
            end
        end

        message = message .. " Done in: " .. str .. "s."
    end

    print(message)
    return true
end

gesiorShopSystem:interval(30000)
gesiorShopSystem:register()

 

Você tem o código disponível? Se tiver publique-o aqui: 

 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

 

Link para o post
Compartilhar em outros sites
  • Sub-Admin
3 horas atrás, Brum disse:

Olá Mens, 

to com esse b.o aqui, alguem sabe por onde eu começo?

 

o impressionante é que a Premium Chega, mas os itens adicionados, NÂO

 

tem algum jeito de eu usar o script da premium, editar e colocar outro item-copia?

 

vou postar alguns arquivos do gift-sistem

 

Screenshot_1.thumb.jpg.971419d9441a6370659fad9ecf538359.jpg

 

 

 

 

gesior-shop-system

 

Você tem o código disponível? Se tiver publique-o aqui: 



 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

 

 

 

local messageType = MESSAGE_EVENT_ORANGE
local displayExecutionTime = true

if(displayExecutionTime) then
    function doSecondsFormat(i)
        local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1.%2", 1), 0
        repeat
            str, found = string.gsub(str, "(%d)(%d%d%d),", "%1.%2,", 1)
        until found == 0
        return str
    end
end

if(not messageType) then
    messageType = MESSAGE_STATUS_CONSOLE_ORANGE
    if(not messageType) then
        messageType = MESSAGE_INFO_DESCR
    end
end

if(not getPlayerByName) then
    function getPlayerByName(name) local p = Player(name) return p ~= nil and p:getId() or false end
end


if(not isPlayer) then
    function isPlayer(cid) return Player(cid) ~= nil end
end

if(not doPlayerSave) then
    function doPlayerSave(cid)
        if(Player and type(Player) == "table" and Player.save and type(Player.save) == "function") then
            local player = Player(cid)
            if(player) then
                player:save()
            end
        end
        
        return true
    end
end

function getResults()
    if(db.storeQuery ~= nil and result.free ~= nil) then -- TFS 1.0+
        local resultId = db.storeQuery("SELECT * FROM z_ots_comunication;")
        if(resultId == false) then
            return false
        end
        
        local results = {}
        repeat
            local tmp = {}
            tmp.name = result.getDataString(resultId, "name")
            
            tmp.exist = false
            tmp.cid = getPlayerByName(tmp.name)
            if(tmp.cid and isPlayer(tmp.cid)) then
                tmp.exist = true
                
                tmp.id = result.getDataInt(resultId, "id")
                tmp.action = result.getDataString(resultId, "action")
                tmp.delete_it = result.getDataInt(resultId, "delete_it")
                
                tmp.param1 = result.getDataInt(resultId, "param1")
                tmp.param2 = result.getDataInt(resultId, "param2")
                tmp.param3 = result.getDataInt(resultId, "param3")
                tmp.param4 = result.getDataInt(resultId, "param4")
                tmp.param5 = result.getDataString(resultId, "param5")
                tmp.param6 = result.getDataString(resultId, "param6")
            end
            
            table.insert(results, tmp)
        until not result.next(resultId)
        result.free(resultId)
        
        return results
    else
        if(db.getResult ~= nil) then
            local result_plr = db.getResult("SELECT * FROM z_ots_comunication;")
            if(result_plr:getID() == -1) then
                return false
            end

            local results = {}
            repeat
                local tmp = {}
                tmp.name = tostring(result_plr:getDataString("name"))

                tmp.exist = false
                tmp.cid = getPlayerByName(tmp.name)
                if(tmp.cid and isPlayer(tmp.cid)) then
                    tmp.exist = true

                    tmp.id = tonumber(result_plr:getDataInt("id"))
                    tmp.action = tostring(result_plr:getDataString("action"))
                    tmp.delete_it = tonumber(result_plr:getDataInt("delete_it"))
                    
                    tmp.param1 = tonumber(result_plr:getDataInt("param1"))
                    tmp.param2 = tonumber(result_plr:getDataInt("param2"))
                    tmp.param3 = tonumber(result_plr:getDataInt("param3"))
                    tmp.param4 = tonumber(result_plr:getDataInt("param4"))
                    tmp.param5 = tostring(result_plr:getDataString("param5"))
                    tmp.param6 = tostring(result_plr:getDataString("param6"))
                end
                
                table.insert(results, tmp)
            until not(result_plr:next())

            result_plr:free()
            return results
        else
            print('[ERROR - gesior-shop-system.lua] Your distribution is not supported')
        end
    end
    
    return false
end

function doQuery(query)
    if(db.asyncQuery ~= nil) then
        db.asyncQuery(query)
    elseif(db.query ~= nil) then
        db.query(query)
    elseif(db.executeQuery ~= nil) then
        db.executeQuery(query)
    else
        return false
    end
    
    return true
end

if(not getItemWeightById) then
    getItemWeightById = getItemWeight
end

if(not doCreateItemEx) then
    function doCreateItemEx(itemid, count)
        if(Game and type(Game) == "table" and Game.createItem and type(Game.createItem) == "function") then
            local item = Game.createItem(itemid, count)
            if item then
                return item:getUniqueId()
            end
            return false
        else
            print("[ERROR - gesior-shop-system] Error code: 1. Please contact slawkens at www.otland.net")
        end
    end
end

local gesiorShopSystem = GlobalEvent("GesiorShopSystem")
function gesiorShopSystem.onThink(interval)
    if(interval > 100) then
        interval = interval / 100
    end

    local started = os.mtime and os.mtime() or os.time()
    local addedItems, waitingItems = 0, 0
    local added = false

    local results = getResults()
    if(not results) then
        return true
    end
    
    for i, v in ipairs(results) do
        added = false
        local id = v.id
        local action = v.action
        local delete = v.delete_it

        if(v.exist) then
            local cid = v.cid
            local param1, param2, param3, param4 = v.param1, v.param2, v.param3, v.param4
            local add_item_type = v.param5
            local add_item_name = v.param6
            local received_item, full_weight, items_weight, item_weigth = 0, 0, 0, 0
            local item_doesnt_exist = false

            if(add_item_type == 'container' or add_item_type == 'item') then
                local item_weigth = getItemWeightById(param1, 1)
                if(type(item_weigth) == 'boolean') then -- item doesn't exist
                    print("[ERROR - gesior-shop-system] Invalid item id: " .. param1 .. ". Change/Fix `itemid1` in `z_shop_offers` then delete it from `z_ots_comunication`")
                    item_doesnt_exist = true
                else
                    if(add_item_type == 'container') then
                        container_weight = getItemWeightById(param3, 1)
                        if(type(container_weight) == 'boolean') then -- container item doesn't exist
                            print("[ERROR - gesior-shop-system] Invalid container id: " .. param3 .. ". Change/Fix `itemid2` in `z_shop_offers` then delete it from `z_ots_comunication`")
                            item_doesnt_exist = true
                        else
                            if(isItemRune(param1)) then
                                items_weight = param4 * item_weigth
                            else
                                items_weight = param4 * getItemWeightById(param1, param2)
                            end
                            
                            full_weight = items_weight + container_weight
                        end
                    elseif(add_item_type == 'item') then
                        full_weight = getItemWeightById(param1, param2)
                        if(isItemRune(param1)) then
                            full_weight = getItemWeightById(param1, 1)
                        end
                    end
                end
                
                if(not item_doesnt_exist) then
                    local free_cap = getPlayerFreeCap(cid)
                    if(full_weight <= free_cap) then
                        if(add_item_type == 'container') then
                            local new_container = doCreateItemEx(param3, 1)
                            for x = 1, param4 do
                                doAddContainerItem(new_container, param1, param2)
                            end
                            received_item = doPlayerAddItemEx(cid, new_container)
                        else
                            local new_item = doCreateItemEx(param1, param2)
                            received_item = doPlayerAddItemEx(cid, new_item)
                        end

                        if(received_item == RETURNVALUE_NOERROR) then
                            doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                            doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                            doQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                            doPlayerSave(cid)
                            added = true
                        else
                            doPlayerSendTextMessage(cid, messageType, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. interval ..' seconds to get it.')
                        end
                    else
                        doPlayerSendTextMessage(cid, messageType, '>> '.. 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 '.. interval ..' seconds to get it.')
                    end
                end
            elseif(add_item_type == 'addon') then
                doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
                doPlayerAddOutfit(cid, param1, param3)
                doPlayerAddOutfit(cid, param2, param4)
                doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                doQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                doPlayerSave(cid)
                added = true
            elseif(add_item_type == 'mount') then
                if(not doPlayerAddMount) then
                    print("[ERROR - gesior-shop-system] Your server doesn't support mounts. Remove all items in database from your `z_shop_offers` table where `offer_type` = mount and also in `z_ots_comunication` where `param5` = mount.")
                else
                    doPlayerAddMount(cid, param1)
                    doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)

                    doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                    doQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                    doPlayerSave(cid)
                    added = true
                end
            end
        end

        if(added) then
            addedItems = addedItems + 1
        else
            waitingItems = waitingItems + 1
        end
    end

    local message = ">> Shopsystem, added " .. addedItems .. " items. Still waiting with " .. waitingItems .. " items."

    if(displayExecutionTime) then
        local done, str = os.time() - started, ""
        if(os.mtime) then
            done = os.mtime() - started
            if(done < 100) then
                str = "0.0" .. done
            elseif(done < 1000) then
                str = "0." .. done
            else
                str = doSecondsFormat(done)
                if(str:len() == 0) then str = "0.0" end
            end
        end

        message = message .. " Done in: " .. str .. "s."
    end

    print(message)
    return true
end

gesiorShopSystem:interval(3000)
gesiorShopSystem:register()

 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites
  • Sub-Admin
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 18
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
function onThink(interval, lastExecution)
  local result_plr = db.storeQuery("SELECT * FROM z_ots_comunication")
  if(result_plr ~= false) then
  repeat
  local id = tonumber(result.getDataInt(result_plr, "id"))
  local action = tostring(result.getDataString(result_plr, "action"))
  local delete = tonumber(result.getDataInt(result_plr, "delete_it"))
  local cid = getPlayerByName(tostring(result.getDataString(result_plr, "name")))
  if(cid) then
  local itemtogive_id = tonumber(result.getDataInt(result_plr, "param1"))
  local itemtogive_count = tonumber(result.getDataInt(result_plr, "param2"))
  local container_id = tonumber(result.getDataInt(result_plr, "param3"))
  local container_count = tonumber(result.getDataInt(result_plr, "param4"))
  local add_item_type = tostring(result.getDataString(result_plr, "param5"))
  local add_item_name = tostring(result.getDataString(result_plr, "param6"))
  local received_item = 0
  local full_weight = 0
  if(add_item_type == 'container') then
  container_weight = getItemWeight(container_id, 1)
  if(isItemRune(itemtogive_id)) then
  items_weight = container_count * getItemWeight(itemtogive_id, 1)
  else
  items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
  end
  full_weight = items_weight + container_weight
  else
  full_weight = getItemWeight(itemtogive_id, itemtogive_count)
  if(isItemRune(itemtogive_id)) then
  full_weight = getItemWeight(itemtogive_id, 1)
  else
  full_weight = getItemWeight(itemtogive_id, itemtogive_count)
  end
  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(type(received_item) == "number" and 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 .. ";")
  else
  doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. 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.')
  end
  else
  doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. 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.')
  end
  end
  until not result.next(result_plr)
  result.free(result_plr)
  end
  return true
end

 

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

 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites

  testar agoraaa  

deu erro, mas apareceu isso 

image.png

image.png

adicionei essa table logo apos o erro

 

CREATE TABLE `z_shop_history_item` (
`id` int(11) NOT NULL auto_increment,
`to_name` varchar(255) NOT NULL default '0',
`to_account` int(11) NOT NULL default '0',
`from_nick` varchar(255) NOT NULL,
`from_account` int(11) NOT NULL default '0',
`price` int(11) NOT NULL default '0',
`offer_id` varchar(255) NOT NULL default '',
`trans_state` varchar(255) NOT NULL,
`trans_start` int(11) NOT NULL default '0',
`trans_real` int(11) NOT NULL default '0',
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
15 minutos atrás, Brum disse:

  testar agoraaa  

deu erro, mas apareceu isso 

image.png

image.png

adicionei essa table logo apos o erro

 


CREATE TABLE `z_shop_history_item` (
`id` int(11) NOT NULL auto_increment,
`to_name` varchar(255) NOT NULL default '0',
`to_account` int(11) NOT NULL default '0',
`from_nick` varchar(255) NOT NULL,
`from_account` int(11) NOT NULL default '0',
`price` int(11) NOT NULL default '0',
`offer_id` varchar(255) NOT NULL default '',
`trans_state` varchar(255) NOT NULL,
`trans_start` int(11) NOT NULL default '0',
`trans_real` int(11) NOT NULL default '0',
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

consegui que caísse o crystal coin, mas o addon fica dando essa menssagem

image.png.719b042d27bc10b6f202d956f803ee8d.png

Editado por Brum (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Sub-Admin
17 minutos atrás, Brum disse:

  testar agoraaa  

deu erro, mas apareceu isso 

image.png

image.png

importe isso pro seu mysql "banco de dados" 

 

DROP TABLE IF EXISTS `z_shop_history_item`; CREATE TABLE IF NOT EXISTS `z_shop_history_item` ( `id` int(11) NOT NULL AUTO_INCREMENT, `to_name` varchar(255) NOT NULL DEFAULT '0', `to_account` int(11) NOT NULL DEFAULT '0', `from_nick` varchar(255) NOT NULL, `from_account` int(11) NOT NULL DEFAULT '0', `price` int(11) NOT NULL DEFAULT '0', `offer_id` varchar(255) NOT NULL DEFAULT '', `trans_state` varchar(255) NOT NULL, `trans_start` int(11) NOT NULL DEFAULT '0', `trans_real` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites
17 minutos atrás, Brum disse:

  testar agoraaa  

deu erro, mas apareceu isso 

image.png

image.png

adicionei essa table logo apos o erro

 


CREATE TABLE `z_shop_history_item` (
`id` int(11) NOT NULL auto_increment,
`to_name` varchar(255) NOT NULL default '0',
`to_account` int(11) NOT NULL default '0',
`from_nick` varchar(255) NOT NULL,
`from_account` int(11) NOT NULL default '0',
`price` int(11) NOT NULL default '0',
`offer_id` varchar(255) NOT NULL default '',
`trans_state` varchar(255) NOT NULL,
`trans_start` int(11) NOT NULL default '0',
`trans_real` int(11) NOT NULL default '0',
PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

consegui que caísse o crystal coin, mas o addon fica dando essa menssagem

image.png.719b042d27bc10b6f202d956f803ee8d.png

image.thumb.png.c83feb5d45b89f78ef9939400cab0538.png

Link para o post
Compartilhar em outros sites
  • Sub-Admin
5 minutos atrás, Brum disse:

image.thumb.png.c83feb5d45b89f78ef9939400cab0538.png

volta o script que estava caindo o crystal coin e teste

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites
3 minutos atrás, L3K0T disse:

volta o script que estava caindo o crystal coin e teste

image.thumb.png.096973c32ab98abc88207b780ec75296.png

 

msm dando essa msg, ainda ta caindo, só n está verificando no historico

e o addon, n cai dejeito nenhum, 

Agora, Brum disse:

image.thumb.png.096973c32ab98abc88207b780ec75296.png

 

msm dando essa msg, ainda ta caindo, só n está verificando no historico

e o addon, n cai dejeito nenhum, 

image.png.4d8209f85b36f3e648c57d2d6d9f29eb.png

Link para o post
Compartilhar em outros sites
  • Sub-Admin
1 minuto atrás, Brum disse:

image.thumb.png.096973c32ab98abc88207b780ec75296.png

 

msm dando essa msg, ainda ta caindo, só n está verificando no historico

e o addon, n cai dejeito nenhum, 

image.png.4d8209f85b36f3e648c57d2d6d9f29eb.png

algum erro no terminal do server?

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites
Agora, L3K0T disse:

algum erro no terminal do server?

só o msm 
image.thumb.png.c57319afcd961b41e3bd134f0cc89a04.png 

 

 

Agora, Brum disse:

só o msm 
image.thumb.png.c57319afcd961b41e3bd134f0cc89a04.png 

 

 

devo excluir o script ?

a função de adicionar items /compra e venda, está OK

MUITO OBRIGADO

 

mas a de addon ainda não funciona, oque será que pode ser

image.png.650df1e7d990398f6da94e433e1e8271.png

 

Excluí o scrip e tentei comprar, mas não dá, só com ele mesmo instalado

vou resintalar e testar e postar o erro, pera

 

Link para o post
Compartilhar em outros sites
  • Sub-Admin
15 minutos atrás, Brum disse:

só o msm 
image.thumb.png.c57319afcd961b41e3bd134f0cc89a04.png 

 

 

devo excluir o script ?

--[[
    Gesior Shop System v2.0
    
    Originally written by Gesior, modified by slawkens for MyAAC.    
    Converted to Revscriptsys by Majesty.
    
    change interval 30000 to 30 if other values in this file are low
]]--

local messageType = MESSAGE_EVENT_ORANGE
local displayExecutionTime = true -- how time script took in console (true/false)

-- don't edit anything below this line
if(displayExecutionTime) then
    function doSecondsFormat(i)
        local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1.%2", 1), 0
        repeat
            str, found = string.gsub(str, "(%d)(%d%d%d),", "%1.%2,", 1)
        until found == 0
        return str
    end
end

if(not messageType) then
    messageType = MESSAGE_STATUS_CONSOLE_ORANGE
    if(not messageType) then
        messageType = MESSAGE_INFO_DESCR
    end
end

if(not getPlayerByName) then
    function getPlayerByName(name) local p = Player(name) return p ~= nil and p:getId() or false end
end


if(not isPlayer) then
    function isPlayer(cid) return Player(cid) ~= nil end
end

if(not doPlayerSave) then
    function doPlayerSave(cid)
        if(Player and type(Player) == "table" and Player.save and type(Player.save) == "function") then
            local player = Player(cid)
            if(player) then
                player:save()
            end
        end
        
        return true
    end
end

function getResults()
    if(db.storeQuery ~= nil and result.free ~= nil) then -- TFS 1.0+
        local resultId = db.storeQuery("SELECT * FROM z_ots_comunication;")
        if(resultId == false) then
            return false
        end
        
        local results = {}
        repeat
            local tmp = {}
            tmp.name = result.getDataString(resultId, "name")
            
            -- better performance when no player found
            tmp.exist = false
            tmp.cid = getPlayerByName(tmp.name)
            if(tmp.cid and isPlayer(tmp.cid)) then
                tmp.exist = true
                
                tmp.id = result.getDataInt(resultId, "id")
                tmp.action = result.getDataString(resultId, "action")
                tmp.delete_it = result.getDataInt(resultId, "delete_it")
                
                tmp.param1 = result.getDataInt(resultId, "param1")
                tmp.param2 = result.getDataInt(resultId, "param2")
                tmp.param3 = result.getDataInt(resultId, "param3")
                tmp.param4 = result.getDataInt(resultId, "param4")
                tmp.param5 = result.getDataString(resultId, "param5")
                tmp.param6 = result.getDataString(resultId, "param6")
            end
            
            table.insert(results, tmp)
        until not result.next(resultId)
        result.free(resultId)
        
        return results
    else -- TFS 0.3
        if(db.getResult ~= nil) then
            local result_plr = db.getResult("SELECT * FROM z_ots_comunication;")
            if(result_plr:getID() == -1) then
                return false
            end

            local results = {}
            repeat
                local tmp = {}
                tmp.name = tostring(result_plr:getDataString("name"))

                -- better performance when no player found
                tmp.exist = false
                tmp.cid = getPlayerByName(tmp.name)
                if(tmp.cid and isPlayer(tmp.cid)) then
                    tmp.exist = true

                    tmp.id = tonumber(result_plr:getDataInt("id"))
                    tmp.action = tostring(result_plr:getDataString("action"))
                    tmp.delete_it = tonumber(result_plr:getDataInt("delete_it"))
                    
                    tmp.param1 = tonumber(result_plr:getDataInt("param1"))
                    tmp.param2 = tonumber(result_plr:getDataInt("param2"))
                    tmp.param3 = tonumber(result_plr:getDataInt("param3"))
                    tmp.param4 = tonumber(result_plr:getDataInt("param4"))
                    tmp.param5 = tostring(result_plr:getDataString("param5"))
                    tmp.param6 = tostring(result_plr:getDataString("param6"))
                end
                
                table.insert(results, tmp)
            until not(result_plr:next())

            result_plr:free()
            return results
        else
            print('[ERROR - gesior-shop-system.lua] Your distribution is not supported')
        end
    end
    
    return false
end

function doQuery(query)
    if(db.asyncQuery ~= nil) then
        db.asyncQuery(query)
    elseif(db.query ~= nil) then
        db.query(query)
    elseif(db.executeQuery ~= nil) then
        db.executeQuery(query)
    else
        return false
    end
    
    return true
end

if(not getItemWeightById) then
    getItemWeightById = getItemWeight
end

if(not doCreateItemEx) then
    function doCreateItemEx(itemid, count)
        if(Game and type(Game) == "table" and Game.createItem and type(Game.createItem) == "function") then
            local item = Game.createItem(itemid, count)
            if item then
                return item:getUniqueId()
            end
            return false
        else
            print("[ERROR - gesior-shop-system] Error code: 1. Please contact slawkens at www.otland.net")
        end
    end
end

local gesiorShopSystem = GlobalEvent("GesiorShopSystem")
function gesiorShopSystem.onThink(interval)
    if(interval > 1000) then
        interval = interval / 1000
    end

    local started = os.mtime and os.mtime() or os.time()
    local addedItems, waitingItems = 0, 0
    local added = false

    local results = getResults()
    if(not results) then
        return true
    end
    
    for i, v in ipairs(results) do
        added = false
        local id = v.id
        local action = v.action
        local delete = v.delete_it

        if(v.exist) then
            local cid = v.cid
            local param1, param2, param3, param4 = v.param1, v.param2, v.param3, v.param4
            local add_item_type = v.param5
            local add_item_name = v.param6
            local received_item, full_weight, items_weight, item_weigth = 0, 0, 0, 0
            local item_doesnt_exist = false

            if(add_item_type == 'container' or add_item_type == 'item') then
                local item_weigth = getItemWeightById(param1, 1)
                if(type(item_weigth) == 'boolean') then -- item doesn't exist
                    print("[ERROR - gesior-shop-system] Invalid item id: " .. param1 .. ". Change/Fix `itemid1` in `z_shop_offers` then delete it from `z_ots_comunication`")
                    item_doesnt_exist = true
                else
                    if(add_item_type == 'container') then
                        container_weight = getItemWeightById(param3, 1)
                        if(type(container_weight) == 'boolean') then -- container item doesn't exist
                            print("[ERROR - gesior-shop-system] Invalid container id: " .. param3 .. ". Change/Fix `itemid2` in `z_shop_offers` then delete it from `z_ots_comunication`")
                            item_doesnt_exist = true
                        else
                            if(isItemRune(param1)) then
                                items_weight = param4 * item_weigth
                            else
                                items_weight = param4 * getItemWeightById(param1, param2)
                            end
                            
                            full_weight = items_weight + container_weight
                        end
                    elseif(add_item_type == 'item') then
                        full_weight = getItemWeightById(param1, param2)
                        if(isItemRune(param1)) then
                            full_weight = getItemWeightById(param1, 1)
                        end
                    end
                end
                
                if(not item_doesnt_exist) then
                    local free_cap = getPlayerFreeCap(cid)
                    if(full_weight <= free_cap) then
                        if(add_item_type == 'container') then
                            local new_container = doCreateItemEx(param3, 1)
                            for x = 1, param4 do
							
                                doAddContainerItem(new_container, param1, param2)
                            end
                            received_item = addItemEx(cid, new_container)
                        else
                            local new_item = doCreateItemEx(param1, param2)
                            received_item = addItemEx(cid, new_item)
                        end

                        if(received_item == RETURNVALUE_NOERROR) then
                            doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                            doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                            doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                            doPlayerSave(cid)
                            added = true
                        else
                            doPlayerSendTextMessage(cid, messageType, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. interval ..' seconds to get it.')
                        end
                    else
                        doPlayerSendTextMessage(cid, messageType, '>> '.. 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 '.. interval ..' seconds to get it.')
                    end
                end
            elseif(add_item_type == 'addon') then
                doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
                doPlayerAddOutfit(cid, param1, param3)
                doPlayerAddOutfit(cid, param2, param4)
                doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                doPlayerSave(cid)
                added = true
            elseif(add_item_type == 'mount') then
                if(not doPlayerAddMount) then
                    print("[ERROR - gesior-shop-system] Your server doesn't support mounts. Remove all items in database from your `z_shop_offers` table where `offer_type` = mount and also in `z_ots_comunication` where `param5` = mount.")
                else
                    doPlayerAddMount(cid, param1)
                    doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)

                    doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                    doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                    doPlayerSave(cid)
                    added = true
                end
            end
        end

        if(added) then
            addedItems = addedItems + 1
        else
            waitingItems = waitingItems + 1
        end
    end

    local message = ">> Shopsystem, added " .. addedItems .. " items. Still waiting with " .. waitingItems .. " items."

    if(displayExecutionTime) then
        local done, str = os.time() - started, ""
        if(os.mtime) then
            done = os.mtime() - started
            if(done < 100) then
                str = "0.0" .. done
            elseif(done < 1000) then
                str = "0." .. done
            else
                str = doSecondsFormat(done)
                if(str:len() == 0) then str = "0.0" end
            end
        end

        message = message .. " Done in: " .. str .. "s."
    end

    print(message)
    return true
end

gesiorShopSystem:interval(30000)
gesiorShopSystem:register()

 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites
  • Solução
3 minutos atrás, L3K0T disse:

--[[
    Gesior Shop System v2.0
    
    Originally written by Gesior, modified by slawkens for MyAAC.    
    Converted to Revscriptsys by Majesty.
    
    change interval 30000 to 30 if other values in this file are low
]]--

local messageType = MESSAGE_EVENT_ORANGE
local displayExecutionTime = true -- how time script took in console (true/false)

-- don't edit anything below this line
if(displayExecutionTime) then
    function doSecondsFormat(i)
        local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1.%2", 1), 0
        repeat
            str, found = string.gsub(str, "(%d)(%d%d%d),", "%1.%2,", 1)
        until found == 0
        return str
    end
end

if(not messageType) then
    messageType = MESSAGE_STATUS_CONSOLE_ORANGE
    if(not messageType) then
        messageType = MESSAGE_INFO_DESCR
    end
end

if(not getPlayerByName) then
    function getPlayerByName(name) local p = Player(name) return p ~= nil and p:getId() or false end
end


if(not isPlayer) then
    function isPlayer(cid) return Player(cid) ~= nil end
end

if(not doPlayerSave) then
    function doPlayerSave(cid)
        if(Player and type(Player) == "table" and Player.save and type(Player.save) == "function") then
            local player = Player(cid)
            if(player) then
                player:save()
            end
        end
        
        return true
    end
end

function getResults()
    if(db.storeQuery ~= nil and result.free ~= nil) then -- TFS 1.0+
        local resultId = db.storeQuery("SELECT * FROM z_ots_comunication;")
        if(resultId == false) then
            return false
        end
        
        local results = {}
        repeat
            local tmp = {}
            tmp.name = result.getDataString(resultId, "name")
            
            -- better performance when no player found
            tmp.exist = false
            tmp.cid = getPlayerByName(tmp.name)
            if(tmp.cid and isPlayer(tmp.cid)) then
                tmp.exist = true
                
                tmp.id = result.getDataInt(resultId, "id")
                tmp.action = result.getDataString(resultId, "action")
                tmp.delete_it = result.getDataInt(resultId, "delete_it")
                
                tmp.param1 = result.getDataInt(resultId, "param1")
                tmp.param2 = result.getDataInt(resultId, "param2")
                tmp.param3 = result.getDataInt(resultId, "param3")
                tmp.param4 = result.getDataInt(resultId, "param4")
                tmp.param5 = result.getDataString(resultId, "param5")
                tmp.param6 = result.getDataString(resultId, "param6")
            end
            
            table.insert(results, tmp)
        until not result.next(resultId)
        result.free(resultId)
        
        return results
    else -- TFS 0.3
        if(db.getResult ~= nil) then
            local result_plr = db.getResult("SELECT * FROM z_ots_comunication;")
            if(result_plr:getID() == -1) then
                return false
            end

            local results = {}
            repeat
                local tmp = {}
                tmp.name = tostring(result_plr:getDataString("name"))

                -- better performance when no player found
                tmp.exist = false
                tmp.cid = getPlayerByName(tmp.name)
                if(tmp.cid and isPlayer(tmp.cid)) then
                    tmp.exist = true

                    tmp.id = tonumber(result_plr:getDataInt("id"))
                    tmp.action = tostring(result_plr:getDataString("action"))
                    tmp.delete_it = tonumber(result_plr:getDataInt("delete_it"))
                    
                    tmp.param1 = tonumber(result_plr:getDataInt("param1"))
                    tmp.param2 = tonumber(result_plr:getDataInt("param2"))
                    tmp.param3 = tonumber(result_plr:getDataInt("param3"))
                    tmp.param4 = tonumber(result_plr:getDataInt("param4"))
                    tmp.param5 = tostring(result_plr:getDataString("param5"))
                    tmp.param6 = tostring(result_plr:getDataString("param6"))
                end
                
                table.insert(results, tmp)
            until not(result_plr:next())

            result_plr:free()
            return results
        else
            print('[ERROR - gesior-shop-system.lua] Your distribution is not supported')
        end
    end
    
    return false
end

function doQuery(query)
    if(db.asyncQuery ~= nil) then
        db.asyncQuery(query)
    elseif(db.query ~= nil) then
        db.query(query)
    elseif(db.executeQuery ~= nil) then
        db.executeQuery(query)
    else
        return false
    end
    
    return true
end

if(not getItemWeightById) then
    getItemWeightById = getItemWeight
end

if(not doCreateItemEx) then
    function doCreateItemEx(itemid, count)
        if(Game and type(Game) == "table" and Game.createItem and type(Game.createItem) == "function") then
            local item = Game.createItem(itemid, count)
            if item then
                return item:getUniqueId()
            end
            return false
        else
            print("[ERROR - gesior-shop-system] Error code: 1. Please contact slawkens at www.otland.net")
        end
    end
end

local gesiorShopSystem = GlobalEvent("GesiorShopSystem")
function gesiorShopSystem.onThink(interval)
    if(interval > 1000) then
        interval = interval / 1000
    end

    local started = os.mtime and os.mtime() or os.time()
    local addedItems, waitingItems = 0, 0
    local added = false

    local results = getResults()
    if(not results) then
        return true
    end
    
    for i, v in ipairs(results) do
        added = false
        local id = v.id
        local action = v.action
        local delete = v.delete_it

        if(v.exist) then
            local cid = v.cid
            local param1, param2, param3, param4 = v.param1, v.param2, v.param3, v.param4
            local add_item_type = v.param5
            local add_item_name = v.param6
            local received_item, full_weight, items_weight, item_weigth = 0, 0, 0, 0
            local item_doesnt_exist = false

            if(add_item_type == 'container' or add_item_type == 'item') then
                local item_weigth = getItemWeightById(param1, 1)
                if(type(item_weigth) == 'boolean') then -- item doesn't exist
                    print("[ERROR - gesior-shop-system] Invalid item id: " .. param1 .. ". Change/Fix `itemid1` in `z_shop_offers` then delete it from `z_ots_comunication`")
                    item_doesnt_exist = true
                else
                    if(add_item_type == 'container') then
                        container_weight = getItemWeightById(param3, 1)
                        if(type(container_weight) == 'boolean') then -- container item doesn't exist
                            print("[ERROR - gesior-shop-system] Invalid container id: " .. param3 .. ". Change/Fix `itemid2` in `z_shop_offers` then delete it from `z_ots_comunication`")
                            item_doesnt_exist = true
                        else
                            if(isItemRune(param1)) then
                                items_weight = param4 * item_weigth
                            else
                                items_weight = param4 * getItemWeightById(param1, param2)
                            end
                            
                            full_weight = items_weight + container_weight
                        end
                    elseif(add_item_type == 'item') then
                        full_weight = getItemWeightById(param1, param2)
                        if(isItemRune(param1)) then
                            full_weight = getItemWeightById(param1, 1)
                        end
                    end
                end
                
                if(not item_doesnt_exist) then
                    local free_cap = getPlayerFreeCap(cid)
                    if(full_weight <= free_cap) then
                        if(add_item_type == 'container') then
                            local new_container = doCreateItemEx(param3, 1)
                            for x = 1, param4 do
							
                                doAddContainerItem(new_container, param1, param2)
                            end
                            received_item = addItemEx(cid, new_container)
                        else
                            local new_item = doCreateItemEx(param1, param2)
                            received_item = addItemEx(cid, new_item)
                        end

                        if(received_item == RETURNVALUE_NOERROR) then
                            doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                            doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                            doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                            doPlayerSave(cid)
                            added = true
                        else
                            doPlayerSendTextMessage(cid, messageType, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. interval ..' seconds to get it.')
                        end
                    else
                        doPlayerSendTextMessage(cid, messageType, '>> '.. 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 '.. interval ..' seconds to get it.')
                    end
                end
            elseif(add_item_type == 'addon') then
                doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
                doPlayerAddOutfit(cid, param1, param3)
                doPlayerAddOutfit(cid, param2, param4)
                doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                doPlayerSave(cid)
                added = true
            elseif(add_item_type == 'mount') then
                if(not doPlayerAddMount) then
                    print("[ERROR - gesior-shop-system] Your server doesn't support mounts. Remove all items in database from your `z_shop_offers` table where `offer_type` = mount and also in `z_ots_comunication` where `param5` = mount.")
                else
                    doPlayerAddMount(cid, param1)
                    doPlayerSendTextMessage(cid, messageType, "You received >> ".. add_item_name .." << from OTS shop.")
                    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)

                    doQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                    doQuery("UPDATE `z_shop_history` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE comunication_id = " .. id .. ";")
                    doPlayerSave(cid)
                    added = true
                end
            end
        end

        if(added) then
            addedItems = addedItems + 1
        else
            waitingItems = waitingItems + 1
        end
    end

    local message = ">> Shopsystem, added " .. addedItems .. " items. Still waiting with " .. waitingItems .. " items."

    if(displayExecutionTime) then
        local done, str = os.time() - started, ""
        if(os.mtime) then
            done = os.mtime() - started
            if(done < 100) then
                str = "0.0" .. done
            elseif(done < 1000) then
                str = "0." .. done
            else
                str = doSecondsFormat(done)
                if(str:len() == 0) then str = "0.0" end
            end
        end

        message = message .. " Done in: " .. str .. "s."
    end

    print(message)
    return true
end

gesiorShopSystem:interval(30000)
gesiorShopSystem:register()

 

esse n está funcionando, oque deu sinal de vida foi aquele msm kkk

Mas Muito Obrigado mano, só de estar funcionando a entrega de itens já é 50% da minha caminhada, Jesus Te Abençoe <3

Link para o post
Compartilhar em outros sites
  • Sub-Admin
13 minutos atrás, Brum disse:

esse n está funcionando, oque deu sinal de vida foi aquele msm kkk

Mas Muito Obrigado mano, só de estar funcionando a entrega de itens já é 50% da minha caminhada, Jesus Te Abençoe <3

 

 

tente

 

SHOP_MSG_TYPE = 18
SQL_interval = 30

function onThink(interval, lastExecution)
    local result_plr = db.storeQuery("SELECT * FROM z_ots_comunication")
    if(result_plr ~= false) then
        repeat
            local id = tonumber(result.getDataInt(result_plr, "id"))
            local action = tostring(result.getDataString(result_plr, "action"))
            local delete = tonumber(result.getDataInt(result_plr, "delete_it"))
            local cid = getPlayerByName(tostring(result.getDataString(result_plr, "name")))
            if(cid) then
                local itemtogive_id = tonumber(result.getDataInt(result_plr, "param1"))
                local itemtogive_count = tonumber(result.getDataInt(result_plr, "param2"))
                local container_id = tonumber(result.getDataInt(result_plr, "param3"))
                local container_count = tonumber(result.getDataInt(result_plr, "param4"))
                local add_item_type = tostring(result.getDataString(result_plr, "param5"))
                local add_item_name = tostring(result.getDataString(result_plr, "param6"))
                local received_item = 0
                local full_weight = 0
              
                -- Script para addons e montaria full pelo Gesior --
                if(add_item_type == 'mounts') then
                local player = Player(cid)
                if (getPlayerStorageValue(cid,itemtogive_id) == -1) then
                doPlayerAddMount(cid, itemtogive_id)
                setPlayerStorageValue(cid,itemtogive_id,1)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
                doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received '.. add_item_name ..' from the 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 .. ";")
                else
                doPlayerSendTextMessage(cid,25,"You Already have this Mount.")
                end
                return TRUE
              
                end              
                -- fim do script --
                -- Script para addons e montaria full pelo Gesior --
                if(add_item_type == 'addons') then
                local player = Player(cid)
                if (getPlayerStorageValue(cid,itemtogive_id) == -1) then
                doPlayerAddOutfit(cid, itemtogive_id, 3)
                doPlayerAddOutfit(cid, container_id, 3)
                setPlayerStorageValue(cid,itemtogive_id,1)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
                doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received '.. add_item_name ..' from the 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 .. ";")
                else
                doPlayerSendTextMessage(cid,25,"You Already have this Outfit.")
                end
                return TRUE
                end              
                -- fim do script --
              
              
              
                if(add_item_type == 'container') then
                    container_weight = getItemWeight(container_id, 1)
                    if(isItemRune(itemtogive_id)) then
                        items_weight = container_count * getItemWeight(itemtogive_id, 1)
                    else
                        items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
                    end
                    full_weight = items_weight + container_weight
                else
                    full_weight = getItemWeight(itemtogive_id, itemtogive_count)
                    if(isItemRune(itemtogive_id)) then
                        full_weight = getItemWeight(itemtogive_id, 1)
                    else
                        full_weight = getItemWeight(itemtogive_id, itemtogive_count)
                    end
                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(type(received_item) == "number" and received_item == RETURNVALUE_NOERROR) then
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received '.. add_item_name ..' from the 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 .. ";")
                    else
                        doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, ' '.. add_item_name ..' from the shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
                    end
                else
                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, ' '.. add_item_name ..' The 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.')
                end
            end
        until not result.next(result_plr)
        result.free(result_plr)
    end
    return true
end

 

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo