Ir para conteúdo
  • 0

Npc Que Da Life


jhonatanp

Pergunta

Eae, Eu gostaria de um npc que da 20k de life e mana para o player, como iria funcionar ?

 

o player fala hi, final reborn, yes, ai no caso ele tinha 20k de life e mana vai para 40k, lembrando se o player tentar falar com o npc novamente o npc não da mas life.

 

Protocolo : 8.0

Link para o comentário
Compartilhar em outros sites

8 respostass a esta questão

Posts Recomendados

  • 0

criei aqui rapidinho

data\npc\scripts\nomedoarquivo.lua

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, "posso te editar só uma vez diz (yes)")   -- muda a frase  menos yes
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, 'yes')) then
sto = getPlayerStorageValue(cid,55782)
if sto == -1 then
local h = 20000 -- quantos que vai aumenta na life
local m = 20000 -- quantos que vai aumenta na mana
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+(h))
doCreatureAddHealth(cid,h)
setCreatureMaxMana(cid, getPlayerMaxMana(cid)+(m))
doPlayerAddMana(cid,m)
setPlayerStorageValue(cid,55782,1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "pronto já te editei") -- muda frase
doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "huum pensa que me engana ja te editei safado...") -- muda a frase
return TRUE
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

data\npc\nomedoarquivo.xml

<npc name="NOMEDONPC" script="data/npc/scripts/nomedoarquivo.lua" walkinterval="2000" floorchange="0">
   <health now="100" max="100"/>
   <look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
    <parameters>
		    <parameter key="message_greet" value="OK." />
		    <parameter key="message_farewell" value="Tchau." />
		    <parameter key="message_walkaway" value="Tchau." />
    </parameters>
</npc>

só não sei se pega em 8.0

Link para o comentário
Compartilhar em outros sites

  • 0
 
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
local mana,heal = 20,30   ---Quanto de mana ele ganha,Quanto de health ele ganha
if (msgcontains(msg, 'yes') or msgcontains(msg, 'yes')) then
if getPlayerStorageValue(cid, 7222) > 0 then
npcHandler:say("Você ja pegou seu poder adicional", cid)
return true
end
npcHandler:say("Você recebeu o power", cid)
doCreatureAddHealth(cid, heal)
doCreatureAddMana(cid, mana)
setPlayerStorageValue(cid, 7222, 1)
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Editado por caotic
Link para o comentário
Compartilhar em outros sites

  • 0

tenta ai

 

local focus = 0

local talk_start = 0

local target = 0

local following = false

local attacking = false

 

function onThingMove(creature, thing, oldpos, oldstackpos)

 

end

 

 

function onCreatureAppear(creature)

 

end

 

 

function onCreatureDisappear(cid, pos)

if focus == cid then

selfSay('?????.')

focus = 0

talk_start = 0

end

end

 

 

function onCreatureTurn(creature)

 

end

 

 

function msgcontains(txt, str)

return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))

end

 

 

function onCreatureSay(cid, type, msg)

msg = string.lower(msg)

 

if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

 

selfSay('Hello. If you ready I can "Reborn" you.')

focus = cid

talk_start = os.clock()

 

 

elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. getCreatureName(cid) .. '! Hey!.')

 

elseif focus == cid then

talk_start = os.clock()

 

if msgcontains(msg, 'reborn') and getPlayerStorageValue(cid,30023) == 4 then

selfSay('Sorry, but you are after reborn.')

focus = 0

talk_start = 0

 

elseif msgcontains(msg, 'reborn') and getPlayerLevel(cid) < 200 and getPlayerStorageValue(cid,30023) ~= 4 then

selfSay('Hehe. Voce Nao Tem Level 350.')

 

 

elseif msgcontains(msg, 'reborn') then

selfSay('Tem Sertesa?')

talk_state = 2

 

elseif msgcontains(msg, 'yes') and talk_state == 2 and getPlayerLevel(cid) >= 200 then

doPlayerAddHealthMax(cid,30000)

setPlayerStorageValue(cid,9999999,4)

talk_state = 0

 

 

 

 

elseif msgcontains(msg, 'yes') and talk_state == 2 then

selfSay('Mals, ' .. getCreatureName(cid) .. '! Voce Tem que tar na transform serta.')

 

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

selfSay('Good bye.')

focus = 0

talk_start = 0

end

end

end

 

function onThink()

doNpcSetCreatureFocus(focus)

if (os.clock() - talk_start) > 45 then

if focus > 0 then

selfSay('Next Please...')

end

focus = 0

end

if focus ~= 0 then

if getDistanceToCreature(focus) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

 

 

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...