Alice Lovelin
New Member
- Joined
- Jul 14, 2018
- Messages
- 26
- Reaction score
- 0
I currently have this "Addoner" npc on my server, which allows you to bring him the items you need for addons, or, in the case of the outfits that are store-only in the original Tibia, you can give him "Raid Tokens" from the server events to get the Addons for these outfits. But what if I want to make him also offer the store outfits themselves? I know how to disable them from being unlocked by default, but I don't know how to program the npc to make the exchange.
Here's a sample of part of the NPC's programming in case you need for reference.
I'd love to learn this, thanks in advance.
Here's a sample of part of the NPC's programming in case you need for reference.
I'd love to learn this, thanks in advance.
Lua:
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 --
citizen = 22001
hunter = 22004
mage = 22056
knight = 22007
nobleman = 22009
summoner = 22011
warrior = 22013
barbarian = 22015
druid = 22017
wizard = 22019
oriental = 22021
pirate = 22023
assassin = 22025
beggar = 22027
shaman = 22029
norseman = 22031
nightmare = 22033
jester = 22035
brotherhood = 22037
wayfarer = 22039
pumpkin = 22040
yalaharian = 22041
glooth = 22042
rift = 22043
elementalist = 22044
newaddon = 'Here you are, enjoy your brand new addon!'
noitems = 'You do not have all the required items.'
noitems2 = 'You do not have all the required items or you do not have the first addon, 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!'
-- ELEMENTALIST START --
function elementalistFirst(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if isPremium(cid) then
addon = getPlayerStorageValue(cid,elementalist)
if addon == -1 then
if getPlayerItemCount(cid,13940) >= 1 then
if doPlayerRemoveItem(cid,13940,1) then
selfSay(newaddon, cid)
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerAddOutfit(cid, 432, 2)
doPlayerAddOutfit(cid, 433, 2)
setPlayerStorageValue(cid,elementalist,1)
end
else
selfSay(noitems, cid)
end
else
selfSay(already, cid)
end
end
end
function elementalistSecond(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if isPremium(cid) then
addon = getPlayerStorageValue(cid,elementalist+1)
if addon == -1 then
if getPlayerItemCount(cid,13756) >= 1 then
if doPlayerRemoveItem(cid,13756,1) then
selfSay(newaddon, cid)
doSendMagicEffect(getCreaturePosition(cid), 13)
doPlayerAddOutfit(cid, 432, 1)
doPlayerAddOutfit(cid, 433, 1)
setPlayerStorageValue(cid,elementalist+1,1)
end
else
selfSay(noitems, cid)
end
else
selfSay(already, cid)
end
end
end
-- ELEMENTALIST END --