• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Haroun

Tairens

Member
Joined
Sep 23, 2007
Messages
90
Reaction score
5
Npc tested on the forgotten server
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
-- OTServ event handling functions start
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
-- OTServ event handling functions end
 
function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end
 
    if msgcontains(msg, 'job') or msgcontains(msg, 'items') then
        selfSay('I trade Enchanted Chicken Wind  for Boots of Haste ,Warrior Sweat for 4 Warrior Helmets ,Fighting Spirit for 2 Royal Helmet Magic Sulphur for 3 Fire Swords and Loterry ticket for 100 empty vials')
 
    elseif msgcontains(msg,'enchanted chicken wind') or msgcontains(msg,'boots of haste') then
        selfSay('Do you want to trade Boots of haste for Enchanted Chicken Wind?')
        talk_state = 1 
 
    elseif msgcontains(msg,'warrior Sweat') or msgcontains(msg,'warrior helmet') then
        selfSay('Do you want to trade 4 Warrior Helmet for Warrior Sweat?')
        talk_state = 2 
 
    elseif msgcontains(msg,'fighting Spirit') or msgcontains(msg,'royal helmet') then
        selfSay('Do you want to trade 2 Royal Helmet for Fighting Spirit')       
        talk_state = 3
 
    elseif msgcontains(msg,'magic sulphur') or msgcontains(msg,'fire sword') then
        selfSay('Do you want to trade 3 Fire Sword for Magic Sulphur') 
        talk_state = 4
 
    elseif msgcontains(msg,'lottery ticket') or msgcontains(msg,'lottery') or msgcontains(msg,'ticket') then
        selfSay('Do you want to trade 100 empty vials for lottery ticket')     
        talk_state = 5
 
    elseif msgcontains(msg,'yes') and talk_state == 1 then
        if getPlayerItemCount(cid,2195) >= 1 then
            if doPlayerTakeItem (cid,2195,1) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5891,1)
            end
        else
            selfsay('Sorry you don\'t have the item')
        end
 
    elseif msgcontains(msg,'yes') and talk_state == 2 then
        if getPlayerItemCount(cid,2475) >= 4 then
            if doPlayerTakeItem(cid,2475,4) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5885,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end
 
    elseif msgcontains (msg,'yes') and talk_state == 3 then
        if getPlayerItemCount(cid,2498) >= 2 then
            if doPlayerTakeItem(cid,2498,2) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5884,2)
            end
        else
            selfSay('Sorry but you don\'t have the item')
        end
 
    elseif msgcontains(msg,'yes') and talk_state == 4 then
        if getPlayerItemCount (cid,2392) >= 3 then
            if doPlayerTakeItem (cid,2392,3) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5904,1)
            end
        else
            selfSay('Sorry but you don\'t have the item')
        end
 
    elseif msgcontains(msg,'yes') and talk_state == 5 then
        if GetPlayerItemCount (cid,2006) >= 100 then
            if doPlayerTakeItem (cid,2006,100) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5957,1)
            end
        else
            selfSay('Sorry but you don\'t have the item')
        end
 
        elseif msgcontains(msg,'no') and (talk_state >= 1 and talk_state <= 5) then
             selfSay(msg,'Ok then')
             talk_state = 0
        end
 
        return true
    end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited by a moderator:
Back
Top