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

All Blessings NPC

Reaperr

Banned User
Joined
Mar 8, 2010
Messages
21
Reaction score
0
Hello folks :d i want to put these both scripts in to one.
First script is from inqusition quest
Second one is a npc thats selling all the blessings.
But i got no idea how to ;/ i have tried everything, hope you gonna help me ;>

1st.
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
	local storage = getPlayerStorageValue(cid, 1889)
	local storagee = getPlayerStorageValue(cid, 1996)
	
	if(msgcontains(msg, 'join') or msgcontains(msg, 'inquisition'))then
		if storage == -1 then
			npcHandler:say("Do you want to join the inquisition?", cid)
			talkState[talkUser] = 1
		else
			npcHandler:say("You are already a member of the inquisition.", cid)
			talkState[talkUser] = 0
		end
		
	elseif msgcontains(msg, 'mission') then
		if storage == 1 then
			npcHandler:say("Let's see if you are worthy. Take an inquisitor's field guide from the box in the back room. ...", cid)
			npcHandler:say("Follow the instructions in the guide to talk to the Thaian guards that protect the walls and gates of the city and test their loyalty. Then report to me about your mission.", cid)
			setPlayerStorageValue(cid, 1889, 2)
			talkState[talkUser] = 0
		elseif storage == 18 then
			npcHandler:say("Your current mission is to investigate the reliability of certain guards. Are you done with that mission?", cid)
			talkState[talkUser] = 3		
			elseif storage == 19 then
			if getPlayerStorageValue(cid, 1996) == -1 then
			npcHandler:say("Now you need to complete The Shadow Nexus and come back to me.", cid)
			npcHandler:say("Use this vial of holy water to destroy the Shadow Nexus.", cid)
			local item2 = doPlayerAddItem(cid, 7494, 1)
			setPlayerStorageValue(cid, 1996, 1)
			talkState[talkUser] = 0
		elseif getPlayerStorageValue(cid, 1883) == 1 then
			npcHandler:say("Your current mission is to destroy the Shadow Nexus. Are you done with that mission?", cid)
			talkState[talkUser] = 4
	end
		end

	elseif msgcontains(msg, 'yes') then		
		if talkState[talkUser] == 1 then
				if storage == -1 then
					npcHandler:say("So be it. Now you are a member of the inquisition. You might ask me for a mission to raise in my esteem.", cid)
					setPlayerStorageValue(cid, 1889, 1)
					--talkState[talkUser] = 0
				end
		elseif talkState[talkUser] == 2 then
				if storage == 1 then
					npcHandler:say("Indeed, this is exactly what my other sources told me. Of course I knew the outcome of this investigation in advance. This was just a test...", cid)
					npcHandler:say("Well, now that you've proven yourself as useful, you can ask me for another mission.", cid)
					setPlayerStorageValue(cid, 1889, 2)
					talkState[talkUser] = 0
				end
		elseif talkState[talkUser] == 3 then
				if storage == 18 then
					npcHandler:say("Indeed, this is exactly what my other sources told me. Of course I knew the outcome of this investigation in advance. This was just a test...", cid)
					npcHandler:say("Well, now that you've proven yourself as useful, you can ask me for another mission.", cid)
					setPlayerStorageValue(cid, 1889, 19)
					talkState[talkUser] = 0
				end
		elseif talkState[talkUser] == 4 then
				if getPlayerStorageValue(cid, 1883) == 1 then

					npcHandler:say("Fine, fine. You have proven that you can work efficiently. Now you can enter the reward room and choose your reward and Enjoy your new fresh outfit!", cid)
					setPlayerStorageValue(cid, 14916, 1)
					talkState[talkUser] = 0
				end
				
			
		
			
		end
	end
	return TRUE
end





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


