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

Lua Problem with the system of BLESS

icaro1988

New Member
Joined
Jul 1, 2009
Messages
63
Reaction score
1
I did one where I add the NPC Bless.
Plus the fact is that after he loses this player login Bless.
I was wondering if I missed something, or is somewhere I have to say that the player continue to Bless login, please if you can help me, below follows the script of my NPC.

PHP:
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


local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
function creatureSayCallback(cid, type, msg)

    if (not npcHandler:isFocused(cid)) then
        return false
    end

    if msgcontains(msg, 'the fire of the suns') then
	  if getPlayerBlessing(cid,3) == FALSE then
	    if getPlayerLevel(cid) >= 1 and getPlayerLevel(cid) <= 30 then
             npcHandler:say('Do you wish to receive the blessing of the two suns? It will cost you 2000 gold, pilgrim.', cid)
             talk_state = 1
		end	 
      else
       npcHandler:say('You already possess this blessing.', cid)	
       npcHandler:resetNpc()
       return TRUE		
      end				 
    elseif getPlayerLevel(cid) >= 1 and getPlayerLevel(cid) <= 30 and getPlayerBlessing(cid,3) == FALSE and msgcontains(msg, 'yes') and talk_state == 1 then
		    if doPlayerRemoveMoney(cid, 2000) == TRUE then
		     npcHandler:say('Kneel down and receive the warmth of sunfire, pilgrim.', cid)
             doSendMagicEffect(getCreaturePosition(cid), 12)
			 doPlayerAddBlessing(cid,3)
			 npcHandler:resetNpc()
             return TRUE			 
			else
			 npcHandler:say('Oh. You do not have enough money.', cid)
             talkState[talkUser] = 1
			 npcHandler:resetNpc()
             return TRUE			 
	        end	
	end
    return TRUE
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
blesser.xml
HTML:
<?xml version="1.0"?>

<npc name="Blesser" script="data/npc/scripts/bless.lua" access="5" lookdir="2">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="134" head="78" body="87" legs="95" feet="88" addons="3"/>
</npc>
bless.lua
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({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
	node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = true, cost = 10000})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
	node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 2, premium = true, cost = 10000})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
	node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 3, premium = true, cost = 10000})
	node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
	node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 4, premium = true, cost = 10000})
	node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
	node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, premium = true, cost = 10000})
	node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

npcHandler:addModule(FocusModule:new())
 
Back
Top