• 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 Irmana (Cloth Trader)

D_Evans89

Member
Joined
Dec 3, 2014
Messages
175
Reaction score
12
I used a combination of npc scripts that came with my server to create this npc.

Let me know if it works for you! Tested on TFS 0.2.13 (fully works)

Create a file in data/npc named Irmana.xml and make a file in data/npc/scripts and name it Irmana.lua



Irmana.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Irmana" script="data/npc/scripts/Irmana.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="140" head="0" body="90" legs="33" feet="16" addons="3"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. I buy only the finest products for my clothing line."/>
        <parameter key="message_decline" value="Is |TOTALCOST| gold coins too much for you? Get out of here!"/>
    </parameters>
</npc>

Irmana.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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({'Ape Fur'}, 5883, 120, 'Ape Fur')
shopModule:addSellableItem({'Badger Fur'}, 3860, 15, 'Badger Fur')
shopModule:addSellableItem({'Black Wool'}, 12404, 300, 'Black Wool')
shopModule:addSellableItem({'Blue Piece of Cloth'}, 5912, 200, 'Blue Piece of Cloth')
shopModule:addSellableItem({'Brown Piece of Cloth'}, 5913, 100, 'Brown Piece of Cloth')
shopModule:addSellableItem({'Bunch of Troll Hair'}, 10606, 30, 'Bunch of Troll Hair')
shopModule:addSellableItem({'Dirty Turban'}, 12412, 120, 'Dirty Turban')
shopModule:addSellableItem({'Downy Feather'}, 12640, 20, 'Downy Feather')
shopModule:addSellableItem({'Frost Giant Pelt'}, 10575, 160, 'Frost Giant Pelt')
shopModule:addSellableItem({'Geomancer\'s Robe'}, 12414, 80, 'Geomancer\'s Robe')
shopModule:addSellableItem({'Ghostly Tissue'}, 10607, 90, 'Ghostly Tissue')
shopModule:addSellableItem({'Green Dragon Leather'}, 5877, 100, 'Green Dragon Leather')
shopModule:addSellableItem({'Green Piece of Cloth'}, 5910, 200, 'Green Piece of Cloth')
shopModule:addSellableItem({'Jewelled Belt'}, 12426, 180, 'Jewelled Belt')
shopModule:addSellableItem({'Lion\'s Mane'}, 10608, 60, 'Lion\'s Mane')
shopModule:addSellableItem({'Lizard Leather'}, 5876, 150, 'Lizard Leather')
shopModule:addSellableItem({'Minotaur Leather'}, 5878, 80, 'Minotaur Leather')
shopModule:addSellableItem({'Necromantic Robe'}, 12431, 250, 'Necromantic Robe')
shopModule:addSellableItem({'Noble Turban'}, 12442, 430, 'Noble Turban')
shopModule:addSellableItem({'Piece of Crocodile Leather'}, 11196, 15, 'Piece of Crocodile Leather')
shopModule:addSellableItem({'Purple Robe'}, 12429, 110, 'Purple Robe')
shopModule:addSellableItem({'Red Dragon Leather'}, 5948, 200, 'Red Dragon Leather')
shopModule:addSellableItem({'Red Piece of Cloth'}, 5911, 300, 'Red Piece of Cloth')
shopModule:addSellableItem({'Rope Belt'}, 12448, 66, 'Rope Belt')
shopModule:addSellableItem({'Royal Tapestry'}, 9958, 1000, 'Royal Tapestry')
shopModule:addSellableItem({'Safety Pin'}, 12449, 120, 'Safety Pin')
shopModule:addSellableItem({'Shaggy Tail'}, 11324, 25, 'Shaggy Tail')
shopModule:addSellableItem({'Silky Fur'}, 11209, 35, 'Silky Fur')
shopModule:addSellableItem({'Simple Dress'}, 2657, 50, 'Simple Dress')
shopModule:addSellableItem({'Skunk Tail'}, 11191, 50, 'Skunk Tail')
shopModule:addSellableItem({'Snake Skin'}, 10611, 400, 'Snake Skin')
shopModule:addSellableItem({'Spool of Yarn'}, 5886, 1000, 'Spool of Yarn')
shopModule:addSellableItem({'Striped Fur'}, 11210, 50, 'Striped Fur')
shopModule:addSellableItem({'Tattered Piece of Robe'}, 10601, 120, 'Tattered Piece of Robe')
shopModule:addSellableItem({'Thick Fur'}, 11224, 150, 'Thick Fur')
shopModule:addSellableItem({'Velvet Tapestry'}, 9837, 800, 'Velvet Tapestry')
shopModule:addSellableItem({'Warwolf Fur'}, 11235, 30, 'Warwolf Fur')
shopModule:addSellableItem({'Werewolf Fur'}, 11234, 380, 'Werewolf Fur')
shopModule:addSellableItem({'White Piece of Cloth'}, 5909, 100, 'White Piece of Cloth')
shopModule:addSellableItem({'Winter Wolf Fur'}, 11212, 20, 'Winter Wolf Fur')
shopModule:addSellableItem({'Wool'}, 11236, 15, 'Wool')
shopModule:addSellableItem({'Yellow Piece of Cloth'}, 5914, 150, 'Yellow Piece of Cloth')