second one:

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

    bless2 = getPlayerBlessing(cid,2)
    tbless = 'Sorry, but you already have this blessing.'
    tbless2 = 'Sorry, but you already have one blessing, and u cant buy all others.'
    obless = 'I will give to you all blessings, but you will have to make a sacrifice. Are you prepared to pay 200.000 gold for the blessings?'
    mbless = 'Oh. You do not have enough money.' 
    gbless = 'Now the Gods blessed you.'
    price = 60000
    player_gold = getPlayerItemCount(cid,2148)
    player_plat = getPlayerItemCount(cid,2152)*100
    player_crys = getPlayerItemCount(cid,2160)*10000
    player_money = player_gold + player_plat + player_crys

    if msgcontains(msg, 'all blessings') then
        if isPremium(cid) then
            if player_money >= price then
                selfSay(obless, cid)
                talkState[talkUser] = 2
            else
                selfSay(mbless, cid)
                talkState[talkUser] = 0
            end
        else
            selfSay(pbless, cid)
            talkState[talkUser] = 0
        end

    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
        talkState[talkUser] = 0
         if bless2 then
            selfSay(tbless, cid)
        else
            if doPlayerRemoveMoney(cid, price) == TRUE then
                doPlayerAddBlessing(cid, 1)
                doPlayerAddBlessing(cid, 2)
                doPlayerAddBlessing(cid, 3)
                doPlayerAddBlessing(cid, 4)
                doPlayerAddBlessing(cid, 5)
                selfSay(gbless, cid)
            else
                selfSay(mbless, cid)
            end
        end

------------------------------------------------ confirm no ------------------------------------------------
    elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
        selfSay('Ok than.', cid)
        talkState[talkUser] = 0
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
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({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 2000 (plus level depending amount) gold?'})
	node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 1, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	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 2000 (plus level depending amount) gold?'})
	node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 2, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	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 2000 (plus level depending amount) gold?'})
	node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 3, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	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 2000 (plus level depending amount) gold?'})
	node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 4, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	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 2000 (plus level depending amount) gold?'})
	node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, number = 5, premium = true, baseCost = 2000, levelCost = 200, startLevel = 30, endLevel = 120})
	node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

npcHandler:addModule(FocusModule:new())


I suppose you to use the script from TFS! Just create a npc and use the script for it.
 
-.- but its not needed ....
I need an npc so if a player got storage value 16915 then npc sells all the blessings at once ;(
 
Am I blind? Is pbless defined somewhere?

this is my attempt
LUA:
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

    bless2 = getPlayerBlessing(cid,2)
    tbless = 'Sorry, but you already have this blessing.'
    tbless2 = 'Sorry, but you already have one blessing, and u cant buy all others.'
    obless = 'I will give to you all blessings, but you will have to make a sacrifice. Are you prepared to pay 200.000 gold for the blessings?'
    mbless = 'Oh. You do not have enough money.' 
    gbless = 'Now the Gods blessed you.'
    pbless = 'You need premium to buy blessings.'
    sbless = 'You a storage value to buy blessings.'
    price = 60000
    player_gold = getPlayerItemCount(cid,2148)
    player_plat = getPlayerItemCount(cid,2152)*100
    player_crys = getPlayerItemCount(cid,2160)*10000
    player_money = player_gold + player_plat + player_crys

if msgcontains(msg, 'all blessings') then
        if isPremium(cid) then
	if getPlayerStorageValue(cid, 16915) > 0 then
            if player_money >= price then
                selfSay(obless, cid)
                talkState[talkUser] = 2
            else
                selfSay(mbless, cid)
                talkState[talkUser] = 0
            end
	else
		selfSay(sbless, cid)
		talkState[talkUser] = 0
	end
        else
            selfSay(pbless, cid)
            talkState[talkUser] = 0
        end

    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
        talkState[talkUser] = 0
         if bless2 then
            selfSay(tbless, cid)
        else
            if doPlayerRemoveMoney(cid, price) == TRUE then
                doPlayerAddBlessing(cid, 1)
                doPlayerAddBlessing(cid, 2)
                doPlayerAddBlessing(cid, 3)
                doPlayerAddBlessing(cid, 4)
                doPlayerAddBlessing(cid, 5)
                selfSay(gbless, cid)
            else
                selfSay(mbless, cid)
            end
        end

------------------------------------------------ confirm no ------------------------------------------------
    elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
        selfSay('Ok than.', cid)
        talkState[talkUser] = 0
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

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

Things to notice, the answers need their modification, and the "storage > 0" to whatever storage value they need to be able to buy blessings..
 
Last edited:
Back
Top