Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Diga em poucas palavras a base utilizada (Nome do servidor ou nome do website).

Tfs 1.2

Base: 

 

 

Qual erro está surgindo/O que você procura?

[IMG]

 

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

  1. local config = {
  2.         levelRequiredToAdd = 20,
  3.         maxOffersPerPlayer = 5,
  4.         SendOffersOnlyInPZ = true,
  5.         blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
  6.         }
  7. function onSay(cid, words, param, channel)
  8.         if(param == '') then
  9.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
  10.                 return true
  11.         end
  12.         local t = string.explode(param, ",")
  13.         if(t[1] == "add") then
  14.                 if((not t[2]) or (not t[3]) or (not t[4])) then
  15.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
  16.                         return true
  17.                 end
  18.                 if(not tonumber(t[3]) or (not tonumber(t[4]))) then
  19.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
  20.                         return true
  21.                 end
  22.                 if(string.len(t[3]) > 7 or (string.len(t[4]) > 3)) then
  23.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
  24.                         return true
  25.                 end
  26.                 local item = getItemIdByName(t[2])
  27.                 if(not item) then
  28.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
  29.                         return true
  30.                 end
  31.                 if(getPlayerLevel(cid) < config.levelRequiredToAdd) then
  32.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
  33.                         return true
  34.                 end
  35.                 if(isInArray(config.blocked_items, item)) then
  36.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
  37.                         return true
  38.                 end
  39.                 if(getPlayerItemCount(cid, item) < (tonumber(t[4]))) then
  40.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
  41.                         return true
  42.                 end
  43.                 local check = db.getResult("SELECT `id` FROM `auction_system` WHERE `player` = " .. getPlayerGUID(cid) .. ";")
  44.                 if(check:getID() == -1) then
  45.                 elseif(check:getRows(true) >= config.maxOffersPerPlayer) then
  46.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
  47.                         return true
  48.                 end
  49.                 if(config.SendOffersOnlyInPZ) then  
  50.                         if(not getTilePzInfo(getPlayerPosition(cid))) then
  51.                                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
  52.                                 return true
  53.                         end
  54.                 end
  55.                 if(tonumber(t[4]) < 1 or (tonumber(t[3]) < 1)) then
  56.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
  57.                         return true
  58.                 end
  59.                                 local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
  60.                 doPlayerRemoveItem(cid, item, itemcount)
  61.                 db.executeQuery("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. getPlayerGUID(cid) .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
  62.                                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
  63.         end
  64.         if(t[1] == "buy") then
  65.                 if(not tonumber(t[2])) then
  66.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
  67.                         return true
  68.                 end
  69.                 local buy = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")
  70.                 if(buy:getID() ~= -1) then
  71.                         if(getPlayerMoney(cid) < buy:getDataInt("cost")) then
  72.                                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
  73.                                 buy:free()
  74.                                 return true
  75.                         end
  76.                         if(getPlayerName(cid) == getPlayerNameByGUID(buy:getDataInt("player"))) then
  77.                                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
  78.                                 buy:free()
  79.                                 return true
  80.                         end
  81.                         if(getPlayerFreeCap(cid) < getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")))then
  82.                                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getDataString("item_name") .. ". It weight " .. getItemWeightById(buy:getDataInt("item_id"), buy:getDataInt("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
  83.                                 buy:free()
  84.                                 return true
  85.                         end
  86.                         if(isItemStackable((buy:getDataString("item_id")))) then
  87.                                 doPlayerAddItem(cid, buy:getDataString("item_id"), buy:getDataInt("count"))
  88.                         else
  89.                                 for i = 1, buy:getDataInt("count") do
  90.                                         doPlayerAddItem(cid, buy:getDataString("item_id"), 1)
  91.                                 end
  92.                         end
  93.                         doPlayerRemoveMoney(cid, buy:getDataInt("cost"))
  94.                         db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
  95.                         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You bought " .. buy:getDataInt("count") .. " ".. buy:getDataString("item_name") .. " for " .. buy:getDataInt("cost") .. " gps!")
  96.                         db.executeQuery("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getDataInt("cost") .. " WHERE `id` = " .. buy:getDataInt("player") .. ";")
  97.                         buy:free()
  98.                 else
  99.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
  100.                 end
  101.         end
  102.         if(t[1] == "remove") then
  103.                 if((not tonumber(t[2]))) then
  104.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
  105.                         return true
  106.                 end
  107.                                 if(config.SendOffersOnlyInPZ) then  
  108.                                         if(not getTilePzInfo(getPlayerPosition(cid))) then
  109.                                                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
  110.                                                 return true
  111.                                         end
  112.                 end
  113.                 local delete = db.getResult("SELECT * FROM `auction_system` WHERE `id` = " .. (tonumber(t[2])) .. ";")      
  114.                 if(delete:getID() ~= -1) then
  115.                         if(getPlayerGUID(cid) == delete:getDataInt("player")) then
  116.                                 db.executeQuery("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
  117.                                 if(isItemStackable(delete:getDataString("item_id"))) then
  118.                                         doPlayerAddItem(cid, delete:getDataString("item_id"), delete:getDataInt("count"))
  119.                                 else
  120.                                         for i = 1, delete:getDataInt("count") do
  121.                                                 doPlayerAddItem(cid, delete:getDataString("item_id"), 1)
  122.                                         end
  123.                                 end
  124.                                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
  125.                         else
  126.                                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
  127.                         end
  128.                 delete:free()
  129.                 else
  130.                         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
  131.                 end
  132.         end
  133.         if(t[1] == "withdraw") then
  134.                 local balance = db.getResult("SELECT `auction_balance` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. ";")
  135.                 if(balance:getDataInt("auction_balance") < 1) then
  136.                         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
  137.                         balance:free()
  138.                         return true
  139.                 end
  140.                 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got " .. balance:getDataInt("auction_balance") .. " gps from auction system!")
  141.                 doPlayerAddMoney(cid, balance:getDataInt("auction_balance"))
  142.                 db.executeQuery("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. getPlayerGUID(cid) .. ";")
  143.                 balance:free()
  144.         end
  145.         if(t[1] == "list") then
  146.             local result = db.getResult("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
  147.             if result:getID() == -1 then
  148.         return true
  149.         end
  150.         local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
  151.         while true do
  152.         local id = result:getDataString("id")
  153.         local name = getPlayerNameByGUID(result:getDataString("player"))
  154.         local item_name = getItemNameById(result:getDataString("item_id"))
  155.         local count = result:getDataString("count")
  156.         local custo = result:getDataString("cost")/1000
  157.         local custo2 = result:getDataString("cost")
  158.         if isPlayer(cid) then
  159.         msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
  160.         end
  161.         if not result:next() then
  162.         break
  163.         end
  164.         end
  165.         doPlayerPopupFYI(cid, msg) return true
  166.         end
  167.         return true
  168. end

 

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

1613731_1.png

Link para o post
Compartilhar em outros sites
local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if player:getName() == getPlayerNameByGUID(buy:getNumber("player"))) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")))then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player")) then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

Editado por FlavioHulk (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if ( player:getName() == getPlayerNameByGUID(buy:getNumber("player")) ) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player")) then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

 

Te ajudei ?? Que tal fazer uma contribuição ?

Doar

Link para o post
Compartilhar em outros sites
Citar

local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if ( player:getName() == getPlayerNameByGUID(buy:getNumber("player")) ) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player") then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

 

 

Te ajudei ?? Que tal fazer uma contribuição ?

Doar

Link para o post
Compartilhar em outros sites

Alguém pode mim ajudar o script não esta dando erro mais nenhum item vai para o sie

1613731_1.png

Link para o post
Compartilhar em outros sites
3 horas atrás, otfacil disse:

Alguém pode mim ajudar o script não esta dando erro mais nenhum item vai para o sie

Eu tenho este aqui porém está dando problema na hora de alguém comprar está recolhendo o dinheiro porém não está dando o item e retirando o item do vendedor se alguém souber ajustar.

local config = {
    level_add = 20,
    max_ofertas = 5,
    ofertas_pz = true,
    itens_bloqueados = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if (param == 'saldo') then
        local consulta = db.storeQuery("SELECT * FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        local saldo = result.getNumber(consulta, "auction_balance")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Seu saldo é de " .. saldo .. " gps de suas vendas no mercado!")
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Seu saldo é de " .. saldo .. " gps de suas vendas no mercado!")
        return true
    end
    if(param == '') or (param == 'info') then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Comandos para utilizar este sistema:\n!oferta saldo\nUse este comando para verificar o saldo de suas vendas.\n!oferta add, nomedoitem, preço, qtd\nexemplo: !oferta add,plate armor,500,1\n\n\n!oferta comprar,id_da_compra\nexemplo: !oferta comprar,1943\n\n\n!oferta remover,id_da_compra\nexemplo: !oferta remover,1943\n\n\n!oferta sacar, qtd\nexemplo: !oferta sacar, 1000.\n")
        return true
    end
    local split = param:split(",")
    if split[2] == nil  then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Parâmetros necessários. Use !oferta info para mais informações!")
        return false
    end
    split[2] = split[2]:gsub("^%s*(.-)$", "%1")
    _BUSCA_DB = db.storeQuery("SELECT * FROM `auction_system` WHERE `player` = " .. player:getGuid())
    if(split[1] == "add") then
        if(not tonumber(split[3]) or (not tonumber(split[4]))) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Use somente números.")
            return true
        end
        if(string.len(split[3]) > 7 or (string.len(split[4]) > 3)) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Este preço ou a quantidade itens é muito alta.")
            return true
        end
        local itemType, item_s = ItemType(split[2]), ItemType(split[2]):getId()
        if(not item_s) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "O item "..itemType.." não existe!")
            return true
        end
        if(player:getLevel() < config.level_add) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas vcê precisa de level igual ou superior a (" .. config.level_add .. ") para continuar.")
            return true
        end
        if(isInArray(config.itens_bloqueados, item_s)) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Você não pode adicionar este item.")
            return true
        end
        if(player:getItemCount(item_s) < tonumber(split[4])) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas você não tem este item.")
            return true
        end
        local amount, tmp_BUSCA_DB  = 0, _BUSCA_DB
        while tmp_BUSCA_DB ~= false do
            tmp_BUSCA_DB = result.next(_BUSCA_DB)
            amount = amount + 1
        end
        if _BUSCA_DB ~= false then
            local limit = amount >= config.max_ofertas
            if limit then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas você atingiu o limite máximo(" .. config.max_ofertas .. ") de publicações de venda de itens.")
                return true
            end
            if(config.SendOffersOnlyInPZ) then    
            if(not getTilePzInfo(player:getPosition())) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas você só pode usar este comando estando em protection zone.")
                return true
            end
        end
    end
    if(tonumber(split[4]) < 1 or (tonumber(split[3]) < 1)) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas você precisa informar um número maior que 0.")
        return true
    end
    local itemcount, costgp = math.floor(split[4]), math.floor(split[3])
    player:removeItem(item_s, itemcount)
    db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. split[2] .. "\", " .. item_s .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Parabéns! Você adicionou para à venda " .. itemcount .." " .. split[2] .." por " .. costgp .. " gps!")
end
if(split[1] == "comprar") then
    _BUSCA_DB = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = ".. tonumber(split[2]))
    local player_id, player_vendas, item_ids, costs, item_names, counts = player:getGuid(), result.getNumber(_BUSCA_DB, "player"), result.getNumber(_BUSCA_DB, "item_id"), result.getNumber(_BUSCA_DB, "cost"), result.getString(_BUSCA_DB, "item_name"), result.getNumber(_BUSCA_DB, "count")
   
    if(not tonumber(split[2])) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas somente números são aceitos.")
        return true
    end
 
    if(_BUSCA_DB ~= false) then
        local total_custo = costs - player:getMoney()
        if(player:getMoney() < costs) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas você não possuí a quantia necessária para comprar. São necessários: "..costs.."gps para comprar o item: "..item_names..". Você tem: " .. player:getMoney() .. "gps. Você precisa de: "..total_custo.." gps.")
            return true
        end
        if(player_id == player_vendas) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas você não pode comprar seu próprio item.")
        return true
    end
        if player:removeMoney(costs) then
            if(isItemStackable((item_ids))) then
                player:addItem(item_ids, counts)
            else
                for i = 1, count do
                    player:addItem(item_ids, 1)
                end
            end
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. split[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "Parabéns! Você comprou " .. counts .. " ".. item_names .. " por " .. costs .. " gps com sucesso!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. costs .. " WHERE `id` = " .. player_vendas .. ";")
        end
else
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas o ID "..split[2].." não existe!.")
end
end
 
if(split[1] == "remover") then
    local _BUSCA_DB = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = ".. tonumber(split[2]))
    local player_id, player_vendas, item_ids, costs, item_names, counts = player:getGuid(), result.getNumber(_BUSCA_DB, "player"), result.getNumber(_BUSCA_DB, "item_id"), result.getNumber(_BUSCA_DB, "cost"), result.getString(_BUSCA_DB, "item_name"), result.getNumber(_BUSCA_DB, "count")
    if((not tonumber(split[2]))) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas somente números são aceitos.")
        return true
    end
    if(config.SendOffersOnlyInPZ) then    
    if(not getTilePzInfo(player:getPosition())) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
        return true
    end
end  
if(_BUSCA_DB ~= false) then
    if(player_id == player_vendas) then
    db.query("DELETE FROM `auction_system` WHERE `id` = " .. split[2] .. ";")
    if(isItemStackable(item_ids)) then
        player:addItem(item_ids, counts)
    else
        for i = 1, counts do
            player:addItem(item_ids, 1)
        end
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Parabéns! A oferta "..split[2].." foi removida com sucesso do mercado.\nVocê recebeu: "..counts.." "..item_names..".")
else
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas essa oferta não é sua.")
end
result.free(resultado)
else
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas este ID não existe.")
end
end
if(split[1] == "sacar") then
    if((not tonumber(split[2]))) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Desculpe, mas somente números são aceitos.")
        return true
    end
    local balance = db.storeQuery("SELECT * FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
    local auction_balance = result.getNumber(balance, "auction_balance")
    if(auction_balance < 1) then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você não possuí saldo suficiente para sacar.")
        result.free(balance)
        return true
    end
    local tz = auction_balance - split[2]
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Você sacou " .. split[2] .. " gps de suas vendas no mercado! Seu saldo é de: "..tz.."gps.")
    player:addMoney(tz)
    db.query("UPDATE `players` SET `auction_balance` = ".. tz .." WHERE `id` = " .. player:getGuid() .. ";")
    result.free(balance)
end
 
return true
end

 

Link para o post
Compartilhar em outros sites
local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if player:getName() == getPlayerNameByGUID(buy:getNumber("player")) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")))then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player")) then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

Link para o post
Compartilhar em outros sites
12 horas atrás, FlavioHulk disse:

local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if player:getName() == getPlayerNameByGUID(buy:getNumber("player")) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")))then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player")) then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

Testei aqui e deu erro

asdasd.jpg

Link para o post
Compartilhar em outros sites
local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if player:getName() == getPlayerGUIDByName(buy:getNumber("player")) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")))then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player")) then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

Link para o post
Compartilhar em outros sites
8 horas atrás, FlavioHulk disse:

local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if player:getName() == getPlayerGUIDByName(buy:getNumber("player")) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")))then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player")) then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

Deu mesmo erro na linha 96 e 136 eu arrumei (), porém não funciona.

 

 

in.jpg

Link para o post
Compartilhar em outros sites
local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item.itemid) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if player:getName() == getPlayerGUIDByName(buy:getNumber("player")) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")))then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player")) then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

