Ir para conteúdo
  • Cadastre-se

Npc Auction Versão 1.0 [Atualizado]


Posts Recomendados

encontrei 2 bugs:

1º Bug: (Leve)

Spoiler

 ha um mes atras mais ou menos vc fez um script pra mim de só vender VIP Coins no NPC auction.

de um tempo pra ca, eu percebi um pequeno "bug"
vou explicar:
João coloca pra vender 5 VIP coins no NPC auction por 10kk cada coin...
Pedro coloca pra vender 10 VIP Coins no NPC auction por 10kk cada coin...
até ai tudo bem.

só que quando vou dar trade no NPC, as duas ofertas mostram:
23:53 VIP Coin Market: Voce so pode comprar 10x VIP Coins desta oferta.
23:53 VIP Coin Market: Voce so pode comprar 10x VIP Coins desta oferta.

sendo que uma oferta é 5, e outra 10 VIP Coins.
pode me ajudar?


Eu copiei o script que voce me mandou e mudei algumas frases nele (coloquei em portugues)

 

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser,msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid,string.lower(msg)
    if isInArray({'apprise', 'check', 'items', 'item', 'list'}, msg) then
        local qry,k,str = db.getResult("SELECT `item_id`, `count`, `price` FROM `shop_npc` WHERE `player_id` = "..getPlayerGUID(cid)),0,"My Items Deposited:\n\n"
        if(qry:getID() ~= -1) then
            repeat
                k = k + 1
                str = str..""..qry:getDataInt("count").." "..getItemNameById(qry:getDataInt("item_id")).." - "..qry:getDataInt("price").." Gps "..(tonumber(qry:getDataInt("count")) > 1 and "Each" or "").."\n"
            until not (qry:next()) or k >= _config_npc_shop.items_limit
            qry:free()
            doPlayerPopupFYI(cid, str)
        else
            selfSay("Voce nao ofertou nenhum VIP Coin na minha loja, tente {deposit}", cid)
        end
    elseif isInArray({'report', 'withdraw'}, msg) then
        if getDepositNpc(cid) <= 0 then
            selfSay("Desculpe, seu balance é de 0 gps.", cid)
        else
            selfSay("Voce possui {"..getDepositNpc(cid).."} gps depositado, voce deseja retirar quantos gps?", cid)
            talkState[talkUser] = 8
        end
    elseif talkState[talkUser] == 8 then
        if tonumber(msg) and tonumber(msg) > 0 and tonumber(msg) <= getDepositNpc(cid) then
            setPlayerStorageValue(cid, _config_npc_shop.WithDraw_storage, (getDepositNpc(cid)-tonumber(msg)))
            doPlayerAddMoney(cid, tonumber(msg))
            selfSay("voce retirou "..msg.." gps, agora voce possui "..getDepositNpc(cid).." de balance.", cid)
            talkState[talkUser] = 0
        else
            selfSay("Voce nao pode remover essa quantia.", cid)
            talkState[talkUser] = 0
        end
    elseif isInArray({'deposit', 'depositar', 'sell', 'selling','vender'}, msg) then
        if getRowsShopByPlayer(getPlayerGUID(cid)) < _config_npc_shop.items_limit then
            selfSay('Se voce deseja colocar a venda seus VIP Coins digite: {VIP Coin} ', cid)
            talkState[talkUser] = 2
        else
            selfSay('Desculpe, voce ja possui vip coins ofertados no trade, verifique no {check} ou no {trade}, caso queira remover sua oferta digite {remove}', cid)
            talkState[talkUser] = 0 
        end 
    elseif talkState[talkUser] == 2 then
        name,item = msg,getItemByName(msg)
        if msg == '' or tonumber(msg) or not item then
            talkState[talkUser] = 0 
            selfSay("Desculpe, voce digitou o nome errado, tente depositar novamente: {deposit}", cid) return true
        elseif not isItemMovable(item) or not isInArray(_config_npc_shop.items_block, getItemIdByName(name)) then
            talkState[talkUser] = 0 
            selfSay("Voce nao pode adicionar este item. somente {VIP Coins} sao permitidos!", cid) return true
        end
        item = getItemIdByName(name)
        selfSay('Quantos VIP Coins voce deseja ofertar? Voce pode ofertar de {1} a {100} VIP Coins por vez.', cid)
        talkState[talkUser] = 3
    elseif talkState[talkUser] == 3 then
        if tonumber(msg) and tonumber(msg) > 0 and tonumber(msg) <= 100 and getPlayerItemCount(cid, item) >= tonumber(msg) then
            count = tonumber(msg)
            selfSay('Muito bem... A cada VIP Coin ofertado vai custar quanto? Valor maximo: 10kk --> {10000000}', cid)
            talkState[talkUser] = 4
        else
            selfSay(getPlayerItemCount(cid, item) < tonumber(msg) and 'Desculpe, mas voce nao possui '..msg..' VIP Coins para depositar ao meu trade ' or 'enter a valid number from 1 to 100.', cid)
        end
    elseif talkState[talkUser] == 4 then
        if tonumber(msg) and tonumber(msg) > 0 and tonumber(msg) < 10000001 then
            price = msg
            selfSay('Voce tem certeza que quer adicionar {'..count..' '..name..'} por {'..price..'} gps '..(count > 1 and 'each' or '')..' ,por cada VIP Coin ofertado? vai custar '.. _config_npc_shop.each_deposit ..' gps pra ofertar, ok? {yes}', cid)
            talkState[talkUser] = 6
        else
            selfSay('Desculpe, o valor maximo para ofertar cada VIP Coin é de 10kk --> {10000000}', cid)
        end
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 6 then
        if doPlayerRemoveMoney(cid, _config_npc_shop.each_deposit) then
            item,price = getItemIdByName(name),price
            if doPlayerRemoveItem(cid, item, count) then
                doAddItemShop(cid, item, count, getItemType(item), tonumber(price))
                selfSay('Parabens, o item foi adicionado com sucesso ao {trade} ,ficara ofertado ate o dia: '..os.date("%d %B %Y %X ", (os.time() + _config_npc_shop.days_limit*24*60*60))..'.', cid)
                doBroadcastMessage("O Player ["..getCreatureName(cid).."]: adicionou uma oferta de VIP Coins no NPC [VIP COIN MARKET] no templo", 22)
                doBroadcastMessage("O Player ["..getCreatureName(cid).."]: adicionou uma oferta de VIP Coins no NPC [VIP COIN MARKET] no templo", MESSAGE_STATUS_CONSOLE_ORANGE)
                talkState[talkUser] = 0
            else
                selfSay('Desculpe, Nao pode ser completado porque nao possui o item.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('Desculpe, mas voce nao possui gps suficientes para depositar seus VIP Coins.', cid)
                    talkState[talkUser] = 0
                end
            elseif isInArray({'trade', 'comprar', 'buy', 'buying', 'shop'}, msg) then
                    local qry = db.getResult("SELECT `id`, `player_id`, `item_id`, `count`, `price` FROM `shop_npc`;")
                    local trade,show = {},true
                    if(qry:getID() ~= -1) then
                        repeat
                            if not _config_npc_shop.ShowMyItems_shop and qry:getDataInt("player_id") == getPlayerGUID(cid) then
                                show = false
                            end
                            if show == true then
                                table.insert(trade,{id= qry:getDataInt("item_id"), buy= qry:getDataInt("price"), db= qry:getDataInt("id"), name= getItemNameById(qry:getDataInt("item_id")), amount = qry:getDataInt("count")})
                            end
                        until not(qry:next())
                        qry:free()
                    else
                        selfSay('Desculpe, mas não existe VIP Coins ofertados no momento.', cid) return true
                    end
                    local items = {} 
                    for _, item in ipairs(trade) do
                        items[item.id] = {item_id = item.id, buyPrice = item.buy, changeDb = item.db, subType = item.amount, realName = item.name}
                    end 
                    local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) 
                        if items[item].buyPrice ~= 0 and amount <= items[item].subType then
                            if isItemInShop(items[item].changeDb, amount) then
                                doPlayerRemoveMoney(cid, amount * items[item].buyPrice)
                                if isItemStackable(items[item].item_id) then
                                    doPlayerAddItem(cid, items[item].item_id, amount) 
                                else
                                    for i = 1, amount do 
                                        doPlayerAddItem(cid, items[item].item_id, 1) 
                                    end
                                end
                                local player,sell_price = getPlayerByNameWildcard(getPlayerByShopID(items[item].changeDb)),amount*items[item].buyPrice
                                if(not player) then
                                    doSetDepositNpc(getPlayerGUIDByName(getPlayerByShopID(items[item].changeDb)), sell_price, "add")
                                    local file = io.open(OfflineMessagesConfig.messageSavingDirectory .. getPlayerByShopID(items[item].changeDb) .. '.Gandhi', 'a+')
                                    if(not file) then return true end
                                    local msgfrom, msgoff = "[VIP Coin Market]",{"Vendeu "..amount.." "..getItemNameById(items[item].item_id).." de seus VIP Coins ofertados, voce recebeu "..sell_price.." gps pelos VIP Coins, para retirar va ate o NPC e digite withdraw."}
                                    file:write(OfflineMessagesConfig.messageFormatString:format(os.date(OfflineMessagesConfig.dateFormatString), msgfrom, table.concat(msgoff, OfflineMessagesConfig.separatorAfterNickname)) .. '\n')
                                    file:close()
                                else
                                    setPlayerStorageValue(player,_config_npc_shop.WithDraw_storage, getDepositNpc(player)+sell_price)
                                    doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE,"[VIP Coin Market] Vendeu "..amount.." "..getItemNameById(items[item].item_id).." de seus VIP Coins ofertados, voce recebeu "..sell_price.." gps pelos VIP Coins, para retirar va ate o NPC e digite withdraw.") 
                                end
                                if amount == items[item].subType then
                                    doDeleteShopItem(items[item].changeDb)
                                else
                                    doRemoveShopItem(items[item].changeDb, amount)
                                end
                                selfSay('Aqui esta seus VIP Coins, Volte sempre!', cid)
                                closeShopWindow(cid)
                            else
                                selfSay('desculpe mas este item acabou de ser comprado.', cid)
                                closeShopWindow(cid)
                            end 
                        else
                            selfSay('Voce so pode comprar {'..items[item].subType..'x} VIP Coins desta oferta.', cid)
                        end 
                    end 
                    openShopWindow(cid, trade, onBuy, onSell)
                elseif isInArray({'retirar', 'remove', 'retire', 'pegar', 'get'}, msg) then
                    selfSay('Para remover seu VIP Coin do meu trade digite: {VIP Coin}', cid)
                        talkState[talkUser] = 15
                    elseif talkState[talkUser] == 15 then
                        name,item = msg,getItemByName(msg)
                        if msg == '' or tonumber(msg) or not item then
                            selfSay("Este item nao existe.", cid) return true
                        end
                        local qry = db.getResult("SELECT `id`, `item_id`, `count` FROM `shop_npc` WHERE `player_id` = "..getPlayerGUID(cid).." and `item_id` = "..getItemIdByName(name))
                        if(qry:getID() ~= -1) then
                            local id, item, amount = qry:getDataInt("id"), qry:getDataInt("item_id"), qry:getDataInt("count")
                            if isItemStackable(item) then
                                doPlayerAddItem(cid, item, amount) 
                            else
                                for i = 1, amount do 
                                    doPlayerAddItem(cid, item, 1) 
                                end
                            end
                            doDeleteShopItem(id)
                            selfSay("Certo, foi devolvido "..amount.." "..name.." pra sua backpack, Obrigado!", cid)
                            talkState[talkUser] = 0
                        else
                            selfSay("Desculpe, mas voce nao possui este item!", cid)
                        end
                    elseif msg == "no" and talkState[talkUser] >= 1 then
                        selfSay("okay then...", cid)
                        talkState[talkUser] = 0
                        npcHandler:releaseFocus(cid)
                    end 
                    return true
                end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 



