Pening
Pingwin :P
Code:
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
bless2 = getPlayerBlessing(cid,2)
tbless = 'Sorry, but you already have this blessing.'
tbless2 = 'Sorry, but you already have one blessing, and u cant buy all others.'
obless = 'I will give to you all blessings, but you will have to make a sacrifice. Are you prepared to pay 200.000 gold for the blessings?'
mbless = 'Oh. You do not have enough money.'
gbless = 'Now the Gods blessed you.'
price = 60000
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'all blessings') then
if isPremium(cid) then
if player_money >= price then
selfSay(obless, cid)
talkState[talkUser] = 2
else
selfSay(mbless, cid)
talkState[talkUser] = 0
end
else
selfSay(pbless, cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
talkState[talkUser] = 0
if bless2 then
selfSay(tbless, cid)
else
if doPlayerRemoveMoney(cid, price) == TRUE then
doPlayerAddBlessing(cid, 1)
doPlayerAddBlessing(cid, 2)
doPlayerAddBlessing(cid, 3)
doPlayerAddBlessing(cid, 4)
doPlayerAddBlessing(cid, 5)
selfSay(gbless, cid)
else
selfSay(mbless, cid)
end
end
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.', cid)
talkState[talkUser] = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())