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

alissonfgp

LUA, C, C++, C#
Joined
Jul 13, 2011
Messages
111
Reaction score
29
Location
Brazil
already many are complaining that I posted in the wrong place, I decided to assemble and post here ...

insert in 050-function

Code:
function getItemsFromList(items)
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end
function doRemoveItemsFromList(cid,items) 
local count = 0
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
if getPlayerItemCount(cid,items[i][1]) >= items[i][2] then
count = count + 1 end  end  end
if count == table.maxn(items) then
for i = 1, table.maxn(items) do doPlayerRemoveItem(cid,items[i][1],items[i][2]) end
else return false end
return true end

Chondur.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Chondur" script="data/npc/scripts/Chondur.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="154" head="0" body="94" legs="120" feet="116" addons="3"/>
<parameters>
<parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="rituals;" />
        <parameter key="keyword_reply1" value="Hm. I don't think you need another one of my counterspells to cross the barrier on Goroma." />
<parameter key="module_shop" value="1" />
		<parameter key="shop_sellable" value="Mysterious Voodoo Skull,5669,4000;Enigmatic Voodoo Skull,5670,4000;black skull,9969,4000;blood herb,2798,500;blood goblet,9447,10000;" />
        <parameter key="message_greet" value="Be greeted, child. What do you want in an old shaman's hut?"/>
        <parameter key="message_farewell" value="Good bye."/>
		<parameter key="message_walkaway" value="Good bye!" />
		<parameter key="message_sendtrade" value="Well, I currently buy mysterious and enigmatic voodoo skulls and a few other things I might need for my rituals." />
</parameters>
</npc>


Chondur.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
function AddMount(cid, message, keywords, parameters, node) 
if(not npcHandler:isFocused(cid)) then
return false
end
if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
npcHandler:say('You must reach level ' .. parameters.level .. ' to buy this mount.', cid)
elseif canPlayerRideMount(cid, parameters.mountid) then
npcHandler:say('you already have this mount!', cid)
elseif not doRemoveItemsFromList(cid,parameters.items) then
npcHandler:say('Sorry You need '..getItemsFromList(parameters.items)..' to buy this mount!', cid)
else
doPlayerAddMount(cid, parameters.mountid)
npcHandler:say('Here is your mount!', cid)
npcHandler:resetNpc()
end
else
npcHandler:say('I can only allow premium players to buy this mount.', cid)
end
npcHandler:resetNpc()
return true
end
local mounts = {
{"stampor", items = {{13300,100}, {13299,50},{13301,30}}, mountid = 11, level = 15, premium = false},
{"mounts", text = "I sell these mounts: {stampor}!"}
}
for i = 1, #mounts do local get = mounts[i] if type(get.items) == "table" then
local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You want to buy the mount " .. get[1] .. " for "..getItemsFromList(get.items).." ?"})
node:addChildKeyword({"yes"}, AddMount, {items = get.items,mountid = get.mountid, level = get.level, premium = get.premium})
node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Ok, then.", reset = true})
else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end
mounts = nil npcHandler:addModule(FocusModule:new())


-- Storage IDs --
fshaman        = 22020
sshaman        = 22021   

newaddon    = 'Ah, right! The shaman mask! Here you go.'
noitems        = 'You do not have all the required items.'
noitems2    = 'You do not have all the required items or you do not have the outfit, which by the way, is a requirement for this addon.'
already        = 'It seems you already have this addon, don\'t you try to mock me son!'


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

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

    if getPlayerStorageValue(cid,fshaman) == -1 then
        if getPlayerItemCount(cid,3955) >= 5 and getPlayerItemCount(cid,5015) >= 1 and getPlayerItemCount(cid,5810) >= 5 then
        if doPlayerRemoveItem(cid,3955,5) and doPlayerRemoveItem(cid,5015,1) and doPlayerRemoveItem(cid,5810,5) then
            npcHandler:say('Ah, right! The shaman staff! Here you go.')             
            doSendMagicEffect(getCreaturePosition(cid), 13)
			setPlayerStorageValue(cid,fshaman,1)
			if getPlayerSex(cid) == 1 then 
            doPlayerAddOutfit(cid, 154, 2)
			elseif getPlayerSex(cid) == 0 then
            doPlayerAddOutfit(cid, 158, 2)
        end    
        end
        else
            selfSay(noitems)
        end
    else
        selfSay(already)
   
    end

end

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

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

    if getPlayerStorageValue(cid,sshaman) == -1 then
        if getPlayerItemCount(cid,3966) >= 5 and getPlayerItemCount(cid,3967) >= 5 then
        if doPlayerRemoveItem(cid,3966,5) and doPlayerRemoveItem(cid,3967,5) then
            npcHandler:say('Ah, right! The shaman mask! Here you go.')             
            doSendMagicEffect(getCreaturePosition(cid), 13)
			setPlayerStorageValue(cid,sshaman,1)
			if getPlayerSex(cid) == 1 then 
            doPlayerAddOutfit(cid, 154, 1)
			elseif getPlayerSex(cid) == 0 then
            doPlayerAddOutfit(cid, 158, 1)
        end    
        end
        else
            selfSay(noitems)
        end
    else
        selfSay(already)
    end

end



node1 = keywordHandler:addKeyword({'staff'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To get shaman staff you need give me 5 Pirate Voodoo Doll, 5 Dworc Voodoo Dolls and 1 Mandrake. Do you have them with you?'})
node1:addChildKeyword({'yes'}, ShamanFirst, {})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

node3 = keywordHandler:addKeyword({'first'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To get shaman staff you need give me 5 Pirate Voodoo Doll, 5 Dworc Voodoo Dolls and 1 Mandrake. Do you have them with you?'})
node3:addChildKeyword({'yes'}, ShamanFirst, {})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

node2 = keywordHandler:addKeyword({'mask'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To get shaman mask you need give me 5 banana staffs and 5 tribal masks. Do you have them with you?'})
node2:addChildKeyword({'yes'}, ShamanSecond, {})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})

node4 = keywordHandler:addKeyword({'second'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To get shaman mask you need give me 5 banana staffs and 5 tribal masks. Do you have them with you?'})
node4:addChildKeyword({'yes'}, ShamanSecond, {})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})


npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top