• 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] Real Addons Trader 8.1 (evo)

Evil Hero

Legacy Member
TFS Developer
Joined
Dec 12, 2007
Messages
1,281
Solutions
29
Reaction score
820
Location
Germany
Hello,

Credits to Me :)

Since i made the real addons 8.1 (evo)
I will give you a NPC which will change items like 2 Royal Helmet for a Fighting Spirit!

make a new file called npcnamerhere.xml and put it into data/NPC

Code:
<?xml version="1.0"?>

<npc name="[COLOR="Red"]npcnamehere[/COLOR]" script="data/npc/scripts/exchange.lua" access="3" lookdir="2" autowalk="0">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="251" head="114" body="119" legs="132" feet="114" addons="3"/>
</npc>

red = changeable

save and close the file.

then make a new file called exchange.lua and put it into data/NPC/scripts

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)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

        if msgcontains(msg, 'offer') then
            selfSay('I can Trade Fighting Spirit, Warriors Sweat, Spool of Yarn, Enchanted Chicken Wings and a Blessed Wooden Stake for some special Items')
        elseif msgcontains(msg, 'fighting spirit') then
            selfSay('Do you like to trade 2 Royal Helmet for a Fighting Spirit?')
            talk_state = 1
        

        elseif msgcontains(msg, 'yes') and talk_state == 1 then
            if getPlayerItemCount(cid,2498) >= 2 then
                if doPlayerTakeItem(cid,2498,2) == 0 then
                selfSay('Here you are.')
                    doPlayerAddItem(cid,5884,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('Ok thanks.')
            talk_state = 0
        end

        if msgcontains(msg, 'warriors sweat') then
            selfSay('Do you like to trade 4 Warrior Helmet Helmet for a Warriors Sweat?')
            talk_state = 2
        

        elseif msgcontains(msg, 'yes') and talk_state == 2 then
            if getPlayerItemCount(cid,2475) >= 4 then
                if doPlayerTakeItem(cid,2475,4) == 0 then
                selfSay('Here you are.')
                    doPlayerAddItem(cid,5885,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('Ok thanks.')
            talk_state = 0
        end

        if msgcontains(msg, 'spool of yarn') then
            selfSay('Do you like to trade 10 Giant Spider Silk for a Spool of Yarn?')
            talk_state = 3
        

        elseif msgcontains(msg, 'yes') and talk_state == 3 then
            if getPlayerItemCount(cid,5879) >= 10 then
                if doPlayerTakeItem(cid,5879,10) == 0 then
                selfSay('Here you are.')
                    doPlayerAddItem(cid,5886,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('Ok thanks.')
            talk_state = 0
        end

        if msgcontains(msg, 'enchanted chicken wings') then
            selfSay('Do you like to trade Boots of Haste for some Enchanted Chicken Wings?')
            talk_state = 4
        

        elseif msgcontains(msg, 'yes') and talk_state == 4 then
            if getPlayerItemCount(cid,2195) >= 1 then
                if doPlayerTakeItem(cid,2195,1) == 0 then
                selfSay('Here you are.')
                    doPlayerAddItem(cid,5891,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('Ok thanks.')
            talk_state = 0
        end

        if msgcontains(msg, 'blessed wooden stake') then
            selfSay('Do you like to trade 100k for a Blessed Wooden Stake?')
            talk_state = 5
        

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

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 6) then
            selfSay('Ok thanks.')
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

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

enjoy ;D

yours Evil Hero,
 
I did make this i dunno if it still existed but i made this myself
I'm not a thief so pls don't call me 1 ;)
 
This npc will change items for addon items

yours Evil Hero,
 
Back
Top