• 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] Wands & Rods seller.

Piotrek1447

Member
Joined
Jun 1, 2007
Messages
658
Reaction score
16
Location
Rzeszów, Poland
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())
 
Sure :p
Code:
<?xml version="1.0" encoding="UTF-8"?>

<npc name="Horgretor" script="data/npc/scripts/wands.lua" autowalk="25" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="130" head="0" body="106" legs="57" feet="0" addons="0"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|." />
	</parameters>
</npc>
 
when i say Buy Wand Of infero or any wands or rods its says

[17/01/2008 19:13:18] Lua Script Error: [Npc interface]
[17/01/2008 19:13:18] data/npc/scripts/wands.lua:eek:nCreatureSay

[17/01/2008 19:13:18] data/npc/lib/npcsystem/modules.lua:669: attempt to index global 'npcHandler' (a nil value)
 
Back
Top