2° Bug (Gravissimo)

Spoiler

Um jogador conseguiu comprar os items que estavam ofertados no trade do NPC bugando o dinheiro na bp:

vou explicar:
1. O player possui 10kk
2. O player da trade com o npc
3. Dai o VIP Coin ta la liberado pra comprar
4. O player joga os 10kk no chão
5. Ele ainda consegue comprar o VIP Coin por 10kk mesmo o dinheiro estando no chão
6. dai ele compra todos os items da loja com somente 10kk


(é como se o dinheiro não atualizasse quando o player tira o dinheiro da BP)
pode me ajudar??



podes me ajudar?

@Vodkart EDIT: me ajuda pf pelo menos no segundo bug q é grave =/

Editado por poko360 (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • 4 months later...
  • Respostas 61
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Versões: Foi feito para servidores que não tem o market system, mas funciona desde o 8.54 até 9.6+ Suporta: servidores Sqlite e MySql Sobre: O Npc basicamente funciona da seguinte maneira, v

ótimo script! como faço para ele mandar mensagem global com o anúncio? adicionei o globalevents mas não está mandando mensagem.. adicionei 2 items para testar.. e não está dando erro na distro.

vou refazer o   simple task pro 5.0 autoloot npc auction   mas depois das provas, talvez no começo de julho kkk então aguardem

Posted Images

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.


×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo