Postado Fevereiro 9, 2018 7 anos 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 ?
Postado Fevereiro 12, 2018 7 anos Autor Alguém pode mim ajudar o script não esta dando erro mais nenhum item vai para o sie
Postado Fevereiro 12, 2018 7 anos 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
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.