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

!Npc! Addon items...

Tsson

New Member
Joined
Nov 4, 2007
Messages
76
Reaction score
0
hello, can someone make a npc script for addon items like...

me: enchanted chicken wing
Npc: do you want to exchange boots of haste for a enchanted chicken wing.

you know what i mean :p

i would be happy if someone could help me =)
 
here ya go

Here ya go i did't made the script i just edited for you.

the npc.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

-- Storage IDs --
local assassin    = 85025  


local newaddon    = 'Cling clang!'
local noitems        = 'Lil\'one no have item?'
local noitems2    = 'Lil\'one no have item?'
local already        = 'We have already traded!'
        
-- ASSASSIN START --
function AssassinFirst(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if isPremium(cid) then
    addon = getPlayerStorageValue(cid,assassin)
    if addon == -1 then
        if getPlayerItemCount(cid,2195) >= 3 then
        if doPlayerRemoveItem(cid,2195,3) then
            selfSay(newaddon)
             
            doSendMagicEffect(getCreaturePosition(cid), 13)
            doPlayerAddItem(cid,5891,1)
            setPlayerStorageValue(cid,assassin,1)
        end
        else
            selfSay(noitems)
        end
    else
        selfSay(already)
    end
    end

end
function AssassinFirst(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if isPremium(cid) then
    addon = getPlayerStorageValue(cid,assassin)
    if addon == -1 then
        if getPlayerItemCount(cid,2498) >= 2 then
        if doPlayerRemoveItem(cid,2498,2) then
            selfSay(newaddon)
             
            doSendMagicEffect(getCreaturePosition(cid), 13)
            doPlayerAddItem(cid,5884,1)
            setPlayerStorageValue(cid,assassin,1)
        end
        else
            selfSay(noitems)
        end
    else
        selfSay(already)
    end
    end

end

function AssassinSecond(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

       if isPremium(cid) then
    addon = getPlayerStorageValue(cid,assassin)
    if addon == -1 then
        if getPlayerItemCount(cid,2475) >= 4 then
        if doPlayerRemoveItem(cid,2475,4) then
            selfSay(newaddon)
             
            doSendMagicEffect(getCreaturePosition(cid), 13)
            doPlayerAddItem(cid,5885,1)
            setPlayerStorageValue(cid,assassin+1,1)
        end
        else
            selfSay(noitems)
        end
    else
        selfSay(already)
    end
    end

end

function AssassinThird(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end

       if isPremium(cid) then
    addon = getPlayerStorageValue(cid,assassin)
    if addon == -1 then
        if getPlayerItemCount(cid,2392) >= 3 then
        if doPlayerRemoveItem(cid,2392,3) then
            selfSay(newaddon)
             
            doSendMagicEffect(getCreaturePosition(cid), 13)
            doPlayerAddItem(cid,5904,1)
            setPlayerStorageValue(cid,assassin+2,1)
        end
        else
            selfSay(noitems)
        end
    else
        selfSay(already)
    end
    end

end
-- ASSASSIN END --

keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Hum Humm! Welcume lil' Player. I forge steel from itens."})
keywordHandler:addKeyword({'steel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "There is many kind of steel please look on tibia wikia for more information."})


local node1 = keywordHandler:addKeyword({'Enchanted Chicken Wing'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade your 3 boots of haste for 1 of mine enchanted chicken wing?'})
    node1:addChildKeyword({'yes'}, AssassinFirst, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})

local node1 = keywordHandler:addKeyword({'Fighting Spirit'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade your 2 royal helmets for 1 of mine fighting spirits?'})
    node1:addChildKeyword({'yes'}, AssassinFirst, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})

local node2 = keywordHandler:addKeyword({'warrior sweat'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade your 4 warrior helmets for 1 of mine warriors sweat?'})
    node2:addChildKeyword({'yes'}, AssassinSecond, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})

local node3 = keywordHandler:addKeyword({'Magic Sulphur'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to trade your 3 fire swords for 1 of mine magic sulphur?'})
    node3:addChildKeyword({'yes'}, AssassinThird, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got the neccessary items.', reset = true})

npcHandler:addModule(FocusModule:new())

The npc.xml
Code:
<?xml version="1.0"?>
<npc name="Haroun" script="data/npc/scripts/Haroun.lua" access="5" lookdir="2" walkinterval="2000">
  <mana now="800" max="800" />
  <health now="200" max="200" />
  <look type="136" head="0" body="0" legs="0" feet="0" addons="3" />
  <parameters>
    <parameter key="message_greet" value="Welcome |PLAYERNAME|." />
  </parameters>
</npc>
 
You propably mean Blue Djinn and Sweaty Cyclop. Here they are:
sweaty cyclop.lua
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)

-- use the real conversation? (true/false)
real = false

if real == true then
tradeMsg = 'Me can make good item from item me need. Me make uth\'kean, za\'ralator, uth\'lokr, uth\'prta and nasty lil\' bolts.'
else
tradeMsg = 'I can forge you royal steel from crown armors, hell steel from devil helmets, draconian steel from dragon shields, crude iron from giant swords and infernal bolts from soul orbs.'
crownMsg = 'Do you want trade a crown armor for royal steel?'
devilMsg = 'Do you want trade a devil helmet for hell steel?'
dragoMsg = 'Do you want trade a dragon shield for draconian steel?'
giantMsg = 'Do you want trade a giant sword for crude iron?'
souloMsg = 'Do you want trade a soul orb for 2 infernal bolts?'
sweatMsg = 'Do you want trade a warriors sweat for 4 warrior helmets?'
hasNoMsg = 'Come back when you have more!'
noMsg = 'Ok than.'
end
if msgcontains(msg, 'items') or msgcontains(msg, 'item') or msgcontains(msg, 'forge') then
selfSay(tradeMsg)
elseif msgcontains(msg, 'royal steel') or msgcontains(msg, 'royal') or msgcontains(msg, 'crown') or msgcontains(msg, 'crown armor') or msgcontains(msg, 'uth\'kean') then
selfSay(crownMsg)
talk_state = 1
elseif msgcontains(msg, 'hell steel') or msgcontains(msg, 'hell') or msgcontains(msg, 'devil') or msgcontains(msg, 'devil helmet') or msgcontains(msg, 'za\'ralator') then
selfSay(devilMsg)
talk_state = 2
elseif msgcontains(msg, 'draconian steel') or msgcontains(msg, 'draconian') or msgcontains(msg, 'dragon') or msgcontains(msg, 'dragon shield') or msgcontains(msg, 'uth\'lokr') then
selfSay(dragoMsg)
talk_state = 3
elseif msgcontains(msg, 'crude iron') or msgcontains(msg, 'crude') or msgcontains(msg, 'giant') or msgcontains(msg, 'gs') or msgcontains(msg, 'giant sword') or msgcontains(msg, 'uth\'prta') then
selfSay(giantMsg)
talk_state = 4
elseif msgcontains(msg, 'infernal') or msgcontains(msg, 'infernal bolt') or msgcontains(msg, 'infernal bolts') or msgcontains(msg, 'soul') or msgcontains(msg, 'soul orb') or msgcontains(msg, 'soul orbs') or msgcontains(msg, 'nasty lil\' bolt') then
selfSay(souloMsg)
talk_state = 5
elseif msgcontains(msg, 'warriors sweat') or msgcontains(msg, 'warriors sweat') or msgcontains(msg, 'warriorssweat') or msgcontains(msg, 'warrior helmet') or msgcontains(msg, 'warrior helmets') then
selfSay(sweatMsg)
talk_state = 6
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,2487) >= 1 then
if doPlayerTakeItem(cid,2487,1) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5887,1)
end
else
selfSay(hasNoMsg)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 then
if getPlayerItemCount(cid,2462) >= 1 then
if doPlayerTakeItem(cid,2462,1) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5888,1)
end
else
selfSay(hasNoMsg)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 3 then
if getPlayerItemCount(cid,2516) >= 1 then
if doPlayerTakeItem(cid,2516,1) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5889,1)
end
else
selfSay(hasNoMsg)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 4 then
if getPlayerItemCount(cid,2393) >= 1 then
if doPlayerTakeItem(cid,2393,1) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5892,1)
end
else
selfSay(hasNoMsg)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 5 then
if getPlayerItemCount(cid,5944) >= 1 then
if doPlayerTakeItem(cid,5944,1) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,6529,2)
end
else
selfSay(hasNoMsg)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 6 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(hasNoMsg)
end
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 6) then
selfSay(noMsg)
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())

sweaty cyclop.xml:
Code:
<?xml version="1.0"?>
<npc name="Sweaty Cyclop" script="data/npc/scripts/sweaty cyclop.lua" access="3" walkinterval="2000">
 	<look type="22" head="0" body="3" legs="0" feet="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I can give you different steels for different items." />
</parameters> 
</npc>

blue_djinn.lua:
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)

-- use the real conversation? (true/false)
real = true

if real == true then
tradeMsg = 'I can give you magic sulphurs for 3 fire swords, fighting spirits for 2 royal helmets, enchanted chicken wings for 1 boots of haste.'
magicMsg = 'I need 3 fire swords to give you a magic sulphur.'
spiritMsg = 'I need 2 royal helmets to give u a fighting spirit.'
wingMsg = 'I need 1 pair of boots of haste to give you an enchanted chicken wing.'
hasNoMsg = 'You dont have the items i need.'
noMsg = 'Bye then...'
else
tradeMsg = 'I can forge you royal steel from crown armors, hell steel from devil helmets, draconian steel from dragon shields, crude iron from giant swords and infernal bolts from soul orbs.'
magicMsg = 'Do you want trade a crown armor for royal steel?'
spiritMsg = 'Do you want trade a devil helmet for hell steel?'
wingMsg = 'Do you want trade a devil helmet for hell steel?'
hasNoMsg = 'Come back when you have more!'
noMsg = 'Ok than.'
end
if msgcontains(msg, 'items') or msgcontains(msg, 'item') or msgcontains(msg, 'forge') then
selfSay(tradeMsg)
elseif msgcontains(msg, 'fire swords') or msgcontains(msg, 'magic sulphur') or msgcontains(msg, 'magicsulphur') or msgcontains(msg, 'fireswords') then
selfSay(magicMsg)
talk_state = 1
elseif msgcontains(msg, 'royal helmets') or msgcontains(msg, 'royalhelmets') or msgcontains(msg, 'fighting spirit') or msgcontains(msg, 'fightingspirit') then
selfSay(spiritMsg)
talk_state = 2
elseif msgcontains(msg, 'boots of haste') or msgcontains(msg, 'boh') or msgcontains(msg, 'enchanted chicken wing') or msgcontains(msg, 'chicken wing') then
selfSay(wingMsg)
talk_state = 3
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,2392) >= 3 then
if doPlayerTakeItem(cid,2392,3) == 0 then
selfSay('Here you are.')
doPlayerAddItem(cid,5904,1)
end
else
selfSay(hasNoMsg)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 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(hasNoMsg)
end
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 3 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(hasNoMsg)
end
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 3) then
selfSay(noMsg)
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())

blue djinn.xml:
Code:
<?xml version="1.0"?>
<npc name="Blue Djinn" script="data/npc/scripts/blue_djinn.lua" access="3" walkinterval="2000">
 	<look type="80" head="20" body="30" legs="40" feet="50"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I can give you different steels for different items." />
</parameters>
</npc>

Please rep++

Your's ballack13
 
Back
Top