• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ Npc King Fix

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;
1580495261337.png

2- The npc only answer by "hi", i want that the npc only answer if the player say : Hail Pharaoh

1580495206881.png


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())
 
Solution
E
Thanks! with this we solve 25% of the probnlem, With this changes, the npc still answers the "hi"

edit:
removing :
npcHandler:addModule(FocusModule:new())
it works! =)
only missing the promotion thing;
I already gave the link with the promotion fix, just add these 3 lines to your script:

Lua:
local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus =...
Thanks! with this we solve 25% of the probnlem, With this changes, the npc still answers the "hi"

edit:
removing :
npcHandler:addModule(FocusModule:new())
it works! =)
only missing the promotion thing;
I already gave the link with the promotion fix, just add these 3 lines to your script:

Lua:
local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
 
Solution
I already gave the link with the promotion fix, just add these 3 lines to your script:

Lua:
local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
I need to put these functions working with mine, if i put these 3 lines, only this 3 lines works
 
Back
Top