• 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 for ADDON

moderhuis

Noob uit Leeuwarden
Joined
Feb 24, 2008
Messages
82
Reaction score
0
Location
Netherlands
Hey!


I have a NPC that can give you addons for items..
like, first citizen addon for 100 mino leathers~


But now I want to create different NPCs for each addon
so, a NPC that give you first citizen addon for [itemname]

But not all the others only that one, example:

Player: Hi
NPC: Hey, do you like my backpack, do you want one to wear?
Player: yes
NPC: Alright, but you need to give me 100 minotaur leathers for it, come back when you have them..
 


Yes, i know that, that one I'm using right now..
I need to know how to add a NPC that only gives you one addon and not all addons :p

Like when you go to the .. well lets say, distance weapon seller, you can trade Sniper gloves for the glove's addon for hunter, and wehn you go to the magic shop, you can change a ferumbras hat for the addon hat for mage's, and if you go to a deeper underground place with a demonish npc, that says, I need a skull helmet for the first Wizard addon, and if you have the skull you can get the addon..
 
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

function buyAddons(cid, message, keywords, parameters, node)
--TODO: buyAddons function in modules.lua
if(not npcHandler:isFocused(cid)) then
return false
end

local addon = parameters.addon
local cost = parameters.cost
local premium = (parameters.premium ~= nil and parameters.premium)

if isPlayerPremiumCallback == nil or (isPlayerPremiumCallback(cid) and premium) then
if doPlayerRemoveMoney(cid, cost) == TRUE then
doPlayerAddAddons(cid, addon)
npcHandler:say('There, you are now able to use all addons!', cid)
else
npcHandler:say('Sorry, you do not have enough money.', cid)
end
else
npcHandler:say('I only serve customers with premium accounts.', cid)
end

keywordHandler:moveUp(1)
return true
end

local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for 100.000 gold coins?'})
node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 100000, premium = true})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for 200.000 gold coins?'})
node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 200000, premium = true})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the -first addons- set for 100.000 gold coins and the -second addons- set for 200000 gold coins.'})

npcHandler:addModule(FocusModule:new())




IS IT YOUR QUESTION? i dont know but it gives you all firsts addons and all second addons, :p
 
Back
Top