• 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

WibbenZ

Global Moderator
Staff member
Global Moderator
Joined
Oct 16, 2008
Messages
6,374
Solutions
229
Reaction score
1,503
Location
Sweden
script:
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


local node1 = keywordHandler:addKeyword({'bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy blessings for 60000 gold?'})
	node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1,2,3,4,5, cost = 60000})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})	

npcHandler:addModule(FocusModule:new())

How can I make soo it adds all bless?
oh heres the XML.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Secret Blesser" script="data/npc/scripts/bless.lua" walkinterval="0" speed="500" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="138" head="55" body="68" legs="96" feet="32" corpse="2212"/>
	<parameters>
	<parameter key="message_greet" value="Hello,  |PLAYERNAME|. I sell blessings for 60.000 gold coins each." />	
	</parameters>
</npc>


plx help rep++ :D
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

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(not npcHandler:isFocused(cid)) then
		return false
	end
	
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	cost = ((2000+getPlayerLevel(cid)*1000)*5)

	if(msgcontains(msg, 'all blessings')) then
	
		if(isPremium(cid) == false)then
			selfSay('I only bless players with a premium account.', cid)
			return
		end
		
		selfSay('Would you like to be blessed with all blessings for '..cost..' gold?', cid)
		talkState[talkUser] = 1
		
		else if(msgcontains(msg, 'yes') and (talkState[talkUser] == 1)) then
			if(doPlayerRemoveMoney(cid, cost) == false) then
				selfSay('You dont have enough gold to be blessed with all blessings.', cid)
				return
			end
			
			selfSay('There you go!', cid)
			
			for i=1,5 do
				doPlayerAddBlessing(cid, i)
			end
			
			doSendMagicEffect(getCreaturePosition(cid), 12)
			talkState[talkUser] = 0	
		
			else if(msgcontains(msg, 'no') and (talkState[talkUser] == 1)) then
				selfSay('Very well.', cid)
				talkState[talkUser] = 0
			end
		end		
	end		
	
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Back
Top Bottom