• 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!

{7.4 npc fail]

Shushu

Banned User
Joined
Feb 16, 2011
Messages
420
Reaction score
4
Location
Shushu is to the north west.
Here is Chephan.xml , is the npc I added for war supplies.

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Arrows Bolts Runes" script="data\npc\scripts\Xodet.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="2" body="26" legs="115" feet="76" addons="0"/>
<parameters>
<parameter key="message_greet" value="I sell burst, Power bolts, and all warring Runes, |PLAYERNAME|? Welcome!"/>
<parameter key="message_farewell" value="So long, |PLAYERNAME|"/>
<parameter key="message_walkaway" value="Good bye, |PLAYERNAME|"/>
<parameter key="module_shop" value="1"/>
<parameter key="shop_buyable" value="pot,2562,30,0;letter,2597,10"/>
		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="offer" />
		<parameter key="keyword_reply1" value="I sell burst, Power bolts, and all warring Runes."/>
</parameters>
</npc>

And here is His script..

PHP:
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:addBuyableItem({'mana potion', 'mana fluid'},		2006, 0, 7,	'mana potion')
shopModule:addBuyableItem({'great fireball', 'gfb'},			2304, 0, 2,	'great fireball rune')
shopModule:addBuyableItem({'explo', 'xpl'},				2313, 0, 3,	'explosion rune')
shopModule:addBuyableItem({'ultimate healing', 'uh'},			2273, 0, 1,	'ultimate healing rune')
shopModule:addBuyableItem({'sudden death', 'sd'},			2268, 0, 1,	'sudden death runes')
shopModule:addBuyableItem({'fire bomb rune', 'fb'},			2305, 0, 2,	'fire bomb rune')
shopModule:addBuyableItem({'energy field', 'ef'},			2277, 0, 3,	'energy field rune')  
shopModule:addBuyableItem({'energy bomb', 'eb'},			2262, 0, 2,	'energy bomb rune')
shopModule:addBuyableItem({'destroy field', 'df'},			2261, 0, 3,	'destroy field rune')
shopModule:addBuyableItem({'burst', 'arrow'},			2546, 0, 1,	'burst arrow')
shopModule:addBuyableItem({'power', 'bolt'},			2547, 0, 1,	'power bolt')
shopModule:addBuyableItem({'time', 'tr'},			2169, 0, 1,	'time ring')
shopModule:addBuyableItem({'energy', 'tr'},			2204, 0, 1,	'energy ring')


npcHandler:addModule(FocusModule:new())


I got no idea why it doesnt work ingame.
It only works with, SD,UH,EXPLO,GFB some of the runes that it had before, doesnt sell the ones i added, + its payable, while i made it 0 cost. ;s.

Help me guyz ;d
 
Using Avesta? If so, Ferrus changed the NPC System, I will see if I can find an NPC example for you, one moment please!