item = 'You do not have the required items.'
done = 'Here you are.'

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
  
        if msgcontains(msg, 'offer') then
        selfSay('I can trade you certain cloths if you have the required items.', cid)

      
elseif msgcontains(msg, 'blue piece of cloth') then
            if getPlayerItemCount(cid,2663) >= 1 then
                selfSay('Did you bring me the Mystic Turban ?', cid)
                talk_state = 12
            else
                selfSay('I need a Mystic Turban, to give you the Blue Piece of Cloth. Come back when you have them.', cid)
                talk_state = 0
            end
        elseif msgcontains(msg, 'yes') and talk_state == 12 then
            talk_state = 0
            if getPlayerItemCount(cid,2663) >= 1 then
                if doPlayerRemoveItem(cid,2663,1) == TRUE then
                        doPlayerAddItem(cid,5912,1)
                                        selfSay(done, cid)
                    end

            else
                selfSay(item, cid)
            end

        elseif msgcontains(msg, 'green piece of cloth') then
            if getPlayerItemCount(cid,2652) >= 1 then
                selfSay('Did you bring me the Green Tunic ?', cid)
                talk_state = 13
            else
                selfSay('I need a Green Tunic, to give you the Green Piece of Cloth. Come back when you have them.', cid)
                talk_state = 0
            end
        elseif msgcontains(msg, 'yes') and talk_state == 13 then
            talk_state = 0
            if getPlayerItemCount(cid,2652) >= 1 then
                if doPlayerRemoveItem(cid,2652,1) == TRUE then
                        doPlayerAddItem(cid,5910,1)
                                        selfSay(done, cid)
                    end

            else
                selfSay(item, cid)
            end

        elseif msgcontains(msg, 'red piece of cloth') then
            if getPlayerItemCount(cid,2655) >= 1 then
                selfSay('Did you bring me the Red Robe ?', cid)
                talk_state = 14
            else
                selfSay('I need a Red Robe, to give you the Red Piece of Cloth. Come back when you have them.', cid)
                talk_state = 0
            end
        elseif msgcontains(msg, 'yes') and talk_state == 14 then
            talk_state = 0
            if getPlayerItemCount(cid,2655) >= 1 then
                if doPlayerRemoveItem(cid,2655,1) == TRUE then
                        doPlayerAddItem(cid,5911,1)
                                        selfSay(done, cid)
                    end

            else
                selfSay(item, cid)
            end


        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Ok than.')
            talk_state = 0
        end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Thats all! Enjoy :)
 
Back
Top