Link para o post
Compartilhar em outros sites
  • 2 weeks later...

@FlavioHulk 

Em 18/02/2018 em 12:07, FlavioHulk disse:

local config = {
    levelRequiredToAdd = 20,
    maxOffersPerPlayer = 5,
    SendOffersOnlyInPZ = true,
    blocked_items = {2165, 2152, 2148, 2160, 2166, 2167, 2168, 2169, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2343, 2433, 2640, 6132, 6300, 6301, 9932, 9933}
}
function onSay(player, words, param)
    if param == '' then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
        return true
    end

    local t = param:split(",")
    if t[1] == "add" then
        if not t[2] or not t[3] or not t[4] then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
            return true
        end

        if not tonumber (t[3]) or not tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't set valid price or items count.")
            return true
        end

        if string.len(t[3]) > 7 or string.len(t[4]) > 3 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This price or item count is too high.")
            return true
        end

        local item = getItemIdByName(t[2])
        if not item then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end

        if player:getLevel() < config.levelRequiredToAdd then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have required (" .. config.levelRequiredToAdd .. ") level.")
            return true
        end

        if table.contains(config.blocked_items, item.itemid) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This item is blocked.")
            return true
        end

        if player:getItemCount(item) < tonumber(t[4]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't have this item(s).")
            return true
        end

        local check = db.storeQuery("SELECT `id` FROM `auction_system` WHERE `player` = " .. player:getGuid() .. ";")
        if check:getID() == -1 then
            elseif check:getRows(true) >= config.maxOffersPerPlayer then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry you can't add more offers (max. " .. config.maxOffersPerPlayer .. ")")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you add offert to database.")
                return true
            end
        end

        if tonumber(t[4]) < 1 or tonumber(t[3]) < 1 then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have to type a number higher than 0.")
            return true
        end

        local itemcount, costgp = math.floor(t[4]), math.floor(t[3])
        player:removeItem(item, itemcount)
        db.query("INSERT INTO `auction_system` (`player`, `item_name`, `item_id`, `count`, `cost`, `date`) VALUES (" .. player:getGuid() .. ", \"" .. t[2] .. "\", " .. getItemIdByName(t[2]) .. ", " .. itemcount .. ", " .. costgp ..", " .. os.time() .. ")")
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You successfully add " .. itemcount .." " .. t[2] .." for " .. costgp .. " gps to offerts database.")
    end

    if t[1] == "buy" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        local buy = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")
        if buy:getID() ~= -1 then
            if player:getMoney() < buy:getNumber("cost") then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enoguh GP.")
                buy:free()
                return true
            end

            if player:getName() == getPlayerGUIDByName(buy:getNumber("player")) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you can't buy your own items.")
                buy:free()
                return true
            end

            if player:getFreeCapacity() < getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")))then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You try to buy a " .. buy:getString("item_name") .. ". It weight " .. getItemWeightById(buy:getNumber("item_id"), buy:getNumber("count")) .. " cap oz. and you have only " .. getPlayerFreeCap(cid) .. " oz. free capacity. Put some items to depot and try again.")
                buy:free()
                return true
            end

            local itemStacks = ItemType(buy:getString("item_id")):isStackable()
            if itemStacks then
                player:addItem(buy:getString("item_id"), buy:getNumber("count"))
            else
                for i = 1, buy:getNumber("count") do
                    player:addItem(buy:getString("item_id"), 1)
                end
            end

            player:removeMoney(buy:getNumber("cost"))
            db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You bought " .. buy:getNumber("count") .. " ".. buy:getString("item_name") .. " for " .. buy:getNumber("cost") .. " gps!")
            db.query("UPDATE `players` SET `auction_balance` = `auction_balance` + " .. buy:getNumber("cost") .. " WHERE `id` = " .. buy:getNumber("player") .. ";")
            buy:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "remove" then
        if not tonumber(t[2]) then
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
            return true
        end

        if config.SendOffersOnlyInPZ then  
            if not Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You must be in PZ area when you remove offerts from database.")
                return true
            end
        end

        local delete = db.storeQuery("SELECT * FROM `auction_system` WHERE `id` = " .. tonumber(t[2]) .. ";")      
        if delete:getID() ~= -1 then
            if player:getGuid() == delete:getNumber("player")) then
                db.query("DELETE FROM `auction_system` WHERE `id` = " .. t[2] .. ";")
                local itemStack = ItemType(delete:getString("item_id")):isStackable()
                if itemStack then
                    player:addItem(delete:getString("item_id"), delete:getNumber("count"))
                else
                    for i = 1, delete:getNumber("count") do
                         player:addItem(delete:getString("item_id"), 1)
                    end
                end
                player:sendTextMessage(MESSAGE_INFO_DESCR, "Your offert has been deleted from offerts database.")
            else
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "This is not your offert!")
            end
            delete:free()
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Wrong ID.")
        end
    end

    if t[1] == "withdraw" then
        local balance = db.storeQuery("SELECT `auction_balance` FROM `players` WHERE `id` = " .. player:getGuid() .. ";")
        if balance:getNumber("auction_balance") < 1 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have money on your auction balance.")
            balance:free()
            return true
        end

        player:sendTextMessage(MESSAGE_INFO_DESCR, "You got " .. balance:getNumber("auction_balance") .. " gps from auction system!")
        player:addMoney(balance:getNumber("auction_balance"))
        db.query("UPDATE `players` SET `auction_balance` = '0' WHERE `id` = " .. player:getGuid() .. ";")
        balance:free()
    end

    if t[1] == "list" then
        local result = db.storeQuery("SELECT * FROM `auction_system` ORDER BY `auction_system`.`id` ASC")
        if result:getID() == -1 then
            return true
        end

        local msg = "Trade Offline:\n\n!offer buy, ID\n!offer remove, ID\n!offer add, ItemName, ItemPrice, ItemCount\n\n"
        while true do
            local id = result:getString("id")
            local name = getPlayerNameByGUID(result:getString("player"))
            local item_name = getItemNameById(result:getString("item_id"))
            local count = result:getString("count")
            local custo = result:getString("cost")/1000
            local custo2 = result:getString("cost")
            if isPlayer() then
                msg = ""..msg.."ID : "..id.."\nItem Name : "..item_name.." - Item Count : "..count.." - Item Cust : "..custo.."k("..custo2.."GP) - Dono : "..name.."\n"
            end
            if not result:next() then
                break
            end
        end
        player:popupFYI(msg)
        return true
    end
    return true
