Ir para conteúdo

Featured Replies

Postado

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

  • Respostas 20
  • Visualizações 2k
  • Created
  • Última resposta

Top Posters In This Topic

Posted Images

Postado
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)

Postado
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

Participe da conversa

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

Visitante
Responder

Quem Está Navegando 0

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

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo