Postado Abril 25, 2017 8 anos Olá, Eu uso um script para uma SUPER CAVE, aonde os monstros dão mais XP e GOLD, para ter acesso eu utilizo um ITEM,o qual o player precisa para ter acesso a essa área, é agora que o problema começa. O objetivo era o player comprar o ITEM no NPC e usar e sumir igual um FOOD, só que ao usar o item ele continua na backpack do player, alguém pode me ajudar a fazer o item sumir ao utilizá-lo? ------------------------------------------------------------------------------------------------------------------------- Script Mostrar conteúdo oculto function onUse(cid, item, frompos, item2, topos) local config = { timeExhausted = 12, -- tempo em horas para poder usar o item novamente. timeForUse = 4, -- 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, "Voce tem acesso a uma cave exclusiva, Parabens!") else doPlayerSendTextMessage (cid, 19, "Voce utilizou uma cave exclusiva recentemente, aguarde 12 horas!") end return true end creaturescripts Mostrar conteúdo oculto local config = { toKnow = 123456, storage = 789456, pos = {x = 155, y = 52, z = 7}, -- 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) doRemoveItem(item.uid) 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 movements Mostrar conteúdo oculto function onStepIn(cid, item, position, fromPosition) local config = { storage = 789456, from = {x = 258, y = 254, z = 13}, -- coordenada do canto superior esquerdo da área. to = {x = 402, y = 154, z = 13}, -- coordenada do canto inferior direito da área. maxPlayers = 1, -- quantos jogadores poderão entrar na área ao mesmo tempo. pos = {x = 319, y = 185, z = 13}, -- 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 area, compre a cave exclusiva com o NPC Lucio Siqueira!") 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 cave ja possui um jogador, escolha outra!") doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT) doTeleportThing(cid, fromPosition, true) end end return true end Editado Abril 28, 2017 8 anos por davidguimaraesdrum (veja o histórico de edições)
Postado Abril 25, 2017 8 anos function onUse(cid, item, frompos, item2, topos) local config = { timeExhausted = 12, -- tempo em horas para poder usar o item novamente. timeForUse = 4, -- 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, "Voce tem acesso a uma cave exclusiva, Parabens!") else doPlayerSendTextMessage (cid, 19, "Voce utilizou uma cave exclusiva recentemente, aguarde 12 horas!") doRemoveItem(item.uid, 1) end return true end SCRIPT
Postado Abril 25, 2017 8 anos Solução @Zzyzx você colocou para remover o item caso o check retorne que o player já tenha usado antes, então caso o player esteja exhausto, quando ele for usar, ae sim irá remover e não quando ele for para poder ter acesso. @davidguimaraesdrum Mostrar conteúdo oculto function onUse(cid, item, frompos, item2, topos) local config = { timeExhausted = 12, -- tempo em horas para poder usar o item novamente. timeForUse = 4, -- 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, "Voce tem acesso a uma cave exclusiva, Parabens!") doRemoveItem(item.uid, 1) else doPlayerSendTextMessage (cid, 19, "Voce utilizou uma cave exclusiva recentemente, aguarde 12 horas!") end return true end
Postado Abril 25, 2017 8 anos Em 25/04/2017 em 22:56, KotZletY disse: @Zzyzx você colocou para remover o item caso o check retorne que o player já tenha usado antes, então caso o player esteja exhausto, quando ele for usar, ae sim irá remover e não quando ele for para poder ter acesso. @davidguimaraesdrum Mostrar conteúdo oculto Mostrar conteúdo oculto function onUse(cid, item, frompos, item2, topos) local config = { timeExhausted = 12, -- tempo em horas para poder usar o item novamente. timeForUse = 4, -- 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, "Voce tem acesso a uma cave exclusiva, Parabens!") doRemoveItem(item.uid, 1) else doPlayerSendTextMessage (cid, 19, "Voce utilizou uma cave exclusiva recentemente, aguarde 12 horas!") end return true end verdade
Postado Abril 26, 2017 8 anos Autor Em 25/04/2017 em 22:56, KotZletY disse: @davidguimaraesdrum Mostrar conteúdo oculto Mostrar conteúdo oculto function onUse(cid, item, frompos, item2, topos) local config = { timeExhausted = 12, -- tempo em horas para poder usar o item novamente. timeForUse = 4, -- 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, "Voce tem acesso a uma cave exclusiva, Parabens!") doRemoveItem(item.uid, 1) else doPlayerSendTextMessage (cid, 19, "Voce utilizou uma cave exclusiva recentemente, aguarde 12 horas!") end return true end Muito obrigado, 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.