Phemus
Member
- Joined
- Jun 16, 2012
- Messages
- 150
- Solutions
- 2
- Reaction score
- 13
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, 'new mana rune')) then
selfSay('It is called the Great Mana Rune. It would heal your mana a 15% more than the Sterong Mana Rune. I could make one for you if only I had the {items} to make one.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'items')) then
if (getPlayerStorageValue(cid,19732) >= 1) then
selfSay('Wait... I already gave you one', cid)
else
selfSay('There is an Orc Tower to the east of Forula City. Inside that tower, there is a teleport that teleports one to a place where is a chest that have an ancient rune. I need it to create the Great Mana Rune. Would you go and bring it to me?', cid)
end
elseif(msgcontains(msg, 'yes')) then
selfSay('Great! Now go to the teleport of the room to the right. It would take you to the Tower that I told you. Then come here and bring me that rune. Good luck!', cid)
setPlayerStorageValue(cid, 19730, 1)
elseif (msgcontains(msg, 'ancient rune')) and (getPlayerStorageValue(cid, 19732) >= 1) then
selfSay('Do you have it?', cid)
talkState[talkUser] = 2
elseif (msgcontains(msg, 'yes')) and (getPlayerItemCount(cid,2348) >= 1) then
selfSay('Thank You! Here it is, the Grat Mana Rune with 50 free charges.', cid)
if doPlayerRemoveItem(cid,2348,1) == TRUE then
doPlayerAddItem(cid,2307,1)
setPlayerStorageValue(cid, 19733, 51)
else
selfSay('Where is it?', cid)
end
elseif msgcontains(msg, 'buy great mana rune') and (getPlayerStorageValue(cid, 19732) >= 1) then
selfSay('Did you lose your Great Mana Rune? It would cost you 2500000 gold coins. Do you want to buy it?', cid)
elseif msgcontains(msg, 'yes') and (getPlayerMoney(cid) >= 250000) then
if doPlayerRemoveMoney(cid, 250000) then
doPlayerAddItem(cid,2307,1)
else
selfSay('Sorry, you don\'t have the money.', cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
talkState[talkUser] = 1
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
local storage = 26533
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
if msg == 'hello' or msg == 'hi' then
if(getPlayerStorageValue(cid, storage) == -1) then
selfSay('I\'m working on a new mana rune. It is called the Great Mana Rune. It would heal your mana a 15% more than the Sterong Mana Rune. I could make one for you if only I had the {items} to make one.', cid)
talkState[talkUser] = 1
elseif(getPlayerStorageValue(cid, storage) == 1) then
selfSay('Did you brought the item?', cid)
talkState[talkUser] = 2
else
selfSay('How can I help you?', cid)
end
npcHandler:addFocus(cid)
else
return false
end
end
if(msgcontains(msg, 'items') and talkState[talkUser] == 1) then
selfSay('There is an Orc Tower to the east of Forula City. Inside that tower, there is a teleport that teleports one to a place where is a chest that have an ancient rune. I need it to create the Great Mana Rune. Would you go and bring it to me?', cid)
talkState[talkUser] = 2
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
if(getPlayerStorageValue(cid, storage) == -1) then
selfSay('Great! Now go to the teleport of the room to the right. It would take you to the Tower that I told you. Then come here and bring me that rune. Good luck!', cid)
setPlayerStorageValue(cid, 19730, 1)
setPlayerStorageValue(cid, storage, 1)
elseif(getPlayerStorageValue(cid, storage) == 1) then
if doPlayerRemoveItem(cid,2348,1) then
selfSay('Thank You! Here it is, the Great Mana Rune with 50 free charges.', cid)
doPlayerAddItem(cid,2307,1)
setPlayerStorageValue(cid, 19733, 51)
setPlayerStorageValue(cid, storage, 2)
else
selfSay('Where is it?', cid)
end
else
if doPlayerRemoveMoney(cid, 250000) then
doPlayerAddItem(cid,2307,1)
selfSay('Here you are.', cid)
else
selfSay('Sorry, you don\'t have the money.', cid)
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, 'buy great mana rune') and (getPlayerStorageValue(cid, 19732) >= 1) then
selfSay('Did you lose your Great Mana Rune? It would cost you 2500000 gold coins. Do you want to buy it?', cid)
talkState[talkUser] = 2
elseif (msgcontains(msg, 'bye')) then
selfSay("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, "Bye!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)