Postado Janeiro 23, 2018 7 anos to trabalhando numa quest e preciso que ela seja feita 1x ao dia, consegui fazer toda a parte que teleportaria os players e tal, mas na hora da storage tá tenso! a storage até é atribuida ao player mas não pelo tempo que eu coloquei ali (tentei com 10 segundos pra fazer o teste, e nada) o script: Spoiler local t = { lvl = 150, Time = 15, entrada = { {x = 191, y = 425, z = 8}, }, saida = { {x = 124, y = 350, z = 9}, {x = 129, y = 350, z = 9} }, monstros = { {{x=299, y=399, z=9}, "Mega Blastoise"}, {{x=238, y=399, z=9}, "Mega Venusaur"}, {{x=206, y=403, z=9}, "Mega Absol"}, {{x=217, y=397, z=9}, "Elder Tangela"}, {{x=219, y=406, z=9}, "Elder Venusaur"}, {{x=229, y=409, z=9}, "Mega Ampharos"}, {{x=235, y=406, z=9}, "Mega Pidgeot"}, {{x=238, y=414, z=9}, "Elder Jynx"}, {{x=227, y=412, z=9}, "Elder Pidgeot"}, {{x=220, y=414, z=9}, "Elder Tentacruel"}, {{x=211, y=412, z=9}, "Mega Charizard X"}, {{x=205, y=418, z=9}, "Mega Charizard Y"}, {{x=215, y=418, z=9}, "Elder Charizard"}, {{x=223, y=420, z=9}, "Elder Pinsir"}, {{x=231, y=418, z=9}, "Elder Jynx"}, {{x=237, y=422, z=9}, "Mega Ampharos"}, {{x=202, y=426, z=9}, "Mega Blastoise"}, {{x=247, y=422, z=9}, "Underworld Rayquaza"} } } function VarAnihiPlayer(cid) if not isCreature(cid) then return LUA_ERROR end if isInRange(getPlayerPosition(cid), t.saida[1], t.saida[#t.saida]) then doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) end end function getPlayersInArea(fromPos, toPos) local players = {} for _, pid in ipairs(getPlayersOnline()) do if isInRange(getPlayerPosition(pid), fromPos, toPos) then table.insert(players, pid) end end return players end function onUse(cid, item, fromPosition, itemEx, toPosition) local check = {} if #getPlayersInArea(t.saida[1], t.saida[#t.saida]) > 0 then doPlayerSendCancel(cid, 'Wait, there are players doing the quest.') return true end if getPlayerStorageValue(cid, 17899) == 1 then doPlayerSendCancel(cid, 'You need to wait 24hours to enter again.') return true end for _, k in ipairs(t.entrada) do local x = getTopCreature(k).uid if(x == 0 or not isPlayer(x) or getPlayerLevel(x) < t.lvl) then doPlayerSendCancel(cid, 'Need another player or somebody else has no level '..t.lvl..'.') return true end table.insert(check, x) end for _, summon in pairs(t.monstros) do local creature = getTopCreature(summon[1]).uid if(creature > 0 and not isPlayer(creature)) then doRemoveCreature(creature) end doCleanTile(summon[1]) doCreateMonster(summon[2], summon[1]) end for i, tid in ipairs(check) do doSendMagicEffect(t.entrada[i], CONST_ME_POFF) doTeleportThing(tid, t.saida[i], false) setPlayerStorageValue(cid, 17899, os.time()+86400) addEvent(VarAnihiPlayer, t.Time*60*1000, tid) doSendMagicEffect(t.saida[i], CONST_ME_ENERGYAREA) end return true end alguém sabe me dizer onde estou errando?
Postado Janeiro 23, 2018 7 anos Testa agora: local t = { lvl = 150, Time = 15, entrada = { {x = 191, y = 425, z = 8}, }, saida = { {x = 124, y = 350, z = 9}, {x = 129, y = 350, z = 9} }, monstros = { {{x=299, y=399, z=9}, "Mega Blastoise"}, {{x=238, y=399, z=9}, "Mega Venusaur"}, {{x=206, y=403, z=9}, "Mega Absol"}, {{x=217, y=397, z=9}, "Elder Tangela"}, {{x=219, y=406, z=9}, "Elder Venusaur"}, {{x=229, y=409, z=9}, "Mega Ampharos"}, {{x=235, y=406, z=9}, "Mega Pidgeot"}, {{x=238, y=414, z=9}, "Elder Jynx"}, {{x=227, y=412, z=9}, "Elder Pidgeot"}, {{x=220, y=414, z=9}, "Elder Tentacruel"}, {{x=211, y=412, z=9}, "Mega Charizard X"}, {{x=205, y=418, z=9}, "Mega Charizard Y"}, {{x=215, y=418, z=9}, "Elder Charizard"}, {{x=223, y=420, z=9}, "Elder Pinsir"}, {{x=231, y=418, z=9}, "Elder Jynx"}, {{x=237, y=422, z=9}, "Mega Ampharos"}, {{x=202, y=426, z=9}, "Mega Blastoise"}, {{x=247, y=422, z=9}, "Underworld Rayquaza"} } } function VarAnihiPlayer(cid) if not isCreature(cid) then return LUA_ERROR end if isInRange(getPlayerPosition(cid), t.saida[1], t.saida[#t.saida]) then doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) end end function getPlayersInArea(fromPos, toPos) local players = {} for _, pid in ipairs(getPlayersOnline()) do if isInRange(getPlayerPosition(pid), fromPos, toPos) then table.insert(players, pid) end end return players end function onUse(cid, item, fromPosition, itemEx, toPosition) local check = {} if #getPlayersInArea(t.saida[1], t.saida[#t.saida]) > 0 then doPlayerSendCancel(cid, 'Wait, there are players doing the quest.') return true end if getPlayerStorageValue(cid, 17899) > os.time() then doPlayerSendCancel(cid, 'You need to wait 24hours to enter again.') return true end for _, k in ipairs(t.entrada) do local x = getTopCreature(k).uid if(x == 0 or not isPlayer(x) or getPlayerLevel(x) < t.lvl) then doPlayerSendCancel(cid, 'Need another player or somebody else has no level '..t.lvl..'.') return true end table.insert(check, x) end for _, summon in pairs(t.monstros) do local creature = getTopCreature(summon[1]).uid if(creature > 0 and not isPlayer(creature)) then doRemoveCreature(creature) end doCleanTile(summon[1]) doCreateMonster(summon[2], summon[1]) end for i, tid in ipairs(check) do doSendMagicEffect(t.entrada[i], CONST_ME_POFF) doTeleportThing(tid, t.saida[i], false) setPlayerStorageValue(cid, 17899, os.time()+86400) addEvent(VarAnihiPlayer, t.Time*60*1000, tid) doSendMagicEffect(t.saida[i], CONST_ME_ENERGYAREA) end return true end O erro aparente era bem simples, se o momento atual do presente é o tempo "100", daqui um dia será "200", você quando salva o tempo "200" (que seria amanhã), ao checar a storage, tem que checar se "amanhã (200) é maior que o tempo atual", e sua checagem estava: if getPlayerStorageValue(cid, 17899) == 1 then Sendo que teria que ser assim: if getPlayerStorageValue(cid, 17899) > os.time() then -- se o tempo salvo na storage é maior que o tempo atual, o player ainda não pode passar pois não deu 24h Programador PHP, Lua, Java, database administrator. "Nada é verdade, tudo é permitido." Requiescat in pace.
Postado Janeiro 23, 2018 7 anos Autor funcionou, muito obrigado!! não entendi isso, os.time é o tempo de agora mas vc me confundiu com isso de 100 e 200, posso te chamar no privado?
Postado Janeiro 24, 2018 7 anos 20 horas atrás, Danxi disse: funcionou, muito obrigado!! não entendi isso, os.time é o tempo de agora mas vc me confundiu com isso de 100 e 200, posso te chamar no privado? Caso você queira entender o que eu te disse, pode me chamar, mas não para pedir scripts, isso pode ser feito criando um tópico, =) Programador PHP, Lua, Java, database administrator. "Nada é verdade, tudo é permitido." Requiescat in pace.
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.