Jump to content
×
×
  • Create New...
  • 0

[Resolvido] [Supporte] NPC que Reborna


Question

Versão do Servidor: TFS - 1.0
Tipo de Script: npc
Código:
 
local config = {
    
    item = 2150, -- ID do item necessario para rebornar
    count = 1, -- Count do item a cima
    
    life = 100, -- Life ao rebornar
    mana = 50, -- Mana ao rebornar
    level = 8, -- Level ao rebornar
    voc = 2, -- Voc ao rebornar
    storage = 30023
}

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
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, 'reborn')) then
        if doPlayerRemoveItem(cid, config.item, config.count) then
            setCreatureMaxHealth(cid, config.life)
            setCreatureMaxMana(cid, config.mana)
            doPlayerSetVocation(cid, config.voc)
            doCreatureSetStorage(cid, config.storage, -1)
            doPlayerAddExp(cid, -(getPlayerExperience(cid)-getExperienceForLevel(1)))
      		selfSay('Parabens, voce rebornou', cid)
            return TRUE
        else
            selfSay("Oh! Então traga para mim {".. config.count .." ".. getItemInfo(config.item).name .."}", cid) 
            return TRUE
        end
    end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Ola pessoal. Eu tenho esse script de NPC que reborna. Ele só tem um detalhe de problema. Quando ele reseta a barra de vida do personagem fica enorme. Acho que uma sobrepõe a outra. Ai volta ao normal qd perde vida. Mas como daria um jeito nisso?

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
17 horas atrás, lSainty disse:

Tenta colocar isso:


doCreatureAddHealth(cid, -(getCreatureHealth(cid) - config.life))

Abaixo dessa linha:


setCreatureMaxHealth(cid, config.life)

 

Não deu cara. Ele fica com vida red, mas quando toma dano a vida fica bem bugada. E quando player morre ele já nasce morrendo kkkk.

Link to post
Share on other sites
  • 0

Usa dessa forma. 

 

Spoiler

local config = {
    
    item = 2150, -- ID do item necessario para rebornar
    count = 1, -- Count do item a cima
    
    life = 100, -- Life ao rebornar
    mana = 50, -- Mana ao rebornar
    level = 8, -- Level ao rebornar
    voc = 2, -- Voc ao rebornar
    storage = 30023
}

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
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, 'reborn')) then
        if doPlayerRemoveItem(cid, config.item, config.count) then
setCreatureMaxHealth(cid, config.life)
  
      
      
      if getCreatureHealth(cid) > config.life then
        doCreatureAddHealth(cid, -(getCreatureHealth(cid) - config.life))
      else
        doCreatureAddHealth(cid, config.life)
      end
      		
      
      
            setCreatureMaxMana(cid, config.mana)
            doPlayerSetVocation(cid, config.voc)
            doCreatureSetStorage(cid, config.storage, -1)
            doPlayerAddExp(cid, -(getPlayerExperience(cid)-getExperienceForLevel(1)))
      		selfSay('Parabens, voce rebornou', cid)
            return TRUE
        else
            selfSay("Oh! Então traga para mim {".. config.count .." ".. getItemInfo(config.item).name .."}", cid) 
            return TRUE
        end
    end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Edited by koete
Link to post
Share on other sites
  • 0
7 horas atrás, koete disse:

Usa dessa forma. 

 

  Ocultar conteúdo


local config = {
    
    item = 2150, -- ID do item necessario para rebornar
    count = 1, -- Count do item a cima
    
    life = 100, -- Life ao rebornar
    mana = 50, -- Mana ao rebornar
    level = 8, -- Level ao rebornar
    voc = 2, -- Voc ao rebornar
    storage = 30023
}

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
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, 'reborn')) then
        if doPlayerRemoveItem(cid, config.item, config.count) then
setCreatureMaxHealth(cid, config.life)
  
      
      
      if getCreatureHealth(cid) > config.life then
        doCreatureAddHealth(cid, -(getCreatureHealth(cid) - config.life))
      else
        doCreatureAddHealth(cid, config.life)
      end
      		
      
      
            setCreatureMaxMana(cid, config.mana)
            doPlayerSetVocation(cid, config.voc)
            doCreatureSetStorage(cid, config.storage, -1)
            doPlayerAddExp(cid, -(getPlayerExperience(cid)-getExperienceForLevel(1)))
      		selfSay('Parabens, voce rebornou', cid)
            return TRUE
        else
            selfSay("Oh! Então traga para mim {".. config.count .." ".. getItemInfo(config.item).name .."}", cid) 
            return TRUE
        end
    end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Funcionou perfeitamente. Muito obrigado!

Link to post
Share on other sites
Guest
This topic is now closed to further replies.