• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

NPC Trader

skrm

New Member
Joined
Mar 15, 2008
Messages
67
Reaction score
0
hello
I have an old trader script i used a long time ago, now that im running my OT again my npc scripts have all changed, so i was wondering if anyone knows how to fix this script:

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,'ticket') or msgcontains(msg,'lottery ticket') then
        selfSay('Do you want to buy a winning lottery ticket for 1 crystal coin?')     
        talk_state = 5

    elseif msgcontains(msg,'royal steel') or msgcontains(msg,'crown armor') then
        selfSay('Do you want to trade your crown armor for a piece of royal steel?')     
        talk_state = 6

    elseif msgcontains(msg,'hell steel') or msgcontains(msg,'devil helmet') then
        selfSay('Do you want to trade your devil helmet for a piece of hell steel?')     
        talk_state = 7

    elseif msgcontains(msg,'draconian steel') or msgcontains(msg,'dragon shield') then
        selfSay('Do you want to trade your dragon shield for a piece of draconian steel?')     
        talk_state = 8

    elseif msgcontains(msg,'crude iron') or msgcontains(msg,'giant sword') then
        selfSay('Do you want to trade your giant sword for a huge chunk of crude iron?')     
        talk_state = 9

    elseif msgcontains(msg,'green tunic') or msgcontains(msg,'green piece of cloth') then
        selfSay('Do you want to trade 5 green tunics for a green piece of cloth?')     
        talk_state = 10

    elseif msgcontains(msg,'blessed wooden stake') or msgcontains(msg,'wooden stake') then
        selfSay('Do you want to buy a blessed wooden stake for 50 platinum coins?')     
        talk_state = 11

    elseif msgcontains(msg,'obsidian knife') or msgcontains(msg,'obsidian') then
        selfSay('Do you want to trade a draconian steel and 3 bast skirts for an obsidian knife?')     
        talk_state = 12

    elseif msgcontains(msg,'mystic turban') or msgcontains(msg,'blue piece of cloth') then
        selfSay('Do you want to trade a mystic turban for a blue piece of cloth?')     
        talk_state = 13

    elseif msgcontains(msg,'silk') or msgcontains(msg,'yarn') then
        selfSay('Do you want to trade 10 giant spider silks for 1 silk yarn?')     
        talk_state = 14

    elseif msgcontains(msg,'infernal bolt') or msgcontains(msg,'soul orb') then
        selfSay('Do you want to trade a soul orb for an infernal bolt?')     
        talk_state = 15
 
    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,2160) >= 1 then
            if doPlayerTakeItem(cid,2160,1) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5958,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 6 then
        if getPlayerItemCount(cid,2487) >= 1 then
            if doPlayerTakeItem(cid,2487,1) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5887,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 7 then
        if getPlayerItemCount(cid,2462) >= 1 then
            if doPlayerTakeItem(cid,2462,1) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5888,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 8 then
        if getPlayerItemCount(cid,2516) >= 1 then
            if doPlayerTakeItem(cid,2516,1) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5889,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 9 then
        if getPlayerItemCount(cid,2393) >= 1 then
            if doPlayerTakeItem(cid,2393,1) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5892,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 10 then
        if getPlayerItemCount(cid,2652) >= 5 then
            if doPlayerTakeItem(cid,2652,5) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5910,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 11 then
        if getPlayerItemCount(cid,2152) >= 50 then
            if doPlayerTakeItem(cid,2152,50) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5942,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 12 then
        if getPlayerItemCount(cid,5889) >= 1 and getPlayerItemCount(cid,3983) >= 3 then
            if doPlayerTakeItem(cid,5889,1) == 0 and doPlayerTakeItem(cid,3983,3) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5908,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 13 then
        if getPlayerItemCount(cid,2663) >= 1 then
            if doPlayerTakeItem(cid,2663,1) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5912,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end
 
    elseif msgcontains(msg,'yes') and talk_state == 14 then
        if getPlayerItemCount(cid,5879) >= 10 then
            if doPlayerTakeItem(cid,5879,10) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,5886,1)
            end
        else
            selfSay('Sorry you don\'t have the item')
        end

    elseif msgcontains(msg,'yes') and talk_state == 15 then
        if getPlayerItemCount(cid,5944) >= 1 then
            if doPlayerTakeItem(cid,5944,1) == 0 then
                selfSay(msg,'Here you are')
                doPlayerAddItem(cid,6529,1)
            end
        else
            selfSay('Sorry 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())

Thanks for any help in advance
 
Back
Top