Postado Março 30, 2020 5 anos Fala galera, de boa? Então, estou tentando montar um OT e estou fazendo alguma alterações nele. Estou utilizando o "The OTX Server Version: (2.6)". Ao abrir, está dando 2 erros, 1 é no NPC Cassino que tentei colocar, e o outro é no SQLite. Veja os erros abaixo e se podem me ajudar por favor! Obrigado! Erros: Citar [30/3/2020 10:27:33] sqlite3_prepare_v2(): SQLITE ERROR: no such table: castle_dono (SELECT "guild_id" FROM "castle_dono" WHERE "guild_id" > 0) Citar [30/3/2020 10:27:23] [Error - NpcScript Interface] [30/3/2020 10:27:23] data/npc/scripts/cassino.lua [30/3/2020 10:27:23] Description: [30/3/2020 10:27:23] data/npc/lib/npcsystem/npchandler.lua:263: table index is nil [30/3/2020 10:27:23] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scripts/cassino.lua Segue os códigos: Cassino.xml <?xml version="1.0" encoding="UTF-8"?> <npc name="Cassino" script="data/npc/scripts/cassino.lua" walkinterval="0" floorchange="0"> <health now="100" max="100" /> <look type="132" head="108" body="87" legs="4" feet="34" addons="3" /> </npc> Cassino.lua local config = { min = 5000, -- Valor Minimo da Aposta max = 1000000, -- Valor Máximo da Aposta multiplyby = 2, -- Quanto o valor será multiplicado caso o jogador ganhe automatic = true, -- O NPC irá falar com o player automáticamente delay = 2, -- Tempo em segundos em que o player poderá falar com o NPC novamente position = { player = Position(143, 54, 7), -- Posição que o player deve estar money = Position(142, 55, 7), -- Posição do dinheiro dice = Position(141, 54, 7) -- Posição de onde estará o dado }, effects = { win = CONST_ME_SOUND_RED, -- Efeito no player caso ele ganhe lose = CONST_ME_POFF -- Efeito no player caso ele perca }, direction = { talking = DIRECTION_WEST, -- Posição na qual estara o NPC caso esteja conversando stopped = DIRECTION_SOUTH -- Posição na qual estara o NPC caso esteja parado } } local dices = { [1] = 5792, -- Dado com número 1 [2] = 5793, -- Dado com número 2 [3] = 5794, -- Dado com número 3 [4] = 5795, -- Dado com número 4 [5] = 5796, -- Dado com número 5 [6] = 5797 -- Dado com número 6 } local coins = { [2148] = 1, -- Gold coin [2152] = 100, -- Platinum coin [2160] = 10000 -- Crystal coin } local player = nil local money = 0 local npc = nil local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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(cid) npcHandler:onThink(cid) end local function greetCallback(cid) local player = Player(cid) if not playerIsInPosition(player) then return false end return true end local function creatureSayCallback(cid, type, msg) if not player then player = Player(cid) end if not npcHandler:isFocused(cid) or player:getStorageValue(7239) >= os.time() then return false end player:setStorageValue(7239, os.time() + 2) local sorted = math.random(1, 6) local tile = Tile(config.position.dice) local status = false if msg:lower() == "l" or msg:lower() == "low" then status = (sorted < 4 and true or false) elseif msg:lower() == "h" or msg:lower() == "high" then status = (sorted > 3 and true or false) else return false end if not removeMoney() then return false end if player then npcHandler:say((status and "YOU WIN!" or "YOU LOSE!"), cid) end for i = 1, 6 do if tile:getItemById(dices[i]) then local dice = tile:getItemById(dices[i]) dice:transform(dices[sorted]) config.position.dice:sendMagicEffect(CONST_ME_CRAPS) break end end addEvent(function() sendRolledMsg(sorted) end, 800) addEvent(function() if status then addMoney() config.position.player:sendMagicEffect(config.effects.win) else config.position.player:sendMagicEffect(config.effects.lose) end end, 1000) end local function onAddFocus(cid) npc = Creature(getNpcCid()) npc:setDirection(config.direction.talking) end local function onReleaseFocus(cid) npc:setDirection(config.direction.stopped) player = nil npc = nil end function onThink() if config.automatic and not player then players = Tile(config.position.player):getCreatures() for i = 1, #players do if players[i]:isPlayer() then npcHandler:addFocus(players[i].uid) npcHandler:greet(players[i].uid) player = players[i] break end end end if player then if not playerIsInPosition(player) then npcHandler:say("Good bye " .. player:getName(), player.uid) npcHandler:releaseFocus(player.uid) player = nil return true end end end function playerIsInPosition(player) local pos1 = player:getPosition() local pos2 = config.position.player if (pos1.x == pos2.x) and (pos1.y == pos2.y) and (pos1.z == pos2.z) then return true end return false end function removeMoney() money = 0 local tile = Tile(config.position.money) local items = tile:getItems() local torvm = {} for i = 1, #items do if coins[items[i]:getId()] then local coin = items[i] money = money + (coins[coin:getId()] * coin:getCount()) end end if money < config.min then npcHandler:say("You need " .. config.min .. " gold coins to use the cassino.", player.uid) return false elseif money > config.max then npcHandler:say("You can only use " .. config.max .. " gold coins in the casino", player.uid) return false end for i = 1, #items do if coins[items[i]:getId()] then items[i]:remove() end end return true end function addMoney() local moneywin = money * config.multiplyby local ccoin = 0 local pcoin = 0 local gcoin = 0 while moneywin > 0 do if (moneywin >= 10000) then ccoin = moneywin / 10000; moneywin = moneywin - 10000 * math.floor(ccoin); end if (moneywin >= 100) then pcoin = moneywin / 100; moneywin = moneywin - 100 * math.floor(pcoin); end if (moneywin >= 1) then gcoin = moneywin / 1; moneywin = moneywin - 1 * math.floor(gcoin); end end while gcoin > 0 do if gcoin >= 100 then Game.createItem(2148, 100, config.position.money) gcoin = gcoin - 100 else Game.createItem(2148, math.floor(gcoin), config.position.money) gcoin = 0 end end while pcoin > 0 do if pcoin >= 100 then Game.createItem(2152, 100, config.position.money) pcoin = pcoin - 100 else Game.createItem(2152, math.floor(pcoin), config.position.money) pcoin = 0 end end while ccoin > 0 do if ccoin >= 100 then Game.createItem(2160, 100, config.position.money) ccoin = ccoin - 100 else Game.createItem(2160, math.floor(ccoin), config.position.money) ccoin = 0 end end end function sendRolledMsg(sorted) local spectators = Game.getSpectators(config.position.dice, false, true, 3, 3) for _, spectator in ipairs(spectators) do npc:say("Rolled a " .. sorted .. ".", TALKTYPE_MONSTER_SAY, false, spectator, config.position.dice) end end npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|, you want to bet it cassino? Say L to 1-3, H to 4-6.') npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus) npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus) npcHandler:addModule(FocusModule:new()) Fico no aguardo! Muito obrigado! Atenciosamente Felipe Sartori - Portal Bot
Postado Março 30, 2020 5 anos use esse cassino: Spoiler local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 local function delayMoneyRemoval(item, pos) doRemoveItem(getTileItemById(pos, item).uid) return true end local function placeMoney(amount, table_middle_pos) local remain = amount local crystal_coins = 0 local platinum_coins = 0 if (math.floor(amount / 10000) >= 1) then crystal_coins = math.floor(amount / 10000) remain = remain - crystal_coins * 10000 end if ((remain / 100) >= 1) then platinum_coins = remain / 100 end addEvent(doCreateItem, 550, 2152, platinum_coins, table_middle_pos) addEvent(doCreateItem, 600, 2160, crystal_coins, table_middle_pos) end local function rollDice(roll, cc_count, pc_count, table_left_pos, table_middle_pos, npc) local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797} local random_rollval = math.random(1,6) local total_g = (10000 * cc_count) + (100 * pc_count) local prize_percent = 0.9 -- 90% if ((total_g) <= 1000000 and (total_g) >= 500) then doSendMagicEffect(table_left_pos, CONST_ME_CRAPS) for _, itemId in pairs(dice_ids) do if(getTileItemById(table_left_pos, itemId).uid > 0) then doTransformItem(getTileItemById(table_left_pos, itemId).uid, dice_ids[random_rollval]) end end if (roll == 1 and random_rollval <= 3) then placeMoney(total_g + (total_g * prize_percent), table_middle_pos) addEvent(doCreatureSay, 500, npc, "You win :D", TALKTYPE_SAY, false, 0) elseif (roll == 2 and random_rollval >= 4) then placeMoney(total_g + (total_g * prize_percent), table_middle_pos) addEvent(doCreatureSay, 500, npc, "You win :D", TALKTYPE_SAY, false, 0) else addEvent(doCreatureSay, 500, npc, "You Loss :(", TALKTYPE_SAY, false, 0) end doCreatureSay(npc, string.format("%s rolled a %d.", getCreatureName(npc), random_rollval), TALKTYPE_ORANGE_1, false, 0, table_left_pos) else addEvent(doCreateItem, 100, 2160, cc_count, table_middle_pos) addEvent(doCreateItem, 150, 2152, pc_count, table_middle_pos) doCreatureSay(npc, "| Min: 50k | Max: 100kk | Coloque o dinheiro no meio para apostar.", TALKTYPE_SAY, false, 0) end return true end function creatureSayCallback(cid, type, msg) -- NPC userdata instance local npc = getNpcCid() -- Participating player userdata instance local position = {x = getNpcPos().x+2, y = getNpcPos().y, z = getNpcPos().z} position.stackpos = STACKPOS_TOP_CREATURE local player_uid = getThingfromPos(position).uid -- Game table position userdata instances local table_left_pos = {x = 143, y = 263, z = 7} local table_middle_pos = {x = 144, y = 263, z = 7} -- Search for coins on the left and middle tables and create item userdata instances local table_middle_cc = getTileItemById(table_middle_pos, 2160) local table_middle_pc = getTileItemById(table_middle_pos, 2152) -- Other variables local cc_count = 0 local pc_count = 0 local ROLL, LOW, HIGH = 0, 1, 2 if (player_uid ~= 0) then if isInArray({"H", "HIGH", "high", "h"}, msg) and getPlayerPosition(cid).x == 145 and getPlayerPosition(cid).y == 264 and getPlayerPosition(cid).z == 7 then ROLL = HIGH elseif isInArray({"L", "LOW", "l", "low"}, msg) and getPlayerPosition(cid).x == 145 and getPlayerPosition(cid).y == 264 and getPlayerPosition(cid).z == 7 then ROLL = LOW else return false end if (table_middle_cc.uid ~= 0) then cc_count = table_middle_cc.type doTeleportThing(table_middle_cc.uid, table_left_pos) addEvent(delayMoneyRemoval, 300, 2160, table_left_pos) end if (table_middle_pc.uid ~= 0) then pc_count = table_middle_pc.type doTeleportThing(table_middle_pc.uid, table_left_pos) addEvent(delayMoneyRemoval, 300, 2152, table_left_pos) end addEvent(rollDice, 500, ROLL, cc_count, pc_count, table_left_pos, table_middle_pos, npc) else return false end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) Laranja: porcentagem que o player vai receber se ganharVermelho: posição onde vai ficar o banco (norte ou sul)Azul: posição onde o player vai jogar o dinheiro (no meio do banco)Verde: posição onde o player vai ficar pra jogar (altere as duas linhas) EDIT: o primeiro error, é que esta faltando a tabela "castle_dono" na coluna guild_id, certamente onde voce pegou o script, deve ter como adicionar (executando uma query)
Postado Março 31, 2020 5 anos Autor @poko360 muito obrigado, funcionou perfeitamente! Pode fechar o tópico! Atenciosamente Felipe Sartori - Portal Bot
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.