Postado Abril 8, 2022 3 anos Bom queria um NPC teleportasse um player para uma position e so poderia ser usado novamente depois de 24 horas, alguem para ajudar? OBG
Postado Abril 9, 2022 3 anos @Gustavo0098 Boa tarde local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local config = { position = { x = 151, y = 57, z = 7 }, -- posicao para onde o player irá timeInHours = 24, -- tempo em horas para o teleport storage = 78186 } function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'teleport') or msgcontains(msg, 'Teleport')) then selfSay('Do you really want to teleport?', cid) talkState[talkUser] = 1 end if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerStorageValue(cid, config.storage) >= os.time()) then selfSay("Voce precisa aguardar ".. config.timeInHours .."hr(s) para se teleportar novamente", cid) talkState[talkUser] = 0 return end if (getPlayerStorageValue(cid, config.storage) <= os.time()) then addTimeTeleportAgain(cid) doTeleportThing(cid, config.position) doSendMagicEffect(getThingPos(cid), 10) selfSay('Ok', cid) talkState[talkUser] = 0 end end function addTimeTeleportAgain(cid) local time = (1 * 60 * 60) * config.timeInHours setPlayerStorageValue(cid, config.storage, os.time() + time) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Abril 9, 2022 3 anos por MatteusDeli (veja o histórico de edições)
Postado Abril 9, 2022 3 anos Autor 1 hora atrás, MatteusDeli disse: @Gustavo0098 Boa tarde local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local config = { position = { x = 151, y = 57, z = 7 }, -- posicao para onde o player irá timeInHours = 24, -- tempo em horas para o teleport storage = 78186 } function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'teleport') or msgcontains(msg, 'Teleport')) then selfSay('Do you really want to teleport?', cid) talkState[talkUser] = 1 end if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerStorageValue(cid, config.storage) >= os.time()) then selfSay("Voce precisa aguardar ".. config.timeInHours .."hr(s) para se teleportar novamente", cid) talkState[talkUser] = 0 return end if (getPlayerStorageValue(cid, config.storage) <= os.time()) then addTimeTeleportAgain(cid) doTeleportThing(cid, config.position) doSendMagicEffect(getThingPos(cid), 10) selfSay('Ok', cid) talkState[talkUser] = 0 end end function addTimeTeleportAgain(cid) local time = (1 * 60 * 60) * config.timeInHours setPlayerStorageValue(cid, config.storage, os.time() + time) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Obrigado!! funcionou certinho aq
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.