Postado Novembro 18, 2018 6 anos Estou com dois problema em um script que eu instalei no meu servidor que um faz com que um jogador não consiga entrar no servidor, e outro, que quando você mata um boss de um evento o seu personagem não é salvo e volta no momento em que você estava matando o boss, segue as imagens abaixo. Script desenvolvido por @luanluciano93 Erro que faz com que o jogador não consiga logar Erro que faz com que o progresso do personagem não salve --------> Script <-------- Primeiramente vamos criar o arquivo das configurações gerais, crie uma pasta dentro do "data" com o nome de sistemas e dentro cria um arquivo rewardchest.lua: Spoiler -- Sistema de recompensa criado por luanluciano93 REWARDCHEST = { rewardBagId = 2595, formula = {hit = 3, block = 1, suport = 9}, storageExaust = 60000, town_id = 1, bosses = { ["baiak alpha boss"] = { comum = { {2143, 10, 100}, -- white pearl {2146, 10, 100}, -- small sapphire {2145, 10, 100}, -- small diamond {2144, 10, 100}, -- black pearl {2149, 10, 100}, -- small emeralds {5954, 3, 100}, -- demon horn {7896, 1, 100}, -- glacier kilt {7590, 1, 100}, -- great mana potion {2179, 1, 100}, -- gold ring {2151, 1, 100}, -- talon }, semi_raro = { {2152, 90, 100}, -- platinum coin {7368, 50, 100}, -- assassin star {2130, 1, 100}, -- golden amulet {2436, 1, 100}, -- skull staff {2447, 1, 100}, -- twin axe {2171, 1, 100}, -- platinum amulet {2158, 1, 100}, -- blue gem {2393, 1, 100}, -- giant sword {2164, 1, 100}, -- might ring {7454, 1, 100}, -- glorious axe {6553, 1, 100}, -- ruthless axe {9971, 1, 100}, -- gold ingot }, raro = { {2160, 3, 100}, -- crystal coin {8887, 1, 100}, -- frozen plate {2470, 1, 100}, -- golden legs {2472, 1, 100}, -- magic plate armor {7431, 1, 100}, -- demonbone {2520, 1, 100}, -- demon shield {5943, 1, 100}, -- morgaroth hearth {2466, 1, 100}, -- golden armor {2514, 1, 100}, -- mastermind shield {2142, 1, 100}, -- ancient amulet {2123, 1, 100}, -- ring of the sky {1984, 1, 100}, -- blue tome }, muito_raro = { {8866, 1, 100}, -- robe of the ice queen {6553, 1, 100}, -- ruthless axe {8884, 1, 100}, -- oceanborn leviathan armor {2421, 1, 100}, -- thunder hammer {2646, 1, 100}, -- golden boots {7455, 1, 100}, -- mythril axe }, sempre = { {2148, 90, 100}, -- gold coin {6500, 9, 100}, -- demonic essence {2177, 1, 100}, -- life crystal {2214, 1, 100}, -- ring of healing }, storage = 65479, }, ["azazel"] = { comum = { {2143, 10, 100}, -- white pearl {2146, 10, 100}, -- small sapphire {2145, 10, 100}, -- small diamond {2144, 10, 100}, -- black pearl {2149, 10, 100}, -- small emeralds {5954, 3, 100}, -- demon horn {7896, 1, 100}, -- glacier kilt {2432, 1, 100}, -- fire axe {2462, 1, 100}, -- devil helmet {7590, 1, 100}, -- great mana potion {2179, 1, 100}, -- gold ring {2151, 1, 100}, -- talon }, semi_raro = { {2195, 1, 100}, -- boots of haste {2436, 1, 100}, -- skull staff {2393, 1, 100}, -- giant sword {5954, 5, 100}, -- demon horn }, raro = { {2470, 1, 100}, -- golden legs {2472, 1, 100}, -- magic plate armor {2514, 1, 100}, -- mastermind shield {2520, 1, 100}, -- demon shield {1982, 1, 100}, -- purple tome {2123, 1, 100}, -- ring of the sky }, muito_raro = { {8890, 1, 100}, -- Robe of the underworld {2421, 1, 100}, -- thunder hammer }, sempre = { {5808, 1, 100}, -- orshabaals brain {2171, 1, 100}, -- platinum amulet {2148, 90, 100}, -- gold coin {2146, 10, 100}, -- small sapphire }, storage = 65480, }, ["ferumbras"] = { comum = { {2143, 10, 100}, -- white pearl {2146, 10, 100}, -- small sapphire {2145, 10, 100}, -- small diamond {2144, 10, 100}, -- black pearl {2149, 10, 100}, -- small emeralds {7416, 1, 100}, -- Bloody Edge {7896, 1, 100}, -- glacier kilt {2432, 1, 100}, -- fire axe {2462, 1, 100}, -- devil helmet {7590, 1, 100}, -- great mana potion {2179, 1, 100}, -- gold ring {2151, 1, 100}, -- talon }, semi_raro = { {2195, 1, 100}, -- boots of haste {2472, 1, 100}, -- magic plate armor {2393, 1, 100}, -- giant sword {2470, 1, 100}, -- golden legs {2514, 1, 100}, -- mastermind shield }, raro = { {8885, 1, 100}, -- divine plate {2520, 1, 100}, -- demon shield {8930, 1, 100}, -- emerald sword {2522, 1, 100}, -- great shield {2421, 1, 100}, -- thunder hammer }, muito_raro = { {5903, 1, 100}, -- ferumbras hat }, sempre = { {2171, 1, 100}, -- platinum amulet {2148, 90, 100}, -- gold coin {2146, 10, 100}, -- small sapphire }, storage = 65481, }, ["zulazza the corruptor"] = { comum = { {2158, 1, 100}, -- blue gem {2156, 1, 100}, -- red gem {2155, 1, 100}, -- green gem {2154, 1, 100}, -- yellow gem {2153, 1, 100}, -- violet gem }, semi_raro = { {5944, 5, 100}, -- soul orb }, raro = { {2514, 1, 100}, -- mastermind shield }, muito_raro = { {11114, 1, 100}, -- dragon scale boots {8882, 1, 100}, -- earthborn titan armor }, sempre = { {2152, 90, 100}, -- platinum coin {9971, 5, 100}, -- gold ingot }, storage = 65482, }, ["morgaroth"] = { comum = { {2143, 10, 100}, -- white pearl {2146, 10, 100}, -- small sapphire {2145, 10, 100}, -- small diamond {2144, 10, 100}, -- black pearl {2149, 10, 100}, -- small emeralds {5954, 3, 100}, -- demon horn {7896, 1, 100}, -- glacier kilt {2432, 1, 100}, -- fire axe {2462, 1, 100}, -- devil helmet {7590, 1, 100}, -- great mana potion {2179, 1, 100}, -- gold ring {2151, 1, 100}, -- talon }, semi_raro = { {2195, 1, 100}, -- boots of haste {2393, 1, 100}, -- giant sword {5954, 5, 100}, -- demon horn {2123, 1, 100}, -- ring of the sky }, raro = { {8886, 1, 100}, -- molten plate {2472, 1, 100}, -- magic plate armor {8867, 1, 100}, -- dragon robe {2514, 1, 100}, -- mastermind shield {2520, 1, 100}, -- demon shield {1982, 1, 100}, -- purple tome {8851, 1, 100}, -- Royal Crossbow }, muito_raro = { {2421, 1, 100}, -- thunder hammer {2522, 1, 100}, -- great shield {8850, 1, 100}, -- chain bolter }, sempre = { {5943, 1, 100}, -- morgaroths brain {2171, 1, 100}, -- platinum amulet {2148, 90, 100}, -- gold coin {2146, 10, 100}, -- small sapphire }, storage = 65483, }, } } Depois em creaturescript crie dois arquivos:rewardchest_boss.lua: Spoiler -- Sistema de recompensa criado por luanluciano93 dofile('data/sistemas/rewardchest.lua') local function addRewardLoot(uid, bossName, tabela_reward) local money = math.random(10, 40) local msg = "Os itens a seguir estao disponiveis no bau de recompensas(depot):" local chest = doCreateItemEx(REWARDCHEST.rewardBagId) doItemSetAttribute(chest, "description", "Reward System has kill the boss ".. bossName ..".") if table.maxn(tabela_reward) > 0 then for x = 1, table.maxn(tabela_reward) do local rand = math.random(100) if rand <= tabela_reward[x][3] then local count = math.random(1, tabela_reward[x][2]) doAddContainerItem(chest, tabela_reward[x][1], count) msg = msg .. " ".. (tabela_reward[x][2] > 1 and tabela_reward[x][2] or "") .." ".. getItemNameById(tabela_reward[x][1]) .."," end end doPlayerSendTextMessage(uid, MESSAGE_INFO_DESCR, msg .. " and ".. money .." platinum coins.") else doPlayerSendTextMessage(uid, MESSAGE_INFO_DESCR, msg .. " ".. money .." platinum coins.") end doAddContainerItem(chest, 2152, money) doPlayerSendMailByName(getPlayerName(uid), chest, REWARDCHEST.town_id) local boss = REWARDCHEST.bosses[bossName] setPlayerStorageValue(uid, boss.storage, 0) doSendMagicEffect(getPlayerPosition(uid), CONST_ME_MAGIC_BLUE) end local function addLoot(tabela_loot, tabela_reward, all_loot) if table.maxn(tabela_loot) > 0 then if all_loot then for x = 1, table.maxn(tabela_loot) do table.insert(tabela_reward, tabela_loot[x]) end else table.insert(tabela_reward, tabela_loot[math.random(table.maxn(tabela_loot))]) end end return tabela_reward end local function rewardChestSystem(bossName) local players = {} local boss = REWARDCHEST.bosses[bossName] for _, uid in ipairs(getPlayersOnline()) do if getPlayerStorageValue(uid, boss.storage) > 0 then table.insert(players, uid) end end table.sort(players, function(a, b) return getPlayerStorageValue(a, boss.storage) > getPlayerStorageValue(b, boss.storage) end) local porcentagem = math.ceil(getPlayerStorageValue(players[1], boss.storage)) for i = 1, table.maxn(players) do local tabela_reward = {} local pontos = getPlayerStorageValue(players, boss.storage) if i == 1 then addLoot(boss.comum, tabela_reward, false) addLoot(boss.semi_raro, tabela_reward, false) addLoot(boss.raro, tabela_reward, false) addLoot(boss.sempre, tabela_reward, true) elseif i >= 2 and pontos >= math.ceil((porcentagem * 0.8)) then addLoot(boss.comum, tabela_reward, false) addLoot(boss.semi_raro, tabela_reward, false) addLoot(boss.raro, tabela_reward, false) addLoot(boss.muito_raro, tabela_reward, false) elseif pontos < math.ceil((porcentagem * 0.8)) and pontos >= math.ceil((porcentagem * 0.6)) then addLoot(boss.comum, tabela_reward, false) addLoot(boss.semi_raro, tabela_reward, false) addLoot(boss.raro, tabela_reward, false) elseif pontos < math.ceil((porcentagem * 0.6)) and pontos >= math.ceil((porcentagem * 0.4)) then addLoot(boss.comum, tabela_reward, false) addLoot(boss.semi_raro, tabela_reward, false) elseif pontos < math.ceil((porcentagem * 0.4)) and pontos >= math.ceil((porcentagem * 0.1)) then addLoot(boss.comum, tabela_reward, false) end addRewardLoot(players, bossName, tabela_reward) end end function onDeath(cid, corpse, killer) local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()] if boss then addEvent(rewardChestSystem, 1000, getCreatureName(cid):lower()) end return true end function onStatsChange(cid, attacker, type, combat, value) if isMonster(cid) and type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()] if boss and attacker then setPlayerStorageValue(attacker, boss.storage, getPlayerStorageValue(attacker, boss.storage) + math.ceil((value / REWARDCHEST.formula.hit))) end end return true end e rewardchest_pontos.lua: Spoiler -- Sistema de recompensa criado por luanluciano93 dofile('data/sistemas/rewardchest.lua') function onLogin(cid) for key, value in pairs(REWARDCHEST.bosses) do if getPlayerStorageValue(cid, value.storage) > 0 then setPlayerStorageValue(cid, value.storage, 0) end end registerCreatureEvent(cid, "RewardChestStats") return true end function onStatsChange(cid, attacker, type, combat, value) if isMonster(attacker) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) then local boss = REWARDCHEST.bosses[getCreatureName(attacker):lower()] if boss then setPlayerStorageValue(cid, boss.storage, getPlayerStorageValue(cid, boss.storage) + math.ceil((value / REWARDCHEST.formula.block))) setPlayerStorageValue(cid, REWARDCHEST.storageExaust, os.time() + 5) end elseif (isPlayer(attacker) and (type == STATSCHANGE_HEALTHGAIN or type == STATSCHANGE_MANAGAIN) and (getCreatureHealth(cid) < getCreatureMaxHealth(cid)) and (getPlayerStorageValue(cid, REWARDCHEST.storageExaust) >= os.time())) then for key, valor in pairs(REWARDCHEST.bosses) do if getPlayerStorageValue(cid, valor.storage) > 0 then if getCreatureHealth(cid) + value > getCreatureMaxHealth(cid) then local add = getCreatureMaxHealth(cid) - getCreatureHealth(cid) setPlayerStorageValue(attacker, valor.storage, getPlayerStorageValue(attacker, valor.storage) + math.ceil((add / REWARDCHEST.formula.suport))) else setPlayerStorageValue(attacker, valor.storage, getPlayerStorageValue(attacker, valor.storage) + math.ceil((value / REWARDCHEST.formula.suport))) end end end end return true end Lembrando que em todas as criaturas que forem adicionadas ao sistema além de coloca-las no rewarchest.lua você deve add isso no xml do monstro: <script> <event name="RewardChestDeath"/> <event name="RewardChestMonster"/> </script> E isso no creaturescript.xml: <!-- Sistema de recompensa criado por luanluciano93 --> <event type="login" name="RewardChestLogin" event="script" value="rewardchest_pontos.lua"/> <event type="statschange" name="RewardChestStats" event="script" value="rewardchest_pontos.lua"/> <event type="death" name="RewardChestDeath" event="script" value="rewardchest_boss.lua"/> <event type="statschange" name="RewardChestMonster" event="script" value="rewardchest_boss.lua OBS: Não fiz esse tópico na intenção de colocar a culpa no script do @luanluciano93 muito menos nele, fiz o mesmo para que alguém me ajude a resolver, também como ninguém é de ferro, pode ser que demore um pouco até que alguém responda. Uso otx, versão do meu servidor é 8.60, desculpa postar isso agora, é que no momento que eu fiz o tópico estava bem ocupado e atrasado. Meu Curso sobre Programação para OTServer Programando OTServer Peça o seu script! Entre agora mesmo no grupo Developing Conteúdos: Spoiler • Cidade [8.60] • Cave de Boss • Widget Gesior • Autoloot 100% • [Old Client] Como Hookar Dll • Configurando VPS Windowns • [Solução] Código Caracteres Especiais Discord: Belmont#7352 Não esqueça do REP+
Postado Novembro 21, 2018 6 anos @Phineasz, Poderia colocar na linha 6 do arquivo rewardchest_pontos.lua e mostrar o que aparece? print(value.storage) E não estou muito atualizado com esses OTX, mas os scripts são compatíveis com?
Postado Novembro 21, 2018 6 anos Autor @marcot Adicionei o código mais deu o mesmo erro, e no tópico do @luanluciano93 não fala o executável que é compatível com o script, apenas fala que é para 8.60, eu uso OTX. Link para o tópico Meu Curso sobre Programação para OTServer Programando OTServer Peça o seu script! Entre agora mesmo no grupo Developing Conteúdos: Spoiler • Cidade [8.60] • Cave de Boss • Widget Gesior • Autoloot 100% • [Old Client] Como Hookar Dll • Configurando VPS Windowns • [Solução] Código Caracteres Especiais Discord: Belmont#7352 Não esqueça do REP+
Postado Novembro 21, 2018 6 anos Mas deu o mesmo erro sem aparecer nada?? O print é pra mostrar o que que é esse valor que ta dando erro pra ver se da pra converter ou nao
Postado Novembro 22, 2018 6 anos Autor @marcot Com o código adicionado na linha 6. E é assim que fica quando você tenta logar. Meu Curso sobre Programação para OTServer Programando OTServer Peça o seu script! Entre agora mesmo no grupo Developing Conteúdos: Spoiler • Cidade [8.60] • Cave de Boss • Widget Gesior • Autoloot 100% • [Old Client] Como Hookar Dll • Configurando VPS Windowns • [Solução] Código Caracteres Especiais Discord: Belmont#7352 Não esqueça do REP+
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.