Postado Agosto 9, 2021 3 anos Em 28/06/2021 em 06:54, ETinhowww disse: testei e funciona direitinho, estou passando ele para o revscript está tudo certo na hora de receber o prêmio mas dps que o evento é encerrado acontece de que quando eu mato qualquer outra criatura sendo ou não da lista, aparece o seguinte erro: Lua Script Error: [Scripts Interface] C:\Users\Desktop\NovoUniServer\otserv - Baiak\data\scripts\creaturescripts\monsterHuntKill.lua:callback ...- Baiak\data\scripts\creaturescripts\monsterHuntKill.lua:17: attempt to index a nil value stack traceback: [C]: in function '__index' ...- Baiak\data\scripts\creaturescripts\monsterHuntKill.lua:17: in function <...- Baiak\data\scripts\creaturescripts\monsterHuntKill.lua:3> SCRIPT: local monsterHunt = CreatureEvent("monsterHunt") function monsterHunt.onKill(player, target) if Game.getStorageValue(MONSTER_HUNT.storages.monster) == nil then return true end if not player or not target then return true end if player:getStorageValue(MONSTER_HUNT.storages.player) == -1 then player:setStorageValue(MONSTER_HUNT.storages.player, 0) end if target:isMonster() and target:getName():lower() == (MONSTER_HUNT.list[Game.getStorageValue(MONSTER_HUNT.storages.monster)]):lower() then player:setStorageValue(MONSTER_HUNT.storages.player, player:getStorageValue(MONSTER_HUNT.storages.player) + 1) player:sendTextMessage(30, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName())) table.insert(MONSTER_HUNT.players, {player:getId(), player:getStorageValue(MONSTER_HUNT.storages.player)}) end end monsterHunt:register() conseguem me ajudar? change for: function onKill(player, target) if Game.getStorageValue(MONSTER_HUNT.storages.monster) == nil then return true end if not player or not target then return true end if player:getStorageValue(MONSTER_HUNT.storages.player) == -1 then player:setStorageValue(MONSTER_HUNT.storages.player, 0) end if target:isMonster() ~= nil then return true end if target:isMonster() and target:getName():lower() == (MONSTER_HUNT.list[Game.getStorageValue(MONSTER_HUNT.storages.monster)]):lower() then player:setStorageValue(MONSTER_HUNT.storages.player, player:getStorageValue(MONSTER_HUNT.storages.player) + 1) player:sendTextMessage(MESSAGE_STATUS_BLUE_LIGHT, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName())) table.insert(MONSTER_HUNT.players, {player:getId(), player:getStorageValue(MONSTER_HUNT.storages.player)}) end return true end
Postado Julho 29, 2022 2 anos Em 09/08/2021 em 07:18, eSvira disse: change for: function onKill(player, target) if Game.getStorageValue(MONSTER_HUNT.storages.monster) == nil then return true end if not player or not target then return true end if player:getStorageValue(MONSTER_HUNT.storages.player) == -1 then player:setStorageValue(MONSTER_HUNT.storages.player, 0) end if target:isMonster() ~= nil then return true end if target:isMonster() and target:getName():lower() == (MONSTER_HUNT.list[Game.getStorageValue(MONSTER_HUNT.storages.monster)]):lower() then player:setStorageValue(MONSTER_HUNT.storages.player, player:getStorageValue(MONSTER_HUNT.storages.player) + 1) player:sendTextMessage(MESSAGE_STATUS_BLUE_LIGHT, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName())) table.insert(MONSTER_HUNT.players, {player:getId(), player:getStorageValue(MONSTER_HUNT.storages.player)}) end return true end Recibo este error al cambiar el creaturescript, alguna idea? Edit: Disculpa, fue mi error. Habia pasado mal las libs. Muchas gracias, funciona! Editado Julho 29, 2022 2 anos por pipe23 (veja o histórico de edições)
Postado Fevereiro 15, 2023 2 anos Em 03/11/2020 em 19:05, Movie disse: Evento Monster Hunt Durante uma hora, o player que mais matar um monstro específico ganha o evento. Na pasta lib, crie um arquivo chamado monsterHunt.lua com isso dentro MONSTER_HUNT = { list = {"Demon", "Rotworm", "Cyclops"}, days = { ["Sunday"] = {"13:55"}, ["Monday"] = {"13:55"}, ["Tuesday"] = {"13:55"}, ["Wednesday"] = {"13:55"}, ["Thursday"] = {"13:55"}, ["Friday"] = {"13:55"}, ["Saturday"] = {"13:55"}, }, messages = { prefix = "[Monster Hunt] ", warnInit = "O evento irá começar em %d minuto%s. Seu objetivo será matar a maior quantidade de monstros escolhidos pelo sistema.", init = "O monstro escolhido pelo sistema foi %s. Você tem 1 hora para matar a maior quantidade desse monstro.", warnEnd = "Faltam %d minuto%s para acabar o evento. Se apressem!", final = "O jogador %s foi o ganhador do evento! Parabéns.", noWinner = "Não houve ganhadores no evento.", reward = "Você recebeu o seu prêmio no mailbox!", kill = "Você já matou {%d} %s do evento.", }, rewards = { {id = 2160, count = 100}, }, storages = { monster = 891641, player = 891642, }, players = {}, } function MONSTER_HUNT:initEvent() Game.setStorageValue(MONSTER_HUNT.storages.monster, 0) Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(5, "s")) addEvent(function() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(3, "s")) end, 2 * 60 * 1000) addEvent(function() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnInit:format(1, "")) end, 4 * 60 * 1000) addEvent(function() local rand = math.random(#MONSTER_HUNT.list) Game.setStorageValue(MONSTER_HUNT.storages.monster, rand) Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.init:format(MONSTER_HUNT.list[rand])) end, 5 * 60 * 1000) return true end function MONSTER_HUNT:endEvent() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(5, "s")) addEvent(function() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(3, "s")) end, 2 * 60 * 1000) addEvent(function() Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.warnEnd:format(1, "")) end, 4 * 60 * 1000) addEvent(function() if #MONSTER_HUNT.players == nil then Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.noWinner) return end table.sort(MONSTER_HUNT.players, function(a,b) return a[2] > b[2] end) local player = Player(MONSTER_HUNT.players[1][1]) if player then Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.final:format(player:getName())) player:setStorageValue(MONSTER_HUNT.storages.player, -1) for c, d in ipairs(MONSTER_HUNT.rewards) do local item = Game.createItem(d.id, d.count) player:addItemEx(item) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.reward) player:getPosition():sendMagicEffect(30) end --[[ Função exclusiva (ignore) else local player = Player(MONSTER_HUNT.players[1][1], true) if not player then return false end Game.broadcastMessage(MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.final:format(player:getName())) player:setStorageValue(MONSTER_HUNT.storages.player, -1) for c, d in ipairs(MONSTER_HUNT.rewards) do local item = Game.createItem(d.id, d.count) player:getInbox():addItemEx(item, INDEX_WHEREEVER, FLAG_NOLIMIT) end player:delete() --]] end for a, b in pairs(MONSTER_HUNT.players) do local player = Player(b[1]) if player then player:setStorageValue(MONSTER_HUNT.storages.player, 0) MONSTER_HUNT.players[a] = nil --[[ Função exclusiva (ignore) else player = Player(b[1], true) player:setStorageValue(MONSTER_HUNT.storages.player, 0) MONSTER_HUNT.players[a] = nil player:delete() --]] end end Game.setStorageValue(MONSTER_HUNT.storages.monster, -1) end, 5 * 60 * 1000) return true end Não esqueça de registrar essa lib no lib.lua Agora em globalevents, crie um arquivo na pasta scripts com isso dentro function onThink(interval) if MONSTER_HUNT.days[os.date("%A")] then local hrs = tostring(os.date("%X")):sub(1, 5) if isInArray(MONSTER_HUNT.days[os.date("%A")], hrs) then MONSTER_HUNT:initEvent() end end return true end function onTime(interval) MONSTER_HUNT:endEvent() return true end Não esqueça de adicionar a tag no globalevents <globalevent name="MonsterHunt" interval="60000" script="custom/events/monsterHunt.lua" /> <globalevent name="MonsterHuntEnd" time="14:55" script="custom/events/monsterHunt.lua" /> Agora em creaturescripts, crie um arquivo na pasta scripts com isso dentro function onKill(player, target) if Game.getStorageValue(MONSTER_HUNT.storages.monster) == nil then return true end if not player or not target then return true end if player:getStorageValue(MONSTER_HUNT.storages.player) == -1 then player:setStorageValue(MONSTER_HUNT.storages.player, 0) end if target:isMonster() and target:getName():lower() == (MONSTER_HUNT.list[Game.getStorageValue(MONSTER_HUNT.storages.monster)]):lower() then player:setStorageValue(MONSTER_HUNT.storages.player, player:getStorageValue(MONSTER_HUNT.storages.player) + 1) player:sendTextMessage(MESSAGE_STATUS_BLUE_LIGHT, MONSTER_HUNT.messages.prefix .. MONSTER_HUNT.messages.kill:format(player:getStorageValue(MONSTER_HUNT.storages.player), target:getName())) table.insert(MONSTER_HUNT.players, {player:getId(), player:getStorageValue(MONSTER_HUNT.storages.player)}) end return true end Com a tag no creaturescripts <event type="kill" name="MonsterHunt" script="custom/monsterHunt.lua" /> Não esqueça de registrar o evento no login.lua player:registerEvent("MonsterHunt") Bom aproveito. Créditos: 100% meu Agora, Caverinhaaaaa disse: Esta dando erro no Login.lua
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.