end

 

 

Continua o Erro!

 

d05942363357628ae61cfa0bc94c8328..jpg

1613731_1.png

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.

  • Conteúdo Similar

    • Por cloudrun2023
      CloudRun - Sua Melhor Escolha para Hospedagem de OTServer!
      Você está procurando a solução definitiva para hospedar seu OTServer com desempenho imbatível e segurança inigualável? Não procure mais! Apresentamos a CloudRun, sua parceira confiável em serviços de hospedagem na nuvem.
       
      Recursos Exclusivos - Proteção DDoS Avançada:
      Mantenha seu OTServer online e seguro com nossa robusta proteção DDoS, garantindo uma experiência de jogo ininterrupta para seus jogadores.
       
      Servidores Ryzen 7 Poderosos: Desfrute do poder de processamento superior dos servidores Ryzen 7 para garantir um desempenho excepcional do seu OTServer. Velocidade e estabilidade garantidas!
       
      Armazenamento NVMe de Alta Velocidade:
      Reduza o tempo de carregamento do jogo com nosso armazenamento NVMe ultrarrápido. Seus jogadores vão adorar a rapidez com que podem explorar o mundo do seu OTServer.
       
      Uplink de até 1GB:
      Oferecemos uma conexão de alta velocidade com até 1GB de largura de banda, garantindo uma experiência de jogo suave e livre de lag para todos os seus jogadores, mesmo nos momentos de pico.
       
      Suporte 24 Horas:
      Estamos sempre aqui para você! Nossa equipe de suporte está disponível 24 horas por dia, 7 dias por semana, para resolver qualquer problema ou responder a qualquer pergunta que você possa ter. Sua satisfação é a nossa prioridade.
       
      Fácil e Rápido de Começar:
      Configurar seu OTServer na CloudRun é simples e rápido. Concentre-se no desenvolvimento do seu jogo enquanto cuidamos da hospedagem.
       
      Entre em Contato Agora!
      Website: https://central.cloudrun.com.br/index.php?rp=/store/cloud-ryzen-brasil
      Email: [email protected]
      Telefone: (47) 99902-5147

      Não comprometa a qualidade da hospedagem do seu OTServer. Escolha a CloudRun e ofereça aos seus jogadores a melhor experiência de jogo possível. Visite nosso site hoje mesmo para conhecer nossos planos e começar!
       
      https://central.cloudrun.com.br/index.php?rp=/store/cloud-ryzen-brasil
       
      CloudRun - Onde a Velocidade Encontra a Confiabilidade!
       

    • Por FeeTads
      SALVE rapaziada do TK, esses dias vim pensando em novos scripts pro meu OT, e em um deles eu precisava que determinada area não contasse frag pro player que matasse outros, PORÉM eu precisava que os players que morressem nessa area ainda assim tivessem as penalidades da sua morte, procurei por ai, achei alguns scripts que apenas tiravam o SKULL e não realmente o FRAG do player.

      **script atualizado 22/10/2023** - melhorado e otimizado, levei o script pra puxar as infos por .lua / creatureScripts

      vou disponibilizar o code aqui, e o que fazer pra determinada area não contar frag.

      SOURCE OTX 2 / TFS 0.x, Funciona em TFS 1.x mudando as tags e ajeitando as sintaxes.

      vá em creatureevent.cpp

      procure por:
      else if(type == "preparedeath") _type = CREATURE_EVENT_PREPAREDEATH;
      Adiciona abaixo:
      else if(type == "nocountfrag") _type = CREATURE_EVENT_NOCOUNTFRAG;

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath";  
      Adicione abaixo: 
      case CREATURE_EVENT_NOCOUNTFRAG: return "noCountFragArea";

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList";
      Adicione abaixo:
      case CREATURE_EVENT_NOCOUNTFRAG: return "cid, target";

      agora no mesmo arquivo, vá até o final do arquivo e adicione essa função:
      uint32_t CreatureEvent::executeNoCountFragArea(Creature* creature, Creature* target) { //noCountFragArea(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::ostringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; if(m_scriptData) scriptstream << *m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::ostringstream desc; desc << creature->getName(); env->setEvent(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::noCountFragArea] Call stack overflow." << std::endl; return 0; } }

      agora vá em creatureevent.h

      procure por:
      CREATURE_EVENT_PREPAREDEATH
      adicione abaixo:
      CREATURE_EVENT_NOCOUNTFRAG

      procure por:
      uint32_t executePrepareDeath(Creature* creature, DeathList deathList);
      Adicione abaixo:
      uint32_t executeNoCountFragArea(Creature* creature, Creature* target);

      agora vá em player.cpp

      procure por:
      bool Player::onKilledCreature(Creature* target, DeathEntry& entry)
      abaixo de:
      War_t enemy; if(targetPlayer->getEnemy(this, enemy)) { if(entry.isLast()) IOGuild::getInstance()->updateWar(enemy); entry.setWar(enemy); }
      Adicione o seguinte código:
      if (targetPlayer){ CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_NOCOUNTFRAG); for (const auto &event : killEvents) { if (!event->executeNoCountFragArea(this, target)) { return true; } } }

      //

      Feito isso, tudo completo na sua source, agora é necessário adicionar o creaturescript dentro do servidor

      vá até creaturescripts/scripts
      crie um arquivo chamado, "noCountFragInArea.lua"
      e dentro dele cole o código:
       
      --[[ script feito por feetads / TibiaKing ]]-- --[[ discord: feetads / FeeTads#0246 ]]-- -- Add positions here for which you do not want to count frags local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, -- from = area superior esquerda / to = area inferior direita (formando um quadrado) } local onlyKillerInArea = false -- only killer need to be in area? function noCountFragArea(cid, target) if not isCreature(cid) or not isCreature(target) then return true end local posKiller = getPlayerPosition(cid) local posTarget = getPlayerPosition(target) for i = 1, #areas do local area = areas[i] if isInArea(posKiller, area.from, area.to) then if onlyKillerInArea then return false elseif isInArea(posTarget, area.from, area.to) then return false end end end return true end
      agora em creaturescripts.xml
      <event type="nocountfrag" name="fragarea" event="script" value="noCountFragInArea.lua"/>
      agora em creaturescripts/scripts/login.lua
       procure por OU semelhante a esse:
      registerCreatureEvent(cid, "AdvanceSave")
      e abaixo adicione:
      registerCreatureEvent(cid, "fragarea")

      //


      Agora tudo certo, quando quiser adiciona uma area que não pega frag, vá até o script e apenas coloque a area, igual o demonstrado no script

      Exemplo:
      local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, [2] = {from = {x = 1000, y = 1000, z = 7}, to = {x = 1100, y = 1100, z = 7}}, }
      assim somente colocando a area no script e abrindo o server ou dando /reload, já funcionará a area como não pegar frag.
      Esse sistema pode ser bom pra areas de pvp ativo, onde você ainda quer que o player que morrer perca os atributos, como se fosse uma morte normal, porém não conta frag pra quem matar.
      Bom pra sistemas tipo castle 48h (guild war), onde há diversas mortes e risco de pegar red, atrapalhando a war.

      Façam bom proveito dos scripts, e deixem os créditos no script rsrs

      **Eu fiz as alterações e o simples código por isso vim disponibilizar, créditos meus**
    • Por Muvuka
      Abri canal a força creaturescript acho que funcione no creaturescript cria script creaturescript
       
      <channel id="9" name="HELP" logged="yes"/>
      <channel id="12" name="Report Bugs" logged="yes"/>
      <channel id="13" name="Loot" logged="yes"/>
      <channel id="14" name="Report Character Rules Tibia Rules" logged="yes"/>
      <channel id="15" name="Death Channel"/>
      <channel id="6548" name="DexSoft" level="1"/>
      <channel id="7" name="Reports" logged="yes"/>
       
      antes de 
              if(lastLogin > 0) then adicione isso:
                      doPlayerOpenChannel(cid, CHANNEL_HELP) doPlayerOpenChannel(cid, 1,  2, 3) = 1,2 ,3 Channels, entendeu? NÃO FUNCIONA EU QUERO UM MEIO DE ABRI SEM USA A SOURCE
       
      EU NÃO CONSEGUI ABRI EU NÃO TENHO SOURCE
       
       
    • Por bolachapancao
      Rapaziada seguinte preciso de um script que ao utilizar uma alavanca para até 4 jogadores.
      Os jogadores serão teleportados para hunt durante uma hora e depois de uma hora os jogadores serão teleportados de volta para o templo.
       
      Observação: caso o jogador morra ou saia da hunt o evento hunt é cancelado.

      Estou a base canary
      GitHub - opentibiabr/canary: Canary Server 13.x for OpenTibia community.
       
    • Por RAJADAO
      .Qual servidor ou website você utiliza como base? 
      Sabrehaven 8.0
      Qual o motivo deste tópico? 
      Ajuda com novos efeitos
       
      Olá amigos, gostaria de ajuda para introduzir os seguintes efeitos no meu servidor (usando o Sabrehaven 8.0 como base), adicionei algumas runas novas (avalanche, icicle, míssil sagrado, stoneshower & Thunderstorm) e alguns novos feitiços (exevo mas san, exori san, exori tera, exori frigo, exevo gran mas frigo, exevo gran mas tera, exevo tera hur, exevo frigo hur) mas nenhum dos efeitos dessas magias parece existir no servidor, alguém tem um link para um tutorial ou algo assim para que eu possa fazer isso funcionar?
      Desculpe pelo mau inglês, sou brasileiro.

      Obrigado!


      AVALANCHE RUNE id:3161 \/
      (COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)

      STONESHOWER RUNE id:3175 \/
      (COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_STONES)
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)

      THUNDERSTORM RUNE id:3202 \/
      (COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_E NERGYHIT)
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)

      ICICLE RUNE id:3158 \/
      COMBAT_ICEDAMAGE
      CONST_ME_ICEAREA
      CONST_ANI_ICE

      SANTO MÍSSIL RUNA id:3182 \/
      (COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)

      CONST_ME_PLANTATTACK (exevo gran mas tera)
      CONST_ME_ICETORNADO (exevo gran mas frigo)
      CONST_ME_SMALLPLANTS (exevo tera hur)
      CONST_ME_ICEAREA (exevo frigo hur)
      CONST_ME_ICEATTACK (exori frigo)
      CONST_ME_CARNIPHILA (exori tera)

      EXORI SAN \/
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
      CONST_ME_HOLYDAM IDADE

      EXEVO MAS SAN \/
      CONST_ME_HOLYAREA
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo