IgoR lYCAN
New Member
- Joined
- Dec 1, 2018
- Messages
- 169
- Reaction score
- 4
Hello,
I made a few changes in my Npc, and got 2 problems..
1- The npc is not giving the promote, only that i've create;
2- The npc only answer by "hi", i want that the npc only answer if the player say : Hail Pharaoh
Xml:
Lua:
I made a few changes in my Npc, and got 2 problems..
1- The npc is not giving the promote, only that i've create;
2- The npc only answer by "hi", i want that the npc only answer if the player say : Hail Pharaoh
Xml:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Pharaoh Lyan" script="Pharaoh Lyan.lua" walkinterval="0" floorchange="0">
<health now="100" max="100" />
<look type="955" head="78" body="79" legs="80" feet="78" addons="3" />
</npc>
Lua:
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 storage = 14960
local iteraction
local function greetCallback(cid)
local player = Player(cid)
npcHandler.topic[cid] = 0
npcHandler:setMessage(MESSAGE_GREET,'I greet thee, my loyal subject |PLAYERNAME|, what you are looking for? a {promotion} or you want to hear some {history}?', cid)
iteraction = 0
return true
end
local function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if msgcontains(msg, "history") then
npcHandler:say('Well...\n my history is honourable and commendable...\n we fight bravely against the queen when she left her city and invaded Dezaram ...\n my {commanders} and my garisson destroyed the monopoly of Dezaram...\n but now we have a deal, so.. we do not attack each other anymore...\n Well...\n the queen of Dezaram are looking for gladiators, this seems a little strange to me',cid)
end
if msgcontains(msg, "king") then
npcHandler:say('I am the pharaoh, not a king, so watch what you say!',cid)
end
if msgcontains(msg, "commanders") then
npcHandler:say('My commanders are always ready to practice the justice...\n ...in the heads of my enemies.',cid)
end
if msgcontains(msg, "promot") then
if player:getStorageValue(14960) == 1 or player:getStorageValue(14961) == 1 or player:getStorageValue(14962) == 1 or player:getStorageValue(14963) == 1 or player:getStorageValue(14964) == 1 then
npcHandler:say('You are already promoted', cid)
else
npcHandler:say('I can promote you and make you a member of my army. Do you want me to promote you? {Yes} or {No} ?', cid)
iteraction = 1
end
end
if msgcontains(msg, "yes") and iteraction == 1 then
if player:getLevel() >= 40 then
player:setStorageValue(14960, 1)
npcHandler:say('Congratulations! You are now promoted.', cid)
else
npcHandler:say('Not enough level!', cid)
end
iteraction = 0
end
if msgcontains(msg, "no") and iteraction == 1 then
npcHandler:say('Alright then, come back when you are ready.', cid)
iteraction = 0
end
end
npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye, |PLAYERNAME|!')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'How rude!')
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())