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

Solved NPC Addon Script Error

Liztivien

New Member
Joined
Feb 15, 2010
Messages
8
Reaction score
0
Hey OT Land, hope someone can help me out with this..


I'm getting this error when I try to buy the second entrepreneur addon:
I'm running TFS 0.2.14 and 9.60.

Code:
[27/05/2013 16:11:13] Lua Script Error: [Npc interface] 
[27/05/2013 16:11:13] data/npc/scripts/addons.lua:onCreatureSay
[27/05/2013 16:11:13] data/npc/scripts/addons.lua:1732: attempt to perform arithmetic on global 'entrepreneur' (a nil value)
[27/05/2013 16:11:13] stack traceback:
[27/05/2013 16:11:13] 	[C]: in function '__add'
[27/05/2013 16:11:13] 	data/npc/scripts/addons.lua:1732: in function 'callback'
[27/05/2013 16:11:13] 	data/npc/lib/npcsystem/keywordhandler.lua:27: in function 'processMessage'
[27/05/2013 16:11:13] 	data/npc/lib/npcsystem/keywordhandler.lua:135: in function 'processNodeMessage'
[27/05/2013 16:11:13] 	data/npc/lib/npcsystem/keywordhandler.lua:103: in function 'processMessage'
[27/05/2013 16:11:13] 	data/npc/lib/npcsystem/npchandler.lua:387: in function 'onCreatureSay'
[27/05/2013 16:11:13] 	data/npc/scripts/addons.lua:7: in function <data/npc/scripts/addons.lua:7>

This is my addons.lua (the entrepreneur part at least)

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 

-- Storage IDs -- 
citizen     = 22001  
hunter        = 22003     
mage        = 22005     
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 
yalaharian    = 22039 
demonhunter    = 22041
warmaster		= 22043
wayfarer		= 22045
afflicted		= 22047
elementalist	= 22049
deepling		= 22051
insectoid		= 22053
enterpreneur	= 22055
crystalwarlord = 22057
soilguardian	= 22059


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!' 

-- ENTREPRENEUR START --

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

	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	if isPremium(cid) then
	addon = getPlayerStorageValue(cid,entrepreneur)
	if addon == -1 then
		if getPlayerItemCount(cid,9971) >= 45 then
		if doPlayerRemoveItem(cid,9971,45) then
			selfSay(newaddon, cid)
			
			doSendMagicEffect(getCreaturePosition(cid), 13)
			doPlayerAddOutfit(cid, 472, 1)
			doPlayerAddOutfit(cid, 471, 1)
			setPlayerStorageValue(cid,entrepreneur,1)
		end
		else
			selfSay(noitems, cid)
		end
	else
		selfSay(already, cid)
	end
	end

end

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

	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
	if isPremium(cid) then
	addon = getPlayerStorageValue(cid,entrepreneur+1)
	if addon == -1 then
		if getPlayerItemCount(cid,6092) >= 1 then
		if doPlayerRemoveItem(cid,6092,1) then
			selfSay(newaddon, cid)
			
			doSendMagicEffect(getCreaturePosition(cid), 13)
			doPlayerAddOutfit(cid, 472, 2)
			doPlayerAddOutfit(cid, 471, 2)
			setPlayerStorageValue(cid,entrepreneur+1,1)
		end 
		else 
			selfSay(noitems, cid) 
		end 
	else 
        selfSay(already, cid) 
    end 
    end 

end



-- ENTREPRENEUR END --

keywordHandler:addKeyword({'addons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can offer you first & second addons of the following outfits: {Citizen}, {Hunter}, {Mage}, {Knight}, {Nobleman}, {Summoner}, {Warrior}, {Barbarian}, {Druid}, {Wizard}, {Oriental}, {Pirate}, {Assassin}, {Beggar}, {Shaman}, {Norseman}, {Nightmare}, {Jester}, {Brotherhood}, {Demonhunter}, {Yalaharian}, {Warmaster}, {Wayfarer}, {Afflicted}, {Elementalist}, {Deepling}, {Insectoid} outfits."}) 
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "What you need to do is type '{first hunter addon}' or '{second hunter addon}' where you replace '{hunter}' with whatever outfit you'd like to achieve the addons for. Assuming you already collected all the required pieces, say 'yes' and voíla! - you got yourself an addon!"})

 node59 = keywordHandler:addKeyword({'first entrepreneur addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To achieve the {first entrepreneur addon} you need to give me {45 gold ingots}. Do you have them with you?'}) 
    node59:addChildKeyword({'yes'}, EntreFirst, {}) 
    node59:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true}) 

 node60 = keywordHandler:addKeyword({'second entrepreneur addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To achieve the {second entrepreneur addon} you need to give me a {very noble-looking watch}. Do you have it with you?'}) 
	node60:addChildKeyword({'yes'}, EntreSecond, {}) 
	node60: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())

Thanks in advance.
Liztivien

- - - Updated - - -

Figured it out.
 
Last edited:
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
 
citizen     = 22001  
hunter        = 22003     
mage        = 22005     
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 
yalaharian    = 22039 
demonhunter    = 22041
warmaster		= 22043
wayfarer		= 22045
afflicted		= 22047
elementalist	= 22049
deepling		= 22051
insectoid		= 22053
enterpreneur	= 22055
enterpreneur2	= 22060
crystalwarlord = 22057
soilguardian	= 22059 
 
newaddon = 'Here you are, enjoy your brand new addon!'
noitems        = 'You do not have all the required items.'
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!'
needoutfit        = '....' 
 
   function EntreFirst(cid, message, keywords, parameters, node)
 
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    if isPremium(cid) then
    enterpreneur = getPlayerStorageValue(cid,22055)
    if enterpreneur == -1 then
       if getPlayerItemCount(cid,9971) >= 45 then
        if doPlayerRemoveItem(cid,9971,45) then
            doPlayerSendTextMessage(cid, 22, "Here you are, enjoy your brand new addon!")
             doSendMagicEffect(getCreaturePosition(cid), 13)
            doPlayerAddAddons(cid, 471, 1)
            doPlayerAddAddons(cid, 472, 1)
            setPlayerStorageValue(cid,22055,1)
        end
        else
            selfSay(noitems, cid)
        end
    else
        selfSay(already, cid)
    end
    else
     selfSay(needoutfit, cid)
    end
end
end
 
function EntreSecond(cid, message, keywords, parameters, node)
 
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    if isPremium(cid) then
    enterpreneur2 = getPlayerStorageValue(cid,22060)
    if enterpreneur2 == -1 then
        if getPlayerItemCount(cid,6092) >= 1 then
        if doPlayerRemoveItem(cid,6092,1) then
            doPlayerSendTextMessage(cid, 22, "Here you are, enjoy your brand new addon!")
            doSendMagicEffect(getCreaturePosition(cid), 13)
            doPlayerAddAddons(cid, 471, 2)
            doPlayerAddAddons(cid, 472, 2)
            setPlayerStorageValue(cid,22060,1)
        end
        else
            selfSay(noitems, cid)
        end
    else
        selfSay(already, cid)
    end
   else
     selfSay(needoutfit, cid)
    end
    end
end
 
node1 = keywordHandler:addKeyword({'first entrepreneur addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To achieve the {first entrepreneur addon} you need to give me {45 gold ingots}. Do you have them with you?'})
    node1:addChildKeyword({'yes'}, EntreFirst, {})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})
 
 node2 = keywordHandler:addKeyword({'second entrepreneur addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To achieve the {second entrepreneur addon} you need to give me a {very noble-looking watch}. Do you have it with you?'})
    node2:addChildKeyword({'yes'}, EntreSecond, {})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got all neccessary items.', reset = true})
 
keywordHandler:addKeyword({'addons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can offer you first & second addons of the following outfits: {Citizen}, {Hunter}, {Mage}, {Knight}, {Nobleman}, {Summoner}, {Warrior}, {Barbarian}, {Druid}, {Wizard}, {Oriental}, {Pirate}, {Assassin}, {Beggar}, {Shaman}, {Norseman}, {Nightmare}, {Jester}, {Brotherhood}, {Demonhunter}, {Yalaharian}, {Warmaster}, {Wayfarer}, {Afflicted}, {Elementalist}, {Deepling}, {Insectoid} outfits."}) 
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "What you need to do is type '{first hunter addon}' or '{second hunter addon}' where you replace '{hunter}' with whatever outfit you'd like to achieve the addons for. Assuming you already collected all the required pieces, say 'yes' and voíla! - you got yourself an addon!"})

npcHandler:addModule(FocusModule:new())
 
Last edited:
Yeah, I figured it out after playing with it a little bit finally, just checked back today, and saw that you posted.

Rep+ for taking the time to help Cronox.
 
Back
Top