Here we go. This is "King.lua" (I suppose it's a promoting script)
Lua:
_state = 0
_delay = 750

function getNext()
        nextPlayer = getQueuedPlayer()
        if (nextPlayer ~= nil) then
                if (getDistanceToCreature(nextPlayer) <= 4) then
                        setFocus(nextPlayer)
                        greet(nextPlayer, _delay * 2)
                        updateIdle()
                        return
                else
                        getNext()
                end
        end
        
        setFocus(0)
        resetIdle()
end

function _selfSay(message)
        selfSay(message, _delay)
        updateIdle()
end

function greet(cid, delay)
        selfSay('I greet thee, my loyal subject.', delay)
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
        if (getFocus() == cid) then
                selfSay('What a lack of manners!', _delay)
                getNext()
        else
                unqueuePlayer(cid)
        end
end

function onCreatureMove(cid, oldPos, newPos)
        if (getFocus() == cid) then
                faceCreature(cid)
        end
end

function onCreatureSay(cid, type, msg)
        if (getFocus() == 0) then
                if (msgcontains(msg, 'king') and getDistanceToCreature(cid) <= 4) then
                        if (msgcontains(msg, 'hello') or msgcontains(msg, 'hail') or msgcontains(msg, 'salutations')) then
                                updateIdle()
                                setFocus(cid)
                                greet(cid, _delay)
                        end
                end
                
        elseif (getFocus() ~= cid) then 
                if ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and getDistanceToCreature(cid) <= 4) then
                        --selfSay('Just wait, ' .. getCreatureName(cid) .. '.', _delay)
                        --queuePlayer(cid)
                end
                
        else
                if (msgcontains(msg, 'bye') or msgcontains(msg, 'farewell')) then
                        selfSay('Good bye, ' .. getCreatureName(cid) .. '!', _delay)
                        getNext()
                
                elseif (msgcontains(msg, 'job')) then
                        _selfSay('I am your sovereign, King Tibianus III, and it\'s my duty to provide justice and guidance for my subjects.')
                
                elseif (msgcontains(msg, 'justice')) then
                        _selfSay('I try my best to be just and fair to our citizens. The army and the TBI are a great help for fulfilling this duty.')
                
                elseif (msgcontains(msg, 'name')) then
                        _selfSay('It\'s hard to believe that you don\'t know your own king!')
                
                elseif (msgcontains(msg, 'king') or msgcontains(msg, 'tibianus')) then
                        _selfSay('The king has not much interest in magic items as far as I know.')
                
                elseif (msgcontains(msg, 'news')) then
                        _selfSay('The latest news are usually brought to our magnificent town by brave adventurers. They spread tales of their journeys at Frodo\'s tavern.')
                
                elseif (msgcontains(msg, 'tibia') or msgcontains(msg, 'land')) then
                        _selfSay('Soon the whole land will be ruled by me once again!')
                
                elseif (msgcontains(msg, 'how') and msgcontains(msg, 'are') and msgcontains(msg, 'you')) then
                        _selfSay('Thank you, I\'m fine.')
                
                elseif (msgcontains(msg, 'castle')) then
                        _selfSay('Rain Castle is my home.')
                
                elseif (msgcontains(msg, 'sell')) then
                        _selfSay('Sell? Sell what? My kingdom isn\'t for sale!')
                
                elseif (msgcontains(msg, 'god')) then
                        _selfSay('Honor the gods and pay your taxes.')
                
                elseif (msgcontains(msg, 'zathroth')) then
                        _selfSay('Please ask a priest about the gods.')
                
                elseif (msgcontains(msg, 'citizen')) then
                        _selfSay('The citizens of Tibia are my subjects. Ask the old monk Quentin to learn more about them.')
                
                elseif (msgcontains(msg, 'sam')) then
                        _selfSay('He is a skilled blacksmith and a loyal subject.')
                        
                elseif (msgcontains(msg, 'frodo')) then
                        _selfSay('He is the owner of Frodo\'s Hut and a faithful tax-payer.')
                        
                elseif (msgcontains(msg, 'gorn')) then
                        _selfSay('He was once one of Tibia\'s greatest fighters. Now he is selling equipment.')
                
                elseif (msgcontains(msg, 'benjamin')) then
                        _selfSay('He was once my greatest general. Now he is very old and senile but we entrusted him with work for the Royal Tibia Mail.')
                
                elseif (msgcontains(msg, 'harkath') or msgcontains(msg, 'bloodblade') or msgcontains(msg, 'general')) then
                        _selfSay('Harkath Bloodblade is the general of our glorious army.')
                
                elseif (msgcontains(msg, 'noodles')) then
                        _selfSay('The royal poodle Noodles is my greatest treasure!')
                
                elseif (msgcontains(msg, 'ferumbras')) then
                        _selfSay('He is a follower of the evil god Zathroth and responsible for many attacks on us. Kill him on sight!')
                        
                elseif (msgcontains(msg, 'bozo')) then
                        _selfSay('He is my royal jester and cheers me up now and then.')
                        
                elseif (msgcontains(msg, 'treasure')) then
                        _selfSay('The royal poodle Noodles is my greatest treasure!')
                        
                elseif (msgcontains(msg, 'monster')) then
                        _selfSay('o and hunt them! For king and country!')
                        
                elseif (msgcontains(msg, 'help')) then
                        _selfSay('Visit Quentin, the monk, for help.')
                        
                elseif (msgcontains(msg, 'quest') or msgcontains(msg, 'mission')) then
                        _selfSay('I will call for heroes as soon as the need arises again and then reward them appropriately.')
                        
                elseif (msgcontains(msg, 'gold') or msgcontains(msg, 'money') or msgcontains(msg, 'tax')) then
                        _selfSay('To pay your taxes, visit the royal tax collector.')
                        
                elseif (msgcontains(msg, 'sewer')) then
                        _selfSay('What a disgusting topic!')
                        
                elseif (msgcontains(msg, 'dungeon')) then
                        _selfSay('Dungeons are no places for kings.')
                        
                elseif (msgcontains(msg, 'equipment')) then
                        _selfSay('Feel free to buy it in our town\'s fine shops.')
                        
                elseif (msgcontains(msg, 'food')) then
                        _selfSay('Ask the royal cook for some food.')
                        
                elseif (msgcontains(msg, 'time') or msgcontains(msg, 'hero') or msgcontains(msg, 'heroes')) then
                        _selfSay('It\'s a time for heroes, that\'s for sure!')
                        
                elseif (msgcontains(msg, 'tax') and msgcontains(msg, 'collector')) then
                        _selfSay('He has been lazy lately. I bet you have not payed any taxes at all.')
                        
                elseif (msgcontains(msg, 'king')) then
                        _selfSay('I am the king, so mind your words!')
                        
                elseif (msgcontains(msg, 'army')) then
                        _selfSay('Ask the soldiers about that topic.')
                        
                elseif (msgcontains(msg, 'enemy') or msgcontains(msg, 'enemies')) then
                        _selfSay('Our enemies are numerous. The evil minotaurs, Ferumbras, and the renegade city of Carlin to the north are just some of them.')
                        
                elseif ((msgcontains(msg, 'city') and msgcontains(msg, 'north')) or msgcontains(msg, 'carliin')) then
                        _selfSay('They dare to reject my reign over the whole continent!')
                        
                elseif (msgcontains(msg, 'thais') or msgcontains(msg, 'city')) then
                        _selfSay('Our beloved city has some fine shops, guildhouses, and a modern system of sewers.')
                        
                elseif (msgcontains(msg, 'shop')) then
                        _selfSay('Visit the shops of our merchants and craftsmen.')
                        
                elseif (msgcontains(msg, 'merchant') or msgcontains(msg, 'craftsmen')) then
                        _selfSay('Ask around about them.')
                        
                elseif (msgcontains(msg, 'guild')) then
                        _selfSay('The four major guilds are the knights, the paladins, the druids, and the sorcerers.')
                        
                elseif (msgcontains(msg, 'minotaur')) then
                        _selfSay('Vile monsters, but I must admit they are strong and sometimes even cunning ... in their own bestial way.')
                        
                elseif (msgcontains(msg, 'paladin') or msgcontains(msg, 'elane')) then
                        _selfSay('The paladins are great protectors for Thais.')
                        
                elseif (msgcontains(msg, 'knight') or msgcontains(msg, 'gregor')) then
                        _selfSay('The brave knights are necessary for human survival in Thais.')
                        
                elseif (msgcontains(msg, 'sorcerer') or msgcontains(msg, 'muriel')) then
                        _selfSay('The magic of the sorcerers is a powerful tool to smite our enemies.')
                        
                elseif (msgcontains(msg, 'druid') or msgcontains(msg, 'marvik')) then
                        _selfSay('We need the druidic healing powers to fight evil.')
                        
                elseif (msgcontains(msg, 'good')) then
                        _selfSay('The forces of good are hard pressed in these dark times.')
                        
                elseif (msgcontains(msg, 'evil')) then
                        _selfSay('We need all strength we can muster to smite evil!')
                        
                elseif (msgcontains(msg, 'order')) then
                        _selfSay('We need order to survive!')
                        
                elseif (msgcontains(msg, 'chaos')) then
                        _selfSay('Chaos arises from selfishness, and that\'s its weakness.')
                        
                elseif (msgcontains(msg, 'excalibug')) then
                        _selfSay('It\'s the sword of the kings. If you could return this weapon to me I would reward you beyond your dreams.')
                        
                elseif (msgcontains(msg, 'reward')) then
                        _selfSay('Well, if you want a reward, go on a quest to bring me Excalibug!')
                        
                elseif (msgcontains(msg, 'chester')) then
                        _selfSay('A very competent person. A little nervous but very competent.')
                        
                elseif (msgcontains(msg, 'eremo')) then
                        _selfSay('It is said that he lives on a small island near Edron. Maybe the people there know more about him.')
                        
                elseif (msgcontains(msg, 'tbi')) then
                        _selfSay('This organisation is important in holding our enemies in check. Its headquarter is located in the bastion in the northwall.')
                        
                elseif (msgcontains(msg, 'promote') or msgcontains(msg, 'promotion')) then
                        _selfSay('Do you want to be promoted in your vocation for 20000 gold?"')
                        _state = 1
                
                elseif (_state == 1) then
                        if (msgcontains(msg, 'yes')) then
                                if (isPremium(cid)) then
                                        if (not(isPromoted(cid))) then
                                                if (getPlayerLevel(cid) >= 20) then
                                                        if (doPlayerRemoveMoney(cid, 20000)) then
                                                                _selfSay('Congratulations! You are now promoted. Visit the sage Eremo for new spells.')
                                                        else
                                                                _selfSay('You do not have enough money.')
                                                        end
                                                else
                                                        _selfSay('You need to be at least level 20 in order to be promoted.')
                                                end
                                        else
                                                _selfSay('You are already promoted.')
                                        end
                                else
                                        _selfSay('You need a premium account in order to promote.')
                                end
                        else
                                _selfSay('Ok, then not.')
                        end
                        
                        _state = 0
                end
        end
