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

Question about custom text lines

Nubs

NGC
Joined
May 3, 2009
Messages
9
Reaction score
0
Location
Missouri
And I definitely put this in the wrong part of the forum, I'd appreciate it if I could get it moved to the support forum. Sorry for the hassle.


I'm having a bit of a problem with my NPC's using text lines that aren't preset in the npchandler.

I've looked around for a post that deals with this, but didn't find it. Then again, I could just be an idiot and have overlooked it. If there is one, then sorry, lol.

I tried adding the other parameters I needed to just this one, but I couldn't get them to work. It was the needmoremoney and the decline parameters.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Harrold the Tailor" script="data/npc/scripts/addons.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="309" head="78" body="88" legs="0" feet="88" addons="0"/>
    [color=red]<parameters>
        <parameter key="message_greet" value="Greetings |PLAYERNAME|. I am the Nexus tailor." />
    </parameters>[/color]
</npc>

And

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

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('[color=red]What is this? Are you kidding me? GET OUT![/color]', 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 5000 gold coins?'})
	node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 5000, premium = true})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = '[color=red]Then why are you here?[/color]'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for 10000 gold coins?'})
	node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 10000, premium = true})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = '[color=red]Then why are you here?[/color]'})

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

npcHandler:addModule(FocusModule:new())

The greeting line works fine, but when I get down to the script for it, I keep getting nil values. I highlighted the only text I changed. I'm guessing I screwed with the npchandler by changing the preset text in the script, I don't know. First time I've been back to messing with OT's in 2 years, so I'm not doin too well so far xD. I would appreciate any help I could get.
 
Last edited:
that's in data\npc\lib\npcsystem\npcsystem.lua:
Code:
message_greet
message_farewell
message_decline
message_needmorespace
message_needspace
message_sendtrade
message_noshop
message_oncloseshop
message_onbuy
message_onsell
message_missingmoney
message_needmoney
message_missingitem
message_needitem
message_idletimeout
message_walkaway
message_alreadyfocused
message_placedinqueue
message_buy
message_sell
message_bought
message_sold

in .../npcsystem/npchandler.lua:

Code:
			-- These are the default replies of all npcs. They can/should be changed individually for each npc.
			[MESSAGE_GREET] 	= 'Welcome, |PLAYERNAME|! I have been expecting you.',
			[MESSAGE_FAREWELL] 	= 'Good bye, |PLAYERNAME|!',
			[MESSAGE_BUY] 		= 'Do you want to buy |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold coins?',
			[MESSAGE_ONBUY] 	= 'It was a pleasure doing business with you.',
			[MESSAGE_BOUGHT] 	= 'Bought |ITEMCOUNT|x |ITEMNAME| for |TOTALCOST| gold.',
			[MESSAGE_SELL] 		= 'Do you want to sell |ITEMCOUNT| |ITEMNAME| for |TOTALCOST| gold coins?',
			[MESSAGE_ONSELL] 	= 'Thank you for this |ITEMNAME|, |PLAYERNAME| gold.',
			[MESSAGE_SOLD]	 	= 'Sold |ITEMCOUNT|x |ITEMNAME| for |TOTALCOST| gold.',
			[MESSAGE_MISSINGMONEY]	= 'Sorry, you don\'t have enough money.',
			[MESSAGE_NEEDMONEY] 	= 'You do not have enough money.',
			[MESSAGE_MISSINGITEM] 	= 'You don\'t even have that item, |PLAYERNAME|!',
			[MESSAGE_NEEDITEM]	= 'You do not have this object.',
			[MESSAGE_NEEDSPACE]	= 'You do not have enough capacity.',
			[MESSAGE_NEEDMORESPACE]	= 'You do not have enough capacity for all items.',
			[MESSAGE_IDLETIMEOUT] 	= 'Next, please!',
			[MESSAGE_WALKAWAY] 	= 'How rude!',
			[MESSAGE_DECLINE]	= 'Not good enough, is it... ?',
			[MESSAGE_SENDTRADE]	= 'Here\'s my offer, |PLAYERNAME|. Don\'t you like it?',
			[MESSAGE_NOSHOP]	= 'Sorry, I\'m not offering anything.',
			[MESSAGE_ONCLOSESHOP]	= 'Thank you, come back when you want something more.',
			[MESSAGE_ALREADYFOCUSED]= '|PLAYERNAME|! I am already talking to you...',
			[MESSAGE_PLACEDINQUEUE] = '|PLAYERNAME|, please wait for your turn. There are |QUEUESIZE| customers before you.'

Regards,
Hermes
 
Back
Top