Postado Agosto 8, 2021 3 anos 8.60 Necessito de um NPC Revive ele funciona assim quando voce fala hi ele vai fala que voce precisa de uma porcentagem x do seu dinheiro pra ressussitar a tal [SQM] ai quando se tem ao dinheiro e fala yes voce é teleportado pro lugar em que voce morreu.
Postado Agosto 15, 2021 3 anos Solução @Muvuka Boa tarde, as configurações estão comentadas no script do npc. data/npc crie um arquivo chamado reviver.xml e adicione isto dentro: <?xml version="1.0" encoding="UTF-8"?> <npc name="Reviver" script="data/npc/scripts/reviver.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="300" head="0" body="0" legs="0" feet="0" corpse="5995"/> <parameters /> </npc> data/npc/scripts crie um arquivo chamado reviver.lua e adicione isto dentro: local MONEY_AMOUNT = 1000 --Quantidade de dinheiro (em gold coins) que o player necessitará para reviver local MAGIC_EFFECT_TELEPORT = 65 -- Efeito que aparecerá quando o player for teleportado local PLAYER_REBORN_POSITION_X = 66541 local PLAYER_REBORN_POSITION_Y = 66542 local PLAYER_REBORN_POSITION_Z = 66543 local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 npcHandler:setMessage(MESSAGE_GREET, "Ola |PLAYERNAME|. Eu posso te {reviver} no local aonde voce morreu recentemente por uma certa quantidade de dinheiro.") 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, 'reviver') or msgcontains(msg, 'revive')) then selfSay('Voce precisa de ' .. MONEY_AMOUNT .. ' gold(s) para ressuscitar no local aonde voce morreu recentemente', cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if(getPlayerMoney(cid) >= MONEY_AMOUNT) then doPlayerRemoveMoney(cid, MONEY_AMOUNT) if teleportPlayerToPositionReborn(cid) then doTeleportThing(cid, { x=playerRebornPositionX, y=playerRebornPositionY, z=playerRebornPositionZ }) doSendMagicEffect(getThingPos(cid), MAGIC_EFFECT_TELEPORT) selfSay('Ok, voce foi ressuscitado', cid) end else selfSay('Desculpe, mais voce nao possui o dinheiro suficiente.', cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then talkState[talkUser] = 0 selfSay('Ok, ate mais.', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) function teleportPlayerToPositionReborn(cid) local playerRebornPositionX = getPlayerStorageValue(cid, PLAYER_REBORN_POSITION_X) local playerRebornPositionY = getPlayerStorageValue(cid, PLAYER_REBORN_POSITION_Y) local playerRebornPositionZ = getPlayerStorageValue(cid, PLAYER_REBORN_POSITION_Z) if (playerRebornPositionX <= -1 or playerRebornPositionY <= -1 or playerRebornPositionZ <= -1) then selfSay('Voce nao morreu nenhuma vez ainda.', cid) return false end doTeleportThing(cid, { x=playerRebornPositionX, y=playerRebornPositionY, z=playerRebornPositionZ }) return true end Agora em data/creaturescripts/scripts, crie um arquivo chamado reviver.lua e adicione isto dentro dele: local PLAYER_REBORN_POSITION_X = 66541 local PLAYER_REBORN_POSITION_Y = 66542 local PLAYER_REBORN_POSITION_Z = 66543 function onDeath(cid, corpse, deathList) if not isPlayer(cid) then return true end local player_position = getThingPos(cid) setPlayerStorageValue(cid, PLAYER_REBORN_POSITION_X, player_position.x) setPlayerStorageValue(cid, PLAYER_REBORN_POSITION_Y, player_position.y) setPlayerStorageValue(cid, PLAYER_REBORN_POSITION_Z, player_position.z) return TRUE end Em data/creaturescripts abra o arquivo creaturescripts.xml e adicione está linha nele: <event type="death" name="PlayerReborn" event="script" value="reviver.lua"/> Por ultimo registre o evento no arquivo login.lua dentro da pasta data/creaturescripts/scripts adicionando esta linha no arquivo: registerCreatureEvent(cid, "PlayerReborn") Espero ter ajudado.
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.