Postado Novembro 30, 2021 3 anos Galera, esse script funciona normalmente, porem gostaria de uma alteração se possível. gostaria que ele removesse o player quando o tempo acabar, "porem ele tem um problema" .. quando eu ataco o mostro dentro da hunt, eu sou jogado para fora da e quando o tempo acaba ele não tira automaticamente. Vou resumir o sistema: Ao usar o item você ganhar acesso de uma hunt especifica, tem tempo para usar o item novamente e também tem limite maximo de players por sala. movements: Citar function onStepIn(cid, item, position, fromPosition) local config = { storage = 789456, from = {x = 1739, y = 358, z = 7}, -- coordenada do canto superior esquerdo da área. to = {x = 1844, y = 453, z = 7}, -- coordenada do canto inferior direito da área. maxPlayers = 2, -- quantos jogadores poderão entrar na área ao mesmo tempo. pos = {x = 1739, y = 397, z = 7}, -- para onde o jogador será teleportado. } local function getPlayersInArea(left, right) local playersInArea = {} for _, cid in ipairs(getPlayersOnline()) do if isInRange(getThingPos(cid), left, right) then table.insert(playersInArea, cid) end end return playersInArea end if isPlayer(cid) then if getPlayerStorageValue (cid, config.storage) < os.time() then doPlayerSendTextMessage(cid, 19, "Voce nao tem acesso a essa hunt, fale com o npc no segundo andar para adquirir uma.") doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) doTeleportThing(cid, fromPosition, true) else doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) end if table.getn(getPlayersInArea(config.from, config.to)) < config.maxPlayers and getPlayerStorageValue (cid, config.storage) > os.time() then doSendMagicEffect(fromPosition, CONST_ME_TELEPORT) doTeleportThing (cid, config.pos) doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) elseif table.getn(getPlayersInArea(config.from, config.to)) >= config.maxPlayers and getPlayerStorageValue (cid, config.storage) > os.time() then doPlayerSendTextMessage (cid, 19, "Essa hunt ja atingiu o numero maximo de jogadores, aguarde um pouco.") doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) doTeleportThing(cid, fromPosition, true) end end return true end creaturescript: Citar local config = { toKnow = 123456, storage = 789456, pos = {x = 1005, y = 905, z = 5}, -- para onde o jogador será teleportado caso o tempo tenha acabado. } function onKill(cid, target, lastHit) if getPlayerStorageValue (cid, config.toKnow) == 1 then if getPlayerStorageValue (cid, config.storage) < os.time () then doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) doRemoveCreature (cid) end end return true end function onLogin(cid) if getPlayerStorageValue (cid, config.toKnow) == 1 then if getPlayerStorageValue (cid, config.storage) < os.time () then doTeleportThing (cid, config.pos) setPlayerStorageValue (cid, config.toKnow, 0) end end return true end creature.xml Citar <event type="login" name="timeAcess" event="script" value="nome_arquivo.lua"/> <event type="kill" name="timeAcessKill" event="script" value="nome_arquivo.lua"/> login.lua Citar registerCreatureEvent(cid, "timeAcess") registerCreatureEvent(cid, "timeAcessKill") action: Citar function onUse(cid, item, frompos, item2, topos) local config = { timeExhausted = 12, -- tempo em horas para poder usar o item novamente. timeForUse = 1, -- tempo em horas que o player poderá entrar na cave. exhausted = 456789, storage = 789456, toKnow = 123456, effect = 27, -- efeito que dará ao usar o item. } if getPlayerStorageValue(cid, config.exhausted) < os.time() then setPlayerStorageValue (cid, config.storage, config.timeForUse * 60 * 60 + os.time()) setPlayerStorageValue (cid, config.exhausted, config.timeExhausted * 60 * 60 + os.time()) setPlayerStorageValue (cid, config.toKnow, 1) doSendMagicEffect (getThingPos(cid), config.effect) doPlayerSendTextMessage (cid, 19, "Parabéns voce tem o acesso a hunt exclusiva N-2 por 1 horas.") doRemoveItem(item.uid) else doPlayerSendTextMessage (cid, 19, "Aguarde 12 horas para usar esse item novamente.") end return true end
Postado Novembro 30, 2021 3 anos creaturescript: Spoiler local config = { toKnow = 123456, storage = 789456, pos = {x = 1005, y = 905, z = 5}, -- para onde o jogador será teleportado caso o tempo tenha acabado. } function onKill(cid, target, lastHit) if getPlayerStorageValue (cid, config.toKnow) == 1 then if ((os.time() - getPlayerStorageValue (cid, config.storage)) <= 0) then doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) doRemoveCreature (cid) end end return true end function onLogin(cid) if getPlayerStorageValue (cid, config.toKnow) == 1 then if ((os.time() - getPlayerStorageValue (cid, config.storage)) <= 0) then doTeleportThing (cid, config.pos) setPlayerStorageValue (cid, config.toKnow, 0) end end return true end
Postado Dezembro 1, 2021 3 anos Autor 18 horas atrás, So volto tarde disse: creaturescript: Ocultar conteúdo local config = { toKnow = 123456, storage = 789456, pos = {x = 1005, y = 905, z = 5}, -- para onde o jogador será teleportado caso o tempo tenha acabado. } function onKill(cid, target, lastHit) if getPlayerStorageValue (cid, config.toKnow) == 1 then if getPlayerStorageValue (cid, config.storage) - os.time() > 0 then doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) doRemoveCreature (cid) end end return true end function onLogin(cid) if getPlayerStorageValue (cid, config.toKnow) == 1 then if getPlayerStorageValue (cid, config.storage) - os.time() > 0 then doTeleportThing (cid, config.pos) setPlayerStorageValue (cid, config.toKnow, 0) end end return true end nao deu certo, o char ainda fica dentro da hunt.
Postado Dezembro 1, 2021 3 anos recomendo a usar uma storage de controle para saber se o jogador está dentro da hunt e só assim tirar ele de lá quando o tempo acabar. [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Dezembro 1, 2021 3 anos Autor 40 minutos atrás, Vodkart disse: recomendo a usar uma storage de controle para saber se o jogador está dentro da hunt e só assim tirar ele de lá quando o tempo acabar. poderia me mostrar como posso fazer isso?
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.