• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Bless npc for free.

Kayan

Active Member
Joined
Sep 19, 2007
Messages
1,561
Reaction score
38
Location
Santa Catarina
Hello i need this npc working for free accounts.

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 creatureSayCallback(cid, type, msg)
	--- TODO: bless function in modules.lua
	if(npcHandler.focus ~= cid) then
		return FALSE
	end

	if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
		npcHandler:say("I can provide you with five blessings... the 'the spiritual shielding', 'the spark of the phoenix', 'the embrace of tibia', 'the fire of the suns' and the 'the wisdom of solitude', they cost 20000 gold coins each.")
		talkState = 0
	elseif msgcontains(msg, 'the spiritual shielding') then
		npcHandler:say("Do you want to buy the first blessing for 20000 gold?")
		talkState = 1
	elseif msgcontains(msg, 'the spark of the phoenix') then
		npcHandler:say("Do you want to buy the second blessing for 20000 gold?")
		talkState = 2
	elseif msgcontains(msg, 'the embrace of tibia') then
		npcHandler:say("Do you want to buy the third blessing for 20000 gold?")
		talkState = 3
	elseif msgcontains(msg, 'the fire of the suns') then
		npcHandler:say("Do you want to buy the fourth blessing for 20000 gold?")
		talkState = 4
	elseif msgcontains(msg, 'the wisdom of solitude') then
		npcHandler:say("Do you want to buy the the wisdom of solitude blessing for 20000 gold?")
		talkState = 5
	elseif talkState > 0 then
		if msgcontains(msg, 'yes') then
			if getPlayerBlessing(cid, talkState) then
				npcHandler:say("A god has already blessed you with this blessing.")
			elseif isPremium(cid) == TRUE then
				if doPlayerRemoveMoney(cid, 20000) == TRUE then
					doPlayerAddBlessing(cid, talkState)
					npcHandler:say("You have been blessed by one of the five gods!")
				else
					npcHandler:say("You don't have enough money.")
				end
			else
				npcHandler:say("You need a premium account to buy blessings.")
			end
			talkState = 0
		elseif msgcontains(msg, 'no') then
			npcHandler:say("Then not.")
			talkState = 0
		end
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I have removed

Code:
elseif isPremium(cid) == TRUE then

and
Code:
else
				npcHandler:say("You need a premium account to buy blessings.")
			end

But no working ;x

Anybody can fixe?
 
Code:
=Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/aol.lua
data/npc/scripts/aol.lua:58: 'end' expected (to close 'function' at line 10) nea
r '<eof>'

;X
 
Try this not tested:
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

function creatureSayCallback(cid, type, msg)
	--- TODO: bless function in modules.lua
	if(npcHandler.focus ~= cid) then
		return FALSE
	end

	if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
		npcHandler:say("I can provide you with five blessings... the 'the spiritual shielding', 'the spark of the phoenix', 'the embrace of tibia', 'the fire of the suns' and the 'the wisdom of solitude', they cost 20000 gold coins each.")
		talkState = 0
	elseif msgcontains(msg, 'the spiritual shielding') then
		npcHandler:say("Do you want to buy the first blessing for 20000 gold?")
		talkState = 1
	elseif msgcontains(msg, 'the spark of the phoenix') then
		npcHandler:say("Do you want to buy the second blessing for 20000 gold?")
		talkState = 2
	elseif msgcontains(msg, 'the embrace of tibia') then
		npcHandler:say("Do you want to buy the third blessing for 20000 gold?")
		talkState = 3
	elseif msgcontains(msg, 'the fire of the suns') then
		npcHandler:say("Do you want to buy the fourth blessing for 20000 gold?")
		talkState = 4
	elseif msgcontains(msg, 'the wisdom of solitude') then
		npcHandler:say("Do you want to buy the the wisdom of solitude blessing for 20000 gold?")
		talkState = 5
	elseif talkState > 0 then
		if msgcontains(msg, 'yes') then
			if getPlayerBlessing(cid, talkState) then
				npcHandler:say("A god has already blessed you with this blessing.")
				if doPlayerRemoveMoney(cid, 20000) == TRUE then
					doPlayerAddBlessing(cid, talkState)
					npcHandler:say("You have been blessed by one of the five gods!")
				else
					npcHandler:say("You don't have enough money.")
				end
			end
			talkState = 0
		elseif msgcontains(msg, 'no') then
			npcHandler:say("Then not.")
			talkState = 0
		end
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Yours,
Clary
 
All you had to do was to replace one line:
PHP:
elseif isPremium(cid) == TRUE then

with:
PHP:
elseif TRUE == TRUE then

And you got the blessing script for both premy and non premium players.
 
That's just stupid Znote, and honstly it'd only be "elseif 1 then" but remove the whole stuff, like:
PHP:
			if getPlayerBlessing(cid, talkState) then
				npcHandler:say("A god has already blessed you with this blessing.")
			elseif isPremium(cid) == TRUE then
				if doPlayerRemoveMoney(cid, 20000) == TRUE then
					doPlayerAddBlessing(cid, talkState)
					npcHandler:say("You have been blessed by one of the five gods!")
				else
					npcHandler:say("You don't have enough money.")
				end
			else
				npcHandler:say("You need a premium account to buy blessings.")
			end

to:
PHP:
			if getPlayerBlessing(cid, talkState) then
				npcHandler:say("A god has already blessed you with this blessing.")
			elseif doPlayerRemoveMoney(cid, 20000) == FALSE then
				npcHandler:say("You don't have enough money.")
			else
				doPlayerAddBlessing(cid, talkState)
				npcHandler:say("You have been blessed by one of the five gods!")
			end
 
Well im using "elseif TRUE == TRUE then " and I cant find any problems with it.
 
Yeah i have teste and no working see.

PHP:
11:37 CM Storm [53]: first bless
11:37 Eremo: Do you want to buy the first blessing for 10000 gold?
11:37 CM Storm [53]: yes
11:37 Eremo: You have been blessed by one of the five gods!
11:37 CM Storm [53]: first bless
11:37 Eremo: Do you want to buy the first blessing for 10000 gold?
11:37 CM Storm [53]: yes
11:37 Eremo: You have been blessed by one of the five gods!
11:38 Eremo: Good bye, CM Storm!

Two time him give some bless ;P
 
Well im using "elseif TRUE == TRUE then " and I cant find any problems with it.

So you'd say this script is nothing wrong with?
PHP:
if TRUE == TRUE then
    if TRUE == TRUE then
        if TRUE == TRUE then
            if TRUE == TRUE then
                if TRUE == TRUE then
                    if TRUE == TRUE then
                        -- code
                    end
                end
            end
        end
    end
end


A check takes cpu, and those checks are not neccessary, just remove them...
 
Ey dude, I only know the basics of the basics of the tiny basics :(

Had no idea thoose checks required CPU usage :p
 
Ofcourse it requires CPU usage... Everything does ^.- But having them there for no reason is stupid, it doesn't mean that you should not make big scripts or so, but just not unnecessary stuff :p

That's why I want to avoid loops, if you for example check my function isInArea, where many people would have used a loop I use simple if-statements, which is the real way to check stuff like that.
 
Back
Top