end

function onThink()
        if (getFocus() ~= 0) then
                if (isIdle() or getDistanceToCreature(getFocus()) > 4) then
                        selfSay('What a lack of manners!', _delay)
                        getNext()
                end
        end
end

And Rune NPC (Only selling blank rune due to that it was like that in the 7.4 state)
Lua:
_state = 0
_count = 0
_index = 0
_delay = 1000

items = {}
items[0] = {name = 'blank rune', id = 2260, subtype = -1, sell = 10, buy = -1}
items[1] = {name = 'life ring', id = 2168, subtype = -1, sell = 900, buy = -1}
items[2] = {name = 'crystal ball', id = 2192, subtype = -1, sell = 530, buy = 190}
items[3] = {name = 'life crystal', id = 2177, subtype = -1, sell = 900, buy = 85}
items[4] = {name = 'mind stone', id = 2178, subtype = -1, sell = 900, buy = 170}
items[5] = {name = 'mana fluid', 'manafluid', id = 2006, subtype = -7, sell = 900, buy = 170}
items[6] = {name = 'sudden death rune', 'sd', id = 2268, subtype = -1, sell = 900, buy = 170}

function getNext()
        nextPlayer = getQueuedPlayer()
        if (nextPlayer ~= nil) then
                if (getDistanceToCreature(nextPlayer) <= 4) then
                        updateIdle()
                        setFocus(nextPlayer)
                        greet(nextPlayer, _delay * 3)
                        return
                else
                        getNext()
                end
        end
        
        setFocus(0)
        resetIdle()
end

local function onActionItem(action)
        if ((action == 'buy' and items[_index].sell == -1) or
                (action == 'sell' and items[_index].buy == -1)) then
                return
        end
        
        amount = ''
        suffix = ''
        plural = 'a'
        
        if (_count > 1) then
                amount = ' ' .. tostring(_count)
                suffix = 's'
                plural = ''
        end
        
        cost = items[_index].buy
        if (action == 'buy') then
                cost = items[_index].sell
        end
        
        selfSay('Do you want to ' .. action .. ' ' .. plural .. amount .. ' ' .. items[_index].name .. suffix .. ' for ' .. cost .. ' gold?')
end

function _selfSay(message)
        selfSay(message, _delay)
        updateIdle()
end

function greet(cid, delay)
        selfSay('Hi there ' .. getCreatureName(cid) .. '.', delay)
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
        if (getFocus() == cid) then
                selfSay('See you.', _delay)
                getNext()
        else
                unqueuePlayer(cid)
        end
end

function onCreatureMove(cid, oldPos, newPos)
        if (getFocus() == cid) then
                faceCreature(cid)
        end
end

function onCreatureSay(cid, type, msg)
        if (getFocus() == 0) then
                if ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and getDistanceToCreature(cid) <= 4) then
                        updateIdle()
                        setFocus(cid)
                        greet(cid, _delay)
                end
                
        elseif (getFocus() ~= cid) then
                if ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and getDistanceToCreature(cid) <= 4) then
                        selfSay('Just wait, ' .. getCreatureName(cid) .. '.', _delay)
                        queuePlayer(cid)
                end
                
        else
                if (msgcontains(msg, 'bye')) then
                        selfSay('See you.', _delay)
                        getNext()
                
                elseif (msgcontains(msg, 'name')) then
                        _selfSay('I am Alexander.')
                
                elseif (msgcontains(msg, 'job')) then
                        _selfSay('I trade with runes and other magic items.')
                
                elseif (msgcontains(msg, 'time')) then
                        _selfSay('It\'s ' .. getTibiaTime() .. ' right now.')
                
                elseif (msgcontains(msg, 'king') or msgcontains(msg, 'tibianus')) then
                        _selfSay('The king has not much interest in magic items as far as I know.')
                
                elseif (msgcontains(msg, 'army')) then
                        _selfSay('The army uses weapons and armor rather then items of magic.')
                
                elseif (msgcontains(msg, 'ferumbras')) then
                        _selfSay('A hero has to be well prepared to face this threat.')
                
                elseif (msgcontains(msg, 'excalibug')) then
                        _selfSay('Ah, I would trade a fortune for this fabulous item.')
                
                elseif (msgcontains(msg, 'thais')) then
                        _selfSay('I am glad the king founded this academy far away from the mundane troubles of Thais')
                
                elseif (msgcontains(msg, 'tibia')) then
                        _selfSay('The world is filled with wonderous places and items.')
                
                elseif (msgcontains(msg, 'carlin')) then
                        _selfSay('I heard it\'s a city of druids.')
                
                elseif (msgcontains(msg, 'edron')) then
                        _selfSay('In our town, science and arts are thriving.')
                
                elseif (msgcontains(msg, 'news') or msgcontains(msg, 'rumors')) then
                        _selfSay('Ask for news and rumors in the tavern.')
                
                elseif (msgcontains(msg, 'offer') or msgcontains(msg, 'goods')) then
                        _selfSay('I\'m selling runes, life rings, wands, rods and crystal balls.')
                        
                elseif (msgcontains(msg, 'rune') and not(msgcontains(msg, 'blank'))) then
                        _selfSay('I sell blank runes and spell runes.')
                        
                elseif (_state == 1) then
                        if (msgcontains(msg, 'yes')) then
                                if (doPlayerRemoveMoney(cid, items[_index].sell * _count)) then
                                        for i = 1, _count do
                                                doPlayerAddItem(cid, items[_index].id, items[_index].subtype)
                                        end
                                
                                        selfSay('Here you are.', _delay)
                                else
                                        selfSay('Come back, when you have enough money.', _delay)
                                end
                                
                                updateIdle()
                        else
                                selfSay('Hmm, but next time.', _delay)
                        end
                        
                        _state = 0
                        
                elseif (_state == 2) then
                        if (msgcontains(msg, 'yes')) then
                                if (doPlayerRemoveItem(cid, items[_index].id, _count, items[_index].subtype)) then
                                        doPlayerAddMoney(cid, items[_index].buy * _count)
                                        selfSay('Ok. Here is your money.')
                                else
                                        if (count > 1) then
                                                selfSay('Sorry, you do not have so many.', _delay)
                                        else
                                                selfSay('Sorry, you do not have one.', _delay)
                                        end
                                end
                                
                                updateIdle()
                        else
                                selfSay('Maybe next time.', _delay)
                        end
                
                        _state = 0
                        
                else
                        for n = 0, table.getn(items) do
                                if (msgcontains(msg, items[n].name) or msgcontains(msg, items[n].name .. "s")) then
                                        _count = getCount(msg)
                                        _index = n
                                        
                                        if (msgcontains(msg, 'sell')) then
                                                onActionItem('sell')
                                                _state = 2
                                        else
                                                onActionItem('buy')
                                                _state = 1
                                        end
                                        
                                        updateIdle()
                                        break
                                end
                        end
                end
        end
end

function onThink()
        if (getFocus() ~= 0) then
                if (isIdle() or getDistanceToCreature(getFocus()) > 4) then
                        selfSay('See you.', _delay)
                        getNext()
                end
        end
end
 
Last edited:
XML:
<?xml version="1.0"?>
<npc name="Alexander" script="alexander.lua" walkinterval="2000" floorchange="0" idleinterval="30">
        <health now="100" max="100"/>
        <look type="130" head="96" body="63" legs="71" feet="97"/>
</npc>

Also, I updated the other post about scripts. I think that is how you do to make it sell mana fluid & sudden death rune as well~
 
Where do i put this ? :S

Lua:
_state = 0
_count = 0
_index = 0
_delay = 1000
 
items = {}
items[0] = {name = 'blank rune', id = 2260, subtype = -1, sell = 10, buy = -1}
items[1] = {name = 'life ring', id = 2168, subtype = -1, sell = 900, buy = -1}
items[2] = {name = 'crystal ball', id = 2192, subtype = -1, sell = 530, buy = 190}
items[3] = {name = 'life crystal', id = 2177, subtype = -1, sell = 900, buy = 85}
items[4] = {name = 'mind stone', id = 2178, subtype = -1, sell = 900, buy = 170}
 
function getNext()
        nextPlayer = getQueuedPlayer()
        if (nextPlayer ~= nil) then
                if (getDistanceToCreature(nextPlayer) <= 4) then
                        updateIdle()
                        setFocus(nextPlayer)
                        greet(nextPlayer, _delay * 3)
                        return
                else
                        getNext()
                end
        end
 
        setFocus(0)
        resetIdle()
end
 
local function onActionItem(action)
        if ((action == 'buy' and items[_index].sell == -1) or
                (action == 'sell' and items[_index].buy == -1)) then
                return
        end
 
        amount = ''
        suffix = ''
        plural = 'a'
 
        if (_count > 1) then
                amount = ' ' .. tostring(_count)
                suffix = 's'
                plural = ''
        end
 
        cost = items[_index].buy
        if (action == 'buy') then
                cost = items[_index].sell
        end
 
        selfSay('Do you want to ' .. action .. ' ' .. plural .. amount .. ' ' .. items[_index].name .. suffix .. ' for ' .. cost .. ' gold?')
end
 
function _selfSay(message)
        selfSay(message, _delay)
        updateIdle()
end
 
function greet(cid, delay)
        selfSay('Hi there ' .. getCreatureName(cid) .. '.', delay)
end
 
function onCreatureAppear(cid)
end
 
function onCreatureDisappear(cid)
        if (getFocus() == cid) then
                selfSay('See you.', _delay)
                getNext()
        else
                unqueuePlayer(cid)
        end
end
 
function onCreatureMove(cid, oldPos, newPos)
        if (getFocus() == cid) then
                faceCreature(cid)
        end
end
 
function onCreatureSay(cid, type, msg)
        if (getFocus() == 0) then
                if ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and getDistanceToCreature(cid) <= 4) then
                        updateIdle()
                        setFocus(cid)
                        greet(cid, _delay)
                end
 
        elseif (getFocus() ~= cid) then
                if ((msgcontains(msg, 'hi') or msgcontains(msg, 'hello')) and getDistanceToCreature(cid) <= 4) then
                        selfSay('Just wait, ' .. getCreatureName(cid) .. '.', _delay)
                        queuePlayer(cid)
                end
 
        else
                if (msgcontains(msg, 'bye')) then
                        selfSay('See you.', _delay)
                        getNext()
 
                elseif (msgcontains(msg, 'name')) then
                        _selfSay('I am Alexander.')
 
                elseif (msgcontains(msg, 'job')) then
                        _selfSay('I trade with runes and other magic items.')
 
                elseif (msgcontains(msg, 'time')) then
                        _selfSay('It\'s ' .. getTibiaTime() .. ' right now.')
 
                elseif (msgcontains(msg, 'king') or msgcontains(msg, 'tibianus')) then
                        _selfSay('The king has not much interest in magic items as far as I know.')
 
                elseif (msgcontains(msg, 'army')) then
                        _selfSay('The army uses weapons and armor rather then items of magic.')
 
                elseif (msgcontains(msg, 'ferumbras')) then
                        _selfSay('A hero has to be well prepared to face this threat.')
 
                elseif (msgcontains(msg, 'excalibug')) then
                        _selfSay('Ah, I would trade a fortune for this fabulous item.')
 
                elseif (msgcontains(msg, 'thais')) then
                        _selfSay('I am glad the king founded this academy far away from the mundane troubles of Thais')
 
                elseif (msgcontains(msg, 'tibia')) then
                        _selfSay('The world is filled with wonderous places and items.')
 
                elseif (msgcontains(msg, 'carlin')) then
                        _selfSay('I heard it\'s a city of druids.')
 
                elseif (msgcontains(msg, 'edron')) then
                        _selfSay('In our town, science and arts are thriving.')
 
                elseif (msgcontains(msg, 'news') or msgcontains(msg, 'rumors')) then
                        _selfSay('Ask for news and rumors in the tavern.')
 
                elseif (msgcontains(msg, 'offer') or msgcontains(msg, 'goods')) then
                        _selfSay('I\'m selling runes, life rings, wands, rods and crystal balls.')
 
                elseif (msgcontains(msg, 'rune') and not(msgcontains(msg, 'blank'))) then
                        _selfSay('I sell blank runes and spell runes.')
 
                elseif (_state == 1) then
                        if (msgcontains(msg, 'yes')) then
                                if (doPlayerRemoveMoney(cid, items[_index].sell * _count)) then
                                        for i = 1, _count do
                                                doPlayerAddItem(cid, items[_index].id, items[_index].subtype)
                                        end
 
                                        selfSay('Here you are.', _delay)
                                else
                                        selfSay('Come back, when you have enough money.', _delay)
                                end
 
                                updateIdle()
                        else
                                selfSay('Hmm, but next time.', _delay)
                        end
 
                        _state = 0
 
                elseif (_state == 2) then
                        if (msgcontains(msg, 'yes')) then
                                if (doPlayerRemoveItem(cid, items[_index].id, _count, items[_index].subtype)) then
                                        doPlayerAddMoney(cid, items[_index].buy * _count)
                                        selfSay('Ok. Here is your money.')
                                else
                                        if (count > 1) then
                                                selfSay('Sorry, you do not have so many.', _delay)
                                        else
                                                selfSay('Sorry, you do not have one.', _delay)
                                        end
                                end
 
                                updateIdle()
                        else
                                selfSay('Maybe next time.', _delay)
                        end
 
                        _state = 0
 
                else
                        for n = 0, table.getn(items) do
                                if (msgcontains(msg, items[n].name) or msgcontains(msg, items[n].name .. "s")) then
                                        _count = getCount(msg)
                                        _index = n
 
                                        if (msgcontains(msg, 'sell')) then
                                                onActionItem('sell')
                                                _state = 2
                                        else
                                                onActionItem('buy')
                                                _state = 1
                                        end
 
                                        updateIdle()
                                        break
                                end
                        end
                end
        end
end
 
function onThink()
        if (getFocus() ~= 0) then
                if (isIdle() or getDistanceToCreature(getFocus()) > 4) then
                        selfSay('See you.', _delay)
                        getNext()
                end
        end
end
 
Okay, so i added it, Its all fine but didnt work..

2u8gs9g.png


It says theres no file or directory, but there is ;S
 
Back
Top