• 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] NPC write off the channel "default" and "PW" at the same time

sessam

New Member
Joined
Dec 28, 2009
Messages
55
Reaction score
1
Welcome back!
I have a small problem with the NPC. If you will be welcomed to the NPC "hi". NPC write off on my default, and a private message.

npc.png


How to set just to write privately to the players? I was looking for it in C++ code, but have not found. This only happens when it will be welcomed. If a thief like the "promotion"is the only write off private message.

33946165.png
 
NPC

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Ozua" script="promotion.lua" walkinterval="3000" floorchange="0">
	<health now="100" max="100"/>
	<look type="18" head="77" body="119" legs="0" feet="0" addons="1"/>
	<parameters>
		<parameter key="message_greet" value="Aaa! Bu!!! |PLAYERNAME| for a small fee, the gods will give you a new gift! You need {Promotion}?"/>
		<parameter key="message_needmoremoney" value="You do not have enough money."/>
		<parameter key="message_decline" value="Maybe next time?"/>
	</parameters>
</npc>

Script
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

local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
--[[
local node2 = keywordHandler:addKeyword({'epic'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can epicize you for 200000 gold coins. Do you want me to epicize you?'})
	node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level = 120, promotion = 2, text = 'Congratulations! You are now epicized.'})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
]]--

npcHandler:addModule(FocusModule:new())
 
npc.xml
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Ozua" script="promotion.lua" walkinterval="3000" floorchange="0">
    <health now="100" max="100"/>
    <look type="18" head="77" body="119" legs="0" feet="0" addons="1"/>
    <parameters>
<parameter key="message_greet" value="Aaa! Bu!!! |PLAYERNAME| for a small fee, the gods will give you a new gift! You need {Promotion}?"/>
		<parameter key="message_needmoremoney" value="You do not have enough money."/>
		<parameter key="message_decline" value="Maybe next time?"/>

    </parameters>
</npc>
promotion.lua
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




local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
--[[
local node2 = keywordHandler:addKeyword({'epic'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can epicize you for 200000 gold coins. Do you want me to epicize you?'})
	node2:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 200000, level = 120, promotion = 2, text = 'Congratulations! You are now epicized.'})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})
]]--


npcHandler:addModule(FocusModule:new())
 
nubaks. its a bug in npc system

remove 1 line in each function in npchandler.lua
Code:
	-- Makes sure the npc un-focuses the currently focused player
	function NpcHandler:unGreet(cid)
		if(not self:isFocused(cid)) then
			return
		end

		local callback = self:getCallback(CALLBACK_FAREWELL)
		if(callback == nil or callback(cid)) then
			if(self:processModuleCallback(CALLBACK_FAREWELL)) then
				if(self.queue == nil or not self.queue:greetNext()) then
					local msg = self:getMessage(MESSAGE_FAREWELL)
					local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid) }
					msg = self:parseMessage(msg, parseInfo)

					self:say(msg, cid)
					self:releaseFocus(cid)
					[B][COLOR="red"]self:say(msg)[/COLOR][/B]
				end
			end
		end
	end
Code:
	-- Greets a new player.
	function NpcHandler:greet(cid)
		if(cid ~= 0) then
			local callback = self:getCallback(CALLBACK_GREET)
			if(callback == nil or callback(cid)) then
				if(self:processModuleCallback(CALLBACK_GREET, cid)) then
					local msg = self:getMessage(MESSAGE_GREET)
					local parseInfo = { [TAG_PLAYERNAME] = getCreatureName(cid) }
					msg = self:parseMessage(msg, parseInfo)

					[B][COLOR="red"]self:say(msg)[/COLOR][/B]
					self:addFocus(cid)
					self:say(msg, cid)
				end
			end
		end
	end
Code:
	-- Should be called on this npc's focus if the distance to focus is greater then talkRadius.
	function NpcHandler:onWalkAway(cid)
		if(self:isFocused(cid)) then
			local callback = self:getCallback(CALLBACK_CREATURE_DISAPPEAR)
			if(callback == nil or callback(cid)) then
				if(self:processModuleCallback(CALLBACK_CREATURE_DISAPPEAR, cid)) then
					if(self.queue == nil or not self.queue:greetNext()) then
						local msg = self:getMessage(MESSAGE_WALKAWAY)
						local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid) }
						msg = self:parseMessage(msg, parseInfo)

						[B][COLOR="red"]self:say(msg, cid)[/COLOR][/B]
						self:releaseFocus(cid)
						self:say(msg)
					end
				end
			end
		end
	end
 
Back
Top