Piotrek1447
Member
I make npc who selling all wands, rods and giving first wand/rod for free.
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
function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, 'wand of vortex') then
if getPlayerVocation(cid) == 1 then
if getPlayerStorageValue(cid, 1000) == -1 then
selfSay('Here is your first wand young sorcerer.')
doPlayerAddItem(cid,2190,1)
setPlayerStorageValue(cid,1000,1)
else
selfSay('Do you want to buy wand of vortex for 500 gold coins?')
talkState = 1
end
else
selfSay('Wand of Vortex is only for sorcerers.')
end
elseif msgcontains(msg, 'snakebite rod') then
if getPlayerVocation(cid) == 2 then
if getPlayerStorageValue(cid, 1000) == -1 then
selfSay('Here is your first rod young druid.')
doPlayerAddItem(cid,2182,1)
setPlayerStorageValue(cid,1000,1)
else
selfSay('Do you want to buy wand of vortex for 500 gold coins?')
talkState = 2
end
else
selfSay('Snakebite Rod is only for druids.')
end
elseif msgcontains(msg, 'yes') and talkState == 1 then
if doPlayerRemoveMoney(cid, 500) == TRUE then
doPlayerAddItem(cid, 2190, 1)
selfSay('Here you are.')
else
selfSay('Sorry '..getCreatureName(cid)..', you don\'t have enough money.')
end
elseif msgcontains(msg, 'yes') and talkState == 2 then
if doPlayerRemoveMoney(cid, 500) == TRUE then
doPlayerAddItem(cid, 2182, 1)
selfSay('Here you are.')
else
selfSay('Sorry '..getCreatureName(cid)..', you don\'t have enough money.')
end
elseif msgcontains(msg, 'no') and (talkState > 1 and talkState < 2) then
selfSay("Then not.")
talkState = 0
end
return true
end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'wand of inferno', 'inferno'}, 2187, 15000, 'wand of inferno')
shopModule:addBuyableItem({'wand of plague', 'plague'}, 2188, 5000, 'wand of plague')
shopModule:addBuyableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 10000, 'explosion rune')
shopModule:addBuyableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 1000, 'wand of dragonbreath')
shopModule:addBuyableItem({'quagmire rod', 'quagmire'}, 2181, 10000, 'quagmire rod')
shopModule:addBuyableItem({'tempest rod', 'tempest'}, 2183, 15000, 'tempest rod')
shopModule:addBuyableItem({'volcanic rod', 'volcanic'}, 2185, 5000, 'volcanic rod')
shopModule:addBuyableItem({'moonlight rod', 'moonlight'}, 2186, 1000, 'moonlight rod')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())