Hello! cause of some reason my blessing npc doesn't work. When I buy blessings from him the death loos % is the same as before. So I died and loose tons of lvls. Also I would like to make it possible buy all 5 blessings by saying "all". Here is my blessing npc script1:
and other one:
I tried to modify them by myself but I failed. Help me please! Its Easter
Thank you and Happy easter!
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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)
--- TODO: bless function in modules.lua
if(npcHandler.focus ~= cid) then
return FALSE
end
if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
npcHandler:say("I can provide you with five blessings... the 'first bless', 'second bless', 'third bless', 'fourth bless' and the 'fifth bless', they cost 10000 gold coins each.")
talkState = 0
elseif msgcontains(msg, 'first bless') then
npcHandler:say("Do you want to buy the first blessing for 10000 gold?")
talkState = 1
elseif msgcontains(msg, 'second bless') then
npcHandler:say("Do you want to buy the second blessing for 10000 gold?")
talkState = 2
elseif msgcontains(msg, 'third bless') then
npcHandler:say("Do you want to buy the third blessing for 10000 gold?")
talkState = 3
elseif msgcontains(msg, 'fourth bless') then
npcHandler:say("Do you want to buy the fourth blessing for 10000 gold?")
talkState = 4
elseif msgcontains(msg, 'fifth bless') then
npcHandler:say("Do you want to buy the fifth blessing for 10000 gold?")
talkState = 5
if msgcontains(msg, 'yes') then
if getPlayerBlessing(cid, talkState) then
npcHandler:say("A god has already blessed you with this blessing.")
elseif isPremium(cid) == TRUE then
if doPlayerRemoveMoney(cid, 10000) == TRUE then
doPlayerAddBlessing(cid, talkState)
npcHandler:say("You have been blessed by one of the five gods!")
else
npcHandler:say("You don't have enough money.")
end
else
npcHandler:say("You need a premium account to buy blessings.")
end
elseif msgcontains(msg, 'no') then
npcHandler:say("Then not.")
end
talkState = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
and other one:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
local node1 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = false, cost = 10000})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 2, premium = false, cost = 10000})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 3, premium = false, cost = 10000})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 4, premium = false, cost = 10000})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, premium = false, cost = 10000})
node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
local node6 = keywordHandler:addKeyword({'all'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy all blessings for 50000 gold?'})
node6:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, bless = 1, bless = 4, bless = 3, bless = 2, premium = false, cost = 50000})
node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})
npcHandler:addModule(FocusModule:new())
I tried to modify them by myself but I failed. Help me please! Its Easter
Thank you and Happy easter!