• 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 Grizzly Adams

Dankoo

Active Member
Joined
Sep 4, 2010
Messages
1,007
Reaction score
27
I have an Grizzly Adams NPC, it has promotions, tasks (oh) etc

But I want the player to be able to trade with him only if he have rank = X u know

Can anyone help me out with this?

Here is the script:

npc/grizzly_adams.xml
LUA:
<?xml version="1.0"?>
<npc name="Grizzly Adams" script="Grizzly_Adams.lua" access="3" walkinterval="2000" lookdir="2">
        <health now="200" max="200"/>
<look type="144" head="97" body="97" legs="94" feet="97" addons="3"/>
<parameters>
<parameter key="message_greet" value="Welcome back |PLAYERNAME|. What brings you here this time?"/>
<parameter key="message_farewall" value="Good bye |PLAYERNAME|!"/>
<parameter key="message_walkaway" value="Bye then..."/>
</parameters>
</npc>

npc/scripts/grizzly_adams.lua
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 say(param)
            npcHandler:say(param.text,param.cid)
         end
    function delayedSay(text, delay, cid)
    if(not npcHandler:isFocused(cid)) then
                return FALSE
     else
         local param = {cid = cid, text = text}
            local delay = delay or 0
            addEvent(say, delay, param)
        end
    end
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
    return false
end
local main_storage = 10001
local tiquandas_revenge = 10004
local demons = 10005
local demodras = 10006
local getStorage = getPlayerStorageValue(cid, main_storage)
local points = getPlayerStorageValue(cid, 10002)
local promote = getPlayerStorageValue(cid, 10003)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local good_hunting = {"Happy hunting, old chap! Come back to me when you are through with your {task}.", "Good show, old chap! Speak to me again when you are done hunting."}	
local good_job = {"That took some time, huh? Good hunting though. If you're up for another hunting mission just ask me for a {task}.", "If you're up for another hunting mission just ask me for a {task}."}
local tasks = {
			[1] = {name = "trolls", storage = 9998, expe = "yes", how_many = 100000, finish_storage_value = 4, begin_storage_value = 3, talkstate = 4},
			[2] = {name = "tarantulas", storage = 9997, expe = "yes", how_many = 1500, finish_storage_value = 8, begin_storage_value = 7, boss = "yes", after_kill_boss = 10, before_kill_boss = 9, talkstate = 5},
			[3] = {name = "carniphilas", storage = 9999, expe = "yes", how_many = 1500, finish_storage_value = 2, begin_storage_value = 1, talkstate = 6},
			[4] = {name = "stone golems", storage = 9996, expe = "yes", how_many = 2000, finish_storage_value = 12, begin_storage_value = 11, talkstate = 7},
			[5] = {name = "mammoths", storage = 9995, expe = "yes", how_many = 4000, finish_storage_value = 14, begin_storage_value = 13, boss = "yes", after_kill_boss = 16, before_kill_boss = 15, talkstate = 8},
			[6] = {name = "ice golems", storage = 9994, expe = "yes", how_many = 15000, finish_storage_value = 17, begin_storage_value = 16, boss = "yes", after_kill_boss = 19, before_kill_boss = 18, talkstate = 9},
			[7] = {name = "quara", talkstate = 100},
			[8] = {name = "elementals", talkstate = 103},
			[9] = {name = "mutated rats", storage = 9987, expe = "yes", how_many = 10000, finish_storage_value = 35, begin_storage_value = 34, boss = "yes", after_kill_boss = 37, before_kill_boss = 36, talkstate = 10},
			[10] = {name = "giant spiders", storage = 9986, expe = "yes", how_many = 5000, finish_storage_value = 39, begin_storage_value = 38, boss = "yes", after_kill_boss = 41, before_kill_boss = 40, talkstate = 11},
			[11] = {name = "hydras", storage = 9985, finish_storage_value = 43, begin_storage_value = 42, boss = "yes", after_kill_boss = 45, before_kill_boss = 44, talkstate = 12},
			[12] = {name = "sea serpents", storage = 9984, finish_storage_value = 47, begin_storage_value = 46, boss = "yes", after_kill_boss = 49, before_kill_boss = 48, talkstate = 13},
			[13] = {name = "behemoths", storage = 9983, finish_storage_value = 51, begin_storage_value = 50, boss = "yes", after_kill_boss = 53, before_kill_boss = 52, talkstate = 14},
			[14] = {name = "serpent spawns", storage = 9982, finish_storage_value = 55, begin_storage_value = 54, boss = "yes", after_kill_boss = 57, before_kill_boss = 56, talkstate = 15}
			}
local promotion = {
				[1] = {talktype = 50, how_many_exp = 5000, finish_storage_values = 0},
				[2] = {talktype = 51, how_many_exp = 8000, finish_storage_values = 1},
				[3] = {talktype = 52, how_many_exp = 10000, finish_storage_values = 2},
				[4] = {talktype = 53, how_many_exp = 15000, item = "yes", what = 10518, count = 1, finish_storage_values = 3},
				[5] = {talktype = 54, how_many_exp = 30000, finish_storage_values = 4}
				}
local rank = {
			[1] = {need_points = 5, storage_value = -1, talkstate = 50},
			[2] = {need_points = 10, storage_value = 0, talkstate = 51},
			[3] = {need_points = 20, storage_value = 1, talkstate = 52},
			[4] = {need_points = 30, storage_value = 2, talkstate = 53},
			[5] = {need_points = 50, storage_value = 3, talkstate = 54}
			}
local others_tasks = {
			[1] = {name = "quaras", storage = 9992, expe = "yes", how_many = 12000, finish_storage_value = 23, begin_storage_value = 22, boss = "yes", after_kill_boss = 25, before_kill_boss = 24, talkstate = 101},
			[2] = {name = "quara scouts", storage = 9993, expe = "yes", how_many = 10000, finish_storage_value = 21, begin_storage_value = 20, talkstate = 102},
			[3] = {name = "fire", storage = 9991, expe = "yes", how_many = 7000, finish_storage_value = 27, begin_storage_value = 26, talkstate = 104},
			[4] = {name = "water", storage = 9990, expe = "yes", how_many = 7000, finish_storage_value = 29, begin_storage_value = 28, talkstate = 105},
			[5] = {name = "earth", storage = 9989, expe = "yes", how_many = 10000, finish_storage_value = 31, begin_storage_value = 30, talkstate = 106},
			[6] = {name = "energy", storage = 9988, expe = "yes", how_many = 10000, finish_storage_value = 33, begin_storage_value = 32, talkstate = 107}
			}
if msgcontains(msg, 'task') and getStorage == 0 or getStorage == -1 then 
	if getStorage == -1 then
		setPlayerStorageValue(cid, main_storage, 0)
	end
	if (getPlayerLevel(cid) > 5 and getPlayerLevel(cid) < 50) then
		selfSay("All right, what would you like to hunt? {Trolls}, {tarantulas}, {carniphilas}, {stone golems} or {mammoths}?", cid)
		talkState[talkUser] = 1
	elseif (getPlayerLevel(cid) > 49 and getPlayerLevel(cid) < 90) then
		selfSay("All right, what would you like to hunt? {Ice golems}, {quara}, {elementals}, {mutated rats} or {giant spiders}?", cid)
		talkState[talkUser] = 2
	elseif (getPlayerLevel(cid) > 89) then
		selfSay("All right, what would you like to hunt? {Hydras}, {sea serpents}, {behemoths} or {serpent spawns}?", cid)
		talkState[talkUser] = 3
	end
end
if msgcontains(msg, 'cancel') and getStorage > 0 then
	selfSay("Do you want cancel actual mission?", cid)
	talkState[talkUser] = 70
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 70 then
	if getStorage > 0 then
		selfSay("Speak to me again when you are done hunting.", cid)
		setPlayerStorageValue(cid, main_storage, 0)
	else
		selfSay("You do not started any {task}.", cid)
	end
end
for i = 1, #others_tasks do
	if msgcontains(msg, others_tasks[i].name) then
		if talkState[talkUser] == 100 then
			if others_tasks[i].name == "quaras" then
				selfSay("Do you want kill {300 quaras?}", cid)
			elseif others_tasks[i].name == "quara scouts" then
				selfSay("Do you want kill {300 quara scouts?}", cid)
			end
		elseif talkState[talkUser] == 103 then
			if others_tasks[i].name == "fire" then
				selfSay("Don't get burnt! Your challenge, should you choose to accept it, is to kill {70 fire elementals or massive fire elementals}. Are you ready?", cid)
			elseif others_tasks[i].name == "water" then
				selfSay("Alright, go hunt {70 water elementals or massive water elementals}. Don't forget your umbrella! Alright?", cid)
			elseif others_tasks[i].name == "earth" then
				selfSay("Good choice! I need you to slay {70 earth elementals or massive earth elementals}. There are some in the so called Taboo-area in the eastern jungle of Tiquanda and I heard about a cave in Edron where you'll find them. Are you game?", cid)
			elseif others_tasks[i].name == "energy" then
				selfSay("A brave hunter! Kill {70 energy elementals or massive energy elementals}. You'll find them in the mountains between Darama and Tiquanda. Are you sure you want to do this?", cid)
			end
		end
		talkState[talkUser] = others_tasks[i].talkstate
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == others_tasks[i].talkstate then
		setPlayerStorageValue(cid, main_storage, others_tasks[i].begin_storage_value)
		selfSay(good_hunting[math.random(1, #good_hunting)], cid)
		if getPlayerStorageValue(cid, others_tasks[i].storage) < 0 then
			setPlayerStorageValue(cid, others_tasks[i].storage, 1)
		end
	elseif msgcontains(msg, 'task') then
		if getStorage == others_tasks[i].finish_storage_value then
			if others_tasks[i].boss == "yes" then
				setPlayerStorageValue(cid, main_storage, others_tasks[i].before_kill_boss)
			else 
				setPlayerStorageValue(cid, main_storage, 0)
				setPlayerStorageValue(cid, others_tasks[i].storage, -1)
				selfSay(good_job[math.random(1, #good_job)], cid)
					if others_tasks[i].expe == "yes" then
						doPlayerAddExp(cid, others_tasks[i].how_many)
						doSendAnimatedText(getPlayerPosition(cid), others_tasks[i].how_many, TEXTCOLOR_WHITE)
					end
			end
		elseif getStorage == others_tasks[i].after_kill_boss then
			setPlayerStorageValue(cid, main_storage, 0)
			setPlayerStorageValue(cid, others_tasks[i].storage, -1)
			selfSay(good_job[math.random(1, #good_job)], cid)
		elseif isInArray(others_tasks[i].begin_storage_value, getStorage) then
			selfSay("You kill ".. getPlayerStorageValue(cid, others_tasks[i].storage)-1 .." "..others_tasks[i].name..".", cid)
		elseif isInArray(others_tasks[i].before_kill_boss, getStorage) then
			selfSay("You do not kill boss yet.", cid)
		end
	end
end
for i = 1, #rank do
	if msgcontains(msg, 'rank') then
		if points >= rank[i].need_points and promote == rank[i].storage_value then
				if rank[i].need_points == 5 then
					selfSay("Welcome back "..getCreatureName(cid)..". You have completed 5 tasks for our society. Ask me for a {promotion} to advance your rank!", cid)
				elseif rank[i].need_points == 10 then
					selfSay("Welcome back "..getCreatureName(cid)..". You have completed 10 tasks for our society. Ask me for a {promotion} to advance your rank!", cid)
				elseif rank[i].need_points == 20 then
					selfSay("Salutations "..getCreatureName(cid)..". You have completed 20 tasks for our society. Ask me for a {promotion} to advance your rank!", cid)
				elseif rank[i].need_points == 30 then
					selfSay("Welcome back "..getCreatureName(cid)..". You have completed 30 tasks for our society. Ask me for a {promotion} to advance your rank!", cid)
				elseif rank[i].need_points == 50 then
					selfSay("By the gods....50 hunting tasks....this is austoding! Ask me for a {promotion} to advance your rank! And while you are here, I also have another special task for you.", cid)
				end
			talkState[talkUser] = rank[i].talkstate
		end
	end
end
for i = 1, #promotion do
	if msgcontains(msg, 'promotion') then
		if talkState[talkUser] == promotion[i].talktype then
			if getPlayerStorageValue(cid, 10003) == promotion[i].finish_storage_values-1 then
				doPlayerAddExp(cid, promotion[i].how_many_exp)
				doSendAnimatedText(getPlayerPosition(cid), promotion[i].how_many_exp, TEXTCOLOR_WHITE)
				setPlayerStorageValue(cid, 10003, promotion[i].finish_storage_values)
					if talkState[talkUser] == 50 then
						selfSay("You have completed 5 tasks! Let me promote you to the first rank: {Huntsman}. Congratulations! ...", cid)
						delayedSay("If you find any trophies that you don't need, feel free to ask me for a {trade}.", 10000, cid)
					elseif talkState[talkUser] == 51 then
						delayedSay("You have completed 10 hunting tasks. It's time for a promotion. You advance to the rank of {Ranger}. Congratulations! ...", 0, cid)
						delayedSay("Oh, I made a deal with Lorek. He ships Rangers from our society - and higher ranks of course - to Banuta, Chor or near the mountain pass to Darama. Just ask him for a passage.", 10000, cid)
					elseif talkState[talkUser] == 52 then
						selfSay("Good show! You have completed 20 hunting tasks for the 'Paw and Fur - Hunting Elite. You have earned the right to join the ranks of those known as {Big game} {hunter}. Congratulations! ...", cid)
						delayedSay("From now on I'll buy more trophies from you!", 10000, cid)
					elseif talkState[talkUser] == 53 then
						selfSay("Spiffing! You have done 30 hunting tasks! From now on you can call yourself a {Trophy hunter}. As a reward I have this special backpack for you and in addition you can sell some more rare trophies to me.", cid)
					elseif talkState[talkUser] == 54 then
						selfSay("Congratulations! You have made the highest rank: {Elite hunter}. If haven't yet done so ask me for the {special task}.", cid)
							if promotion[i].item == "yes" then
								doPlayerAddItem(cid, promotion[i].what, promotion[i].count)
							end
					end
			end
		end
	end
end
for i = 1, #tasks do
	if msgcontains(msg, tasks[i].name) then
		if talkState[talkUser] == 1 then
				if tasks[i].name == "carniphilas" then
					selfSay("Damn walking weed-thingies! You'll find them deeper in the jungle. Weed out {150 "..tasks[i].name.."} for our society. Alright?", cid)
				elseif tasks[i].name == "trolls" then
					selfSay("Argh! Estes malditos trolls infestaram os bueiros da cidade. Mate {100 "..tasks[i].name.."} e lhe darei uma bela recompensa. Interessado?", cid)
				elseif tasks[i].name == "tarantulas" then
					selfSay("Do you want kill {300 tarantulas?}", cid)
				elseif tasks[i].name == "stone golems" then
					selfSay("They can be found all over Tibia. You'll find them in mountain caves or rocky dungeons. Hunt {200} of them and come back to me. Understood?", cid)
				elseif tasks[i].name == "mammoths" then
					selfSay("This particular species are found in Svargrond. Impressive beasts, but you wouldn't want one in your back garden. Hunt {300} of them. Alright?", cid)
				end
		elseif talkState[talkUser] == 2 then
				if tasks[i].name == "ice golems" then
					selfSay("The ice golems on the glacier of Hrodmir are becoming a threat to the civilians in Svargrond. Travel to the Ice Islands and hunt {300 "..tasks[i].name.."}. Do you accept this task?", cid)
				elseif tasks[i].name == "quara" then
					selfSay("What do you want, {quaras} or {quara scouts?}", cid)
				elseif tasks[i].name == "elementals" then
					selfSay("What do you want, {fire}, {water}, {earth} or {energy?}", cid)
				elseif tasks[i].name == "mutated rats" then
					selfSay("Recently, I heard of a disturbing development in Yalahar - a plague of monstrous Mutated rats! If they were to spread to the rest of Tibia.. <shudders> My task for you is to contain their numbers in Yalahar. Hunt {200} of them. What do you say?", cid)
				elseif tasks[i].name == "giant spiders" then
					selfSay("Never liked spiders. Entirely too many legs. And I always find them in my bath! Those nasty creepy crawlies are a threat to the hygiene of every living being in Tibia. Hunt {500} of them. Okay?", cid)
				end
		elseif talkState[talkUser] == 3 then
				if tasks[i].name == "hydras" then
					selfSay("Do you want kill {2000 "..tasks[i].name.."?}", cid)
				elseif tasks[i].name == "sea serpents" then
					selfSay("Do you want kill {2000 "..tasks[i].name.."?}", cid)
				elseif tasks[i].name == "behemoths" then
					selfSay("Do you want kill {2000 "..tasks[i].name.."?}", cid)
				elseif tasks[i].name == "serpent spawns" then
					selfSay("Do you want kill {1500 "..tasks[i].name.."?}", cid)
				end
		end	
	talkState[talkUser] = tasks[i].talkstate
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == tasks[i].talkstate then
		setPlayerStorageValue(cid, main_storage, tasks[i].begin_storage_value)
		selfSay(good_hunting[math.random(1, #good_hunting)], cid)
		if getPlayerStorageValue(cid, tasks[i].storage) < 0 then
			setPlayerStorageValue(cid, tasks[i].storage, 0)
		end
	elseif msgcontains(msg, 'task') then
		if getStorage == tasks[i].finish_storage_value then
			if tasks[i].boss == "yes" then
				selfSay("Good job, go kill boss.", cid)
				setPlayerStorageValue(cid, main_storage, tasks[i].before_kill_boss)
			else 
				setPlayerStorageValue(cid, main_storage, 0)
				setPlayerStorageValue(cid, tasks[i].storage, -1)
				selfSay(good_job[math.random(1, #good_job)], cid)
				if tasks[i].expe == "yes" then
					doPlayerAddExp(cid, tasks[i].how_many)
					doSendAnimatedText(getPlayerPosition(cid), tasks[i].how_many, TEXTCOLOR_WHITE)
				end
			end
		elseif getStorage == tasks[i].after_kill_boss then
			setPlayerStorageValue(cid, main_storage, 0)
			setPlayerStorageValue(cid, tasks[i].storage, -1)
			selfSay(good_job[math.random(1, #good_job)], cid)
		elseif isInArray(tasks[i].begin_storage_value, getStorage) then
			selfSay("You do not kill enough monsters.", cid)
		elseif isInArray(tasks[i].before_kill_boss, getStorage) then
			selfSay("You do not kill boss yet.", cid)
		end
	end
end
if msgcontains(msg, 'points') then
	if points < 0 then
		points = 0
	end
	selfSay("You have already " .. points .. " points now.", cid)
elseif msgcontains(msg, 'no') and isInArray({4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 101, 102, 103, 104, 105, 106, 107}, talkState[talkUser]) then 
	selfSay("Ok then.", cid)
elseif msgcontains(msg, 'special task') then
	if getPlayerStorageValue(cid, 10003) == 5 then
		if getPlayerLevel(cid) >= 90 then
			if getPlayerStorageValue(cid, tiquandas_revenge) == -1 then
				selfSay("Have you heared about Tiquandas Revenge? It is said that the jungle itself is alive and takes revenge for all the bad things people have done to it. ...", cid)
				delayedSay("I myself believe that there is some truth in this clap trap. Something 'real' which therefore must have a hideout somewhere. Go find it and take revenge yourself! Ask me about the special task when you're done.", 10000, cid)
				setPlayerStorageValue(cid, main_storage, 104)
				setPlayerStorageValue(cid, tiquandas_revenge, 1)
			elseif getPlayerStorageValue(cid, demodras) == -1 then
				selfSay("Kill Demodras.", cid)
				setPlayerStorageValue(cid, main_storage, 102)
				setPlayerStorageValue(cid, demodras, 1)
			end
		elseif getPlayerLevel(cid) >= 100 and getPlayerStorageValue(cid, demons) == -1 then
			selfSay("Kill 6666 Demons.", cid)
			setPlayerStorageValue(cid, main_storage, 100)
			setPlayerStorageValue(cid, demons, 1)
		end
	end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

it must be something like

if msg contains "trade", then, verify storageid (promotion), if >1 then
opentradechannel
else sendplayer msg "u're noob in our society lol"
 
well when a player is promoted a storage id is given to him by the npc
so if think what u want is that the npc wil only talk to him when he has this storage id then try this


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 say(param)
            npcHandler:say(param.text,param.cid)
         end
    function delayedSay(text, delay, cid)
    if(not npcHandler:isFocused(cid)) then
                return FALSE
     else
         local param = {cid = cid, text = text}
            local delay = delay or 0
            addEvent(say, delay, param)
        end
    end
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
    return false
end
local main_storage = 10001
local tiquandas_revenge = 10004
local demons = 10005
local demodras = 10006
local getStorage = getPlayerStorageValue(cid, main_storage)
local points = getPlayerStorageValue(cid, 10002)
local promote = getPlayerStorageValue(cid, 10003)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local good_hunting = {"Happy hunting, old chap! Come back to me when you are through with your {task}.", "Good show, old chap! Speak to me again when you are done hunting."}	
local good_job = {"That took some time, huh? Good hunting though. If you're up for another hunting mission just ask me for a {task}.", "If you're up for another hunting mission just ask me for a {task}."}
local tasks = {
			[1] = {name = "trolls", storage = 9998, expe = "yes", how_many = 100000, finish_storage_value = 4, begin_storage_value = 3, talkstate = 4},
			[2] = {name = "tarantulas", storage = 9997, expe = "yes", how_many = 1500, finish_storage_value = 8, begin_storage_value = 7, boss = "yes", after_kill_boss = 10, before_kill_boss = 9, talkstate = 5},
			[3] = {name = "carniphilas", storage = 9999, expe = "yes", how_many = 1500, finish_storage_value = 2, begin_storage_value = 1, talkstate = 6},
			[4] = {name = "stone golems", storage = 9996, expe = "yes", how_many = 2000, finish_storage_value = 12, begin_storage_value = 11, talkstate = 7},
			[5] = {name = "mammoths", storage = 9995, expe = "yes", how_many = 4000, finish_storage_value = 14, begin_storage_value = 13, boss = "yes", after_kill_boss = 16, before_kill_boss = 15, talkstate = 8},
			[6] = {name = "ice golems", storage = 9994, expe = "yes", how_many = 15000, finish_storage_value = 17, begin_storage_value = 16, boss = "yes", after_kill_boss = 19, before_kill_boss = 18, talkstate = 9},
			[7] = {name = "quara", talkstate = 100},
			[8] = {name = "elementals", talkstate = 103},
			[9] = {name = "mutated rats", storage = 9987, expe = "yes", how_many = 10000, finish_storage_value = 35, begin_storage_value = 34, boss = "yes", after_kill_boss = 37, before_kill_boss = 36, talkstate = 10},
			[10] = {name = "giant spiders", storage = 9986, expe = "yes", how_many = 5000, finish_storage_value = 39, begin_storage_value = 38, boss = "yes", after_kill_boss = 41, before_kill_boss = 40, talkstate = 11},
			[11] = {name = "hydras", storage = 9985, finish_storage_value = 43, begin_storage_value = 42, boss = "yes", after_kill_boss = 45, before_kill_boss = 44, talkstate = 12},
			[12] = {name = "sea serpents", storage = 9984, finish_storage_value = 47, begin_storage_value = 46, boss = "yes", after_kill_boss = 49, before_kill_boss = 48, talkstate = 13},
			[13] = {name = "behemoths", storage = 9983, finish_storage_value = 51, begin_storage_value = 50, boss = "yes", after_kill_boss = 53, before_kill_boss = 52, talkstate = 14},
			[14] = {name = "serpent spawns", storage = 9982, finish_storage_value = 55, begin_storage_value = 54, boss = "yes", after_kill_boss = 57, before_kill_boss = 56, talkstate = 15}
			}
local promotion = {
				[1] = {talktype = 50, how_many_exp = 5000, finish_storage_values = 0},
				[2] = {talktype = 51, how_many_exp = 8000, finish_storage_values = 1},
				[3] = {talktype = 52, how_many_exp = 10000, finish_storage_values = 2},
				[4] = {talktype = 53, how_many_exp = 15000, item = "yes", what = 10518, count = 1, finish_storage_values = 3},
				[5] = {talktype = 54, how_many_exp = 30000, finish_storage_values = 4}
				}
local rank = {
			[1] = {need_points = 5, storage_value = -1, talkstate = 50},
			[2] = {need_points = 10, storage_value = 0, talkstate = 51},
			[3] = {need_points = 20, storage_value = 1, talkstate = 52},
			[4] = {need_points = 30, storage_value = 2, talkstate = 53},
			[5] = {need_points = 50, storage_value = 3, talkstate = 54}
			}
local others_tasks = {
			[1] = {name = "quaras", storage = 9992, expe = "yes", how_many = 12000, finish_storage_value = 23, begin_storage_value = 22, boss = "yes", after_kill_boss = 25, before_kill_boss = 24, talkstate = 101},
			[2] = {name = "quara scouts", storage = 9993, expe = "yes", how_many = 10000, finish_storage_value = 21, begin_storage_value = 20, talkstate = 102},
			[3] = {name = "fire", storage = 9991, expe = "yes", how_many = 7000, finish_storage_value = 27, begin_storage_value = 26, talkstate = 104},
			[4] = {name = "water", storage = 9990, expe = "yes", how_many = 7000, finish_storage_value = 29, begin_storage_value = 28, talkstate = 105},
			[5] = {name = "earth", storage = 9989, expe = "yes", how_many = 10000, finish_storage_value = 31, begin_storage_value = 30, talkstate = 106},
			[6] = {name = "energy", storage = 9988, expe = "yes", how_many = 10000, finish_storage_value = 33, begin_storage_value = 32, talkstate = 107}
			}
if (getPlayerStorageValue(cid, xxxx) == 1) then			
if msgcontains(msg, 'task') and getStorage == 0 or getStorage == -1 then 
	if getStorage == -1 then
		setPlayerStorageValue(cid, main_storage, 0)
		elseif getPlayerStorageValue(cid, xxxx) == -1)
		selfSay("you are a noob in our society lol", cid)
		end
	end	
end	
	if (getPlayerLevel(cid) > 5 and getPlayerLevel(cid) < 50) then
		selfSay("All right, what would you like to hunt? {Trolls}, {tarantulas}, {carniphilas}, {stone golems} or {mammoths}?", cid)
		talkState[talkUser] = 1
	elseif (getPlayerLevel(cid) > 49 and getPlayerLevel(cid) < 90) then
		selfSay("All right, what would you like to hunt? {Ice golems}, {quara}, {elementals}, {mutated rats} or {giant spiders}?", cid)
		talkState[talkUser] = 2
	elseif (getPlayerLevel(cid) > 89) then
		selfSay("All right, what would you like to hunt? {Hydras}, {sea serpents}, {behemoths} or {serpent spawns}?", cid)
		talkState[talkUser] = 3
		end
	end
if msgcontains(msg, 'cancel') and getStorage > 0 then
	selfSay("Do you want cancel actual mission?", cid)
	talkState[talkUser] = 70
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 70 then
	if getStorage > 0 then
		selfSay("Speak to me again when you are done hunting.", cid)
		setPlayerStorageValue(cid, main_storage, 0)
	else
		selfSay("You do not started any {task}.", cid)
	end
end
for i = 1, #others_tasks do
	if msgcontains(msg, others_tasks[i].name) then
		if talkState[talkUser] == 100 then
			if others_tasks[i].name == "quaras" then
				selfSay("Do you want kill {300 quaras?}", cid)
			elseif others_tasks[i].name == "quara scouts" then
				selfSay("Do you want kill {300 quara scouts?}", cid)
			end
		elseif talkState[talkUser] == 103 then
			if others_tasks[i].name == "fire" then
				selfSay("Don't get burnt! Your challenge, should you choose to accept it, is to kill {70 fire elementals or massive fire elementals}. Are you ready?", cid)
			elseif others_tasks[i].name == "water" then
				selfSay("Alright, go hunt {70 water elementals or massive water elementals}. Don't forget your umbrella! Alright?", cid)
			elseif others_tasks[i].name == "earth" then
				selfSay("Good choice! I need you to slay {70 earth elementals or massive earth elementals}. There are some in the so called Taboo-area in the eastern jungle of Tiquanda and I heard about a cave in Edron where you'll find them. Are you game?", cid)
			elseif others_tasks[i].name == "energy" then
				selfSay("A brave hunter! Kill {70 energy elementals or massive energy elementals}. You'll find them in the mountains between Darama and Tiquanda. Are you sure you want to do this?", cid)
			end
		end
		talkState[talkUser] = others_tasks[i].talkstate
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == others_tasks[i].talkstate then
		setPlayerStorageValue(cid, main_storage, others_tasks[i].begin_storage_value)
		selfSay(good_hunting[math.random(1, #good_hunting)], cid)
		if getPlayerStorageValue(cid, others_tasks[i].storage) < 0 then
			setPlayerStorageValue(cid, others_tasks[i].storage, 1)
		end
	elseif msgcontains(msg, 'task') then
		if getStorage == others_tasks[i].finish_storage_value then
			if others_tasks[i].boss == "yes" then
				setPlayerStorageValue(cid, main_storage, others_tasks[i].before_kill_boss)
			else 
				setPlayerStorageValue(cid, main_storage, 0)
				setPlayerStorageValue(cid, others_tasks[i].storage, -1)
				selfSay(good_job[math.random(1, #good_job)], cid)
					if others_tasks[i].expe == "yes" then
						doPlayerAddExp(cid, others_tasks[i].how_many)
						doSendAnimatedText(getPlayerPosition(cid), others_tasks[i].how_many, TEXTCOLOR_WHITE)
					end
			end
		elseif getStorage == others_tasks[i].after_kill_boss then
			setPlayerStorageValue(cid, main_storage, 0)
			setPlayerStorageValue(cid, others_tasks[i].storage, -1)
			selfSay(good_job[math.random(1, #good_job)], cid)
		elseif isInArray(others_tasks[i].begin_storage_value, getStorage) then
			selfSay("You kill ".. getPlayerStorageValue(cid, others_tasks[i].storage)-1 .." "..others_tasks[i].name..".", cid)
		elseif isInArray(others_tasks[i].before_kill_boss, getStorage) then
			selfSay("You do not kill boss yet.", cid)
		end
	end
end
for i = 1, #rank do
	if msgcontains(msg, 'rank') then
		if points >= rank[i].need_points and promote == rank[i].storage_value then
				if rank[i].need_points == 5 then
					selfSay("Welcome back "..getCreatureName(cid)..". You have completed 5 tasks for our society. Ask me for a {promotion} to advance your rank!", cid)
				elseif rank[i].need_points == 10 then
					selfSay("Welcome back "..getCreatureName(cid)..". You have completed 10 tasks for our society. Ask me for a {promotion} to advance your rank!", cid)
				elseif rank[i].need_points == 20 then
					selfSay("Salutations "..getCreatureName(cid)..". You have completed 20 tasks for our society. Ask me for a {promotion} to advance your rank!", cid)
				elseif rank[i].need_points == 30 then
					selfSay("Welcome back "..getCreatureName(cid)..". You have completed 30 tasks for our society. Ask me for a {promotion} to advance your rank!", cid)
				elseif rank[i].need_points == 50 then
					selfSay("By the gods....50 hunting tasks....this is austoding! Ask me for a {promotion} to advance your rank! And while you are here, I also have another special task for you.", cid)
				end
			talkState[talkUser] = rank[i].talkstate
		end
	end
end
for i = 1, #promotion do
	if msgcontains(msg, 'promotion') then
		if talkState[talkUser] == promotion[i].talktype then
			if getPlayerStorageValue(cid, 10003) == promotion[i].finish_storage_values-1 then
				doPlayerAddExp(cid, promotion[i].how_many_exp)
				doSendAnimatedText(getPlayerPosition(cid), promotion[i].how_many_exp, TEXTCOLOR_WHITE)
				setPlayerStorageValue(cid, 10003, promotion[i].finish_storage_values)
					if talkState[talkUser] == 50 then
						selfSay("You have completed 5 tasks! Let me promote you to the first rank: {Huntsman}. Congratulations! ...", cid)
						delayedSay("If you find any trophies that you don't need, feel free to ask me for a {trade}.", 10000, cid)
					elseif talkState[talkUser] == 51 then
						delayedSay("You have completed 10 hunting tasks. It's time for a promotion. You advance to the rank of {Ranger}. Congratulations! ...", 0, cid)
						delayedSay("Oh, I made a deal with Lorek. He ships Rangers from our society - and higher ranks of course - to Banuta, Chor or near the mountain pass to Darama. Just ask him for a passage.", 10000, cid)
					elseif talkState[talkUser] == 52 then
						selfSay("Good show! You have completed 20 hunting tasks for the 'Paw and Fur - Hunting Elite. You have earned the right to join the ranks of those known as {Big game} {hunter}. Congratulations! ...", cid)
						delayedSay("From now on I'll buy more trophies from you!", 10000, cid)
					elseif talkState[talkUser] == 53 then
						selfSay("Spiffing! You have done 30 hunting tasks! From now on you can call yourself a {Trophy hunter}. As a reward I have this special backpack for you and in addition you can sell some more rare trophies to me.", cid)
					elseif talkState[talkUser] == 54 then
						selfSay("Congratulations! You have made the highest rank: {Elite hunter}. If haven't yet done so ask me for the {special task}.", cid)
							if promotion[i].item == "yes" then
								doPlayerAddItem(cid, promotion[i].what, promotion[i].count)
							end
					end
			end
		end
	end
end
for i = 1, #tasks do
	if msgcontains(msg, tasks[i].name) then
		if talkState[talkUser] == 1 then
				if tasks[i].name == "carniphilas" then
					selfSay("Damn walking weed-thingies! You'll find them deeper in the jungle. Weed out {150 "..tasks[i].name.."} for our society. Alright?", cid)
				elseif tasks[i].name == "trolls" then
					selfSay("Argh! Estes malditos trolls infestaram os bueiros da cidade. Mate {100 "..tasks[i].name.."} e lhe darei uma bela recompensa. Interessado?", cid)
				elseif tasks[i].name == "tarantulas" then
					selfSay("Do you want kill {300 tarantulas?}", cid)
				elseif tasks[i].name == "stone golems" then
					selfSay("They can be found all over Tibia. You'll find them in mountain caves or rocky dungeons. Hunt {200} of them and come back to me. Understood?", cid)
				elseif tasks[i].name == "mammoths" then
					selfSay("This particular species are found in Svargrond. Impressive beasts, but you wouldn't want one in your back garden. Hunt {300} of them. Alright?", cid)
				end
		elseif talkState[talkUser] == 2 then
				if tasks[i].name == "ice golems" then
					selfSay("The ice golems on the glacier of Hrodmir are becoming a threat to the civilians in Svargrond. Travel to the Ice Islands and hunt {300 "..tasks[i].name.."}. Do you accept this task?", cid)
				elseif tasks[i].name == "quara" then
					selfSay("What do you want, {quaras} or {quara scouts?}", cid)
				elseif tasks[i].name == "elementals" then
					selfSay("What do you want, {fire}, {water}, {earth} or {energy?}", cid)
				elseif tasks[i].name == "mutated rats" then
					selfSay("Recently, I heard of a disturbing development in Yalahar - a plague of monstrous Mutated rats! If they were to spread to the rest of Tibia.. <shudders> My task for you is to contain their numbers in Yalahar. Hunt {200} of them. What do you say?", cid)
				elseif tasks[i].name == "giant spiders" then
					selfSay("Never liked spiders. Entirely too many legs. And I always find them in my bath! Those nasty creepy crawlies are a threat to the hygiene of every living being in Tibia. Hunt {500} of them. Okay?", cid)
				end
		elseif talkState[talkUser] == 3 then
				if tasks[i].name == "hydras" then
					selfSay("Do you want kill {2000 "..tasks[i].name.."?}", cid)
				elseif tasks[i].name == "sea serpents" then
					selfSay("Do you want kill {2000 "..tasks[i].name.."?}", cid)
				elseif tasks[i].name == "behemoths" then
					selfSay("Do you want kill {2000 "..tasks[i].name.."?}", cid)
				elseif tasks[i].name == "serpent spawns" then
					selfSay("Do you want kill {1500 "..tasks[i].name.."?}", cid)
				end
		end	
	talkState[talkUser] = tasks[i].talkstate
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == tasks[i].talkstate then
		setPlayerStorageValue(cid, main_storage, tasks[i].begin_storage_value)
		selfSay(good_hunting[math.random(1, #good_hunting)], cid)
		if getPlayerStorageValue(cid, tasks[i].storage) < 0 then
			setPlayerStorageValue(cid, tasks[i].storage, 0)
		end
	elseif msgcontains(msg, 'task') then
		if getStorage == tasks[i].finish_storage_value then
			if tasks[i].boss == "yes" then
				selfSay("Good job, go kill boss.", cid)
				setPlayerStorageValue(cid, main_storage, tasks[i].before_kill_boss)
			else 
				setPlayerStorageValue(cid, main_storage, 0)
				setPlayerStorageValue(cid, tasks[i].storage, -1)
				selfSay(good_job[math.random(1, #good_job)], cid)
				if tasks[i].expe == "yes" then
					doPlayerAddExp(cid, tasks[i].how_many)
					doSendAnimatedText(getPlayerPosition(cid), tasks[i].how_many, TEXTCOLOR_WHITE)
				end
			end
		elseif getStorage == tasks[i].after_kill_boss then
			setPlayerStorageValue(cid, main_storage, 0)
			setPlayerStorageValue(cid, tasks[i].storage, -1)
			selfSay(good_job[math.random(1, #good_job)], cid)
		elseif isInArray(tasks[i].begin_storage_value, getStorage) then
			selfSay("You do not kill enough monsters.", cid)
		elseif isInArray(tasks[i].before_kill_boss, getStorage) then
			selfSay("You do not kill boss yet.", cid)
		end
	end
end
if msgcontains(msg, 'points') then
	if points < 0 then
		points = 0
	end
	selfSay("You have already " .. points .. " points now.", cid)
elseif msgcontains(msg, 'no') and isInArray({4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 101, 102, 103, 104, 105, 106, 107}, talkState[talkUser]) then 
	selfSay("Ok then.", cid)
elseif msgcontains(msg, 'special task') then
	if getPlayerStorageValue(cid, 10003) == 5 then
		if getPlayerLevel(cid) >= 90 then
			if getPlayerStorageValue(cid, tiquandas_revenge) == -1 then
				selfSay("Have you heared about Tiquandas Revenge? It is said that the jungle itself is alive and takes revenge for all the bad things people have done to it. ...", cid)
				delayedSay("I myself believe that there is some truth in this clap trap. Something 'real' which therefore must have a hideout somewhere. Go find it and take revenge yourself! Ask me about the special task when you're done.", 10000, cid)
				setPlayerStorageValue(cid, main_storage, 104)
				setPlayerStorageValue(cid, tiquandas_revenge, 1)
			elseif getPlayerStorageValue(cid, demodras) == -1 then
				selfSay("Kill Demodras.", cid)
				setPlayerStorageValue(cid, main_storage, 102)
				setPlayerStorageValue(cid, demodras, 1)
			end
		elseif getPlayerLevel(cid) >= 100 and getPlayerStorageValue(cid, demons) == -1 then
			selfSay("Kill 6666 Demons.", cid)
			setPlayerStorageValue(cid, main_storage, 100)
			setPlayerStorageValue(cid, demons, 1)
		end
	end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Below this

Code:
local others_tasks = {
			[1] = {name = "quaras", storage = 9992, expe = "yes", how_many = 12000, finish_storage_value = 23, begin_storage_value = 22, boss = "yes", after_kill_boss = 25, before_kill_boss = 24, talkstate = 101},
			[2] = {name = "quara scouts", storage = 9993, expe = "yes", how_many = 10000, finish_storage_value = 21, begin_storage_value = 20, talkstate = 102},
			[3] = {name = "fire", storage = 9991, expe = "yes", how_many = 7000, finish_storage_value = 27, begin_storage_value = 26, talkstate = 104},
			[4] = {name = "water", storage = 9990, expe = "yes", how_many = 7000, finish_storage_value = 29, begin_storage_value = 28, talkstate = 105},
			[5] = {name = "earth", storage = 9989, expe = "yes", how_many = 10000, finish_storage_value = 31, begin_storage_value = 30, talkstate = 106},
			[6] = {name = "energy", storage = 9988, expe = "yes", how_many = 10000, finish_storage_value = 33, begin_storage_value = 32, talkstate = 107}

edit this part where the xxxx are put the storagevalue of youre promoted players
like if a player buys elite knight promotion he gets a storage value insert that value here
if lets say the value = (cid,2020,1) then only add 2020 on the X marks

Code:
if (getPlayerStorageValue(cid, xxxx) == 1) then			
if msgcontains(msg, 'task') and getStorage == 0 or getStorage == -1 then 
	if getStorage == -1 then
		setPlayerStorageValue(cid, main_storage, 0)
		elseif getPlayerStorageValue(cid, xxxx) == -1)
		selfSay("you are a noob in our society lol", cid)
		end
	end	
end

if this fixes it then please let me know
 
izaak

I don't know if you get it, look:

(I'll take spare parts of the script)

LUA:
local promote = getPlayerStorageValue(cid, 10003)

local promotion = {
				[1] = {talktype = 50, how_many_exp = 5000, finish_storage_values = 0},
				[2] = {talktype = 51, how_many_exp = 8000, finish_storage_values = 1},
				[3] = {talktype = 52, how_many_exp = 10000, finish_storage_values = 2},
				[4] = {talktype = 53, how_many_exp = 15000, item = "yes", what = 10518, count = 1, finish_storage_values = 3},
				[5] = {talktype = 54, how_many_exp = 30000, finish_storage_values = 4}
				}

for i = 1, #promotion do
	if msgcontains(msg, 'promotion') then
		if talkState[talkUser] == promotion[i].talktype then
			if getPlayerStorageValue(cid, 10003) == promotion[i].finish_storage_values-1 then
				doPlayerAddExp(cid, promotion[i].how_many_exp)
				doSendAnimatedText(getPlayerPosition(cid), promotion[i].how_many_exp, TEXTCOLOR_WHITE)
				setPlayerStorageValue(cid, 10003, promotion[i].finish_storage_values)
					if talkState[talkUser] == 50 then
						selfSay("You have completed 5 tasks! Let me promote you to the first rank: {Huntsman}. Congratulations! ...", cid)
						delayedSay("If you find any trophies that you don't need, feel free to ask me for a {trade}.", 10000, cid)
					elseif talkState[talkUser] == 51 then
						delayedSay("You have completed 10 hunting tasks. It's time for a promotion. You advance to the rank of {Ranger}. Congratulations! ...", 0, cid)
						delayedSay("Oh, I made a deal with Lorek. He ships Rangers from our society - and higher ranks of course - to Banuta, Chor or near the mountain pass to Darama. Just ask him for a passage.", 10000, cid)
					elseif talkState[talkUser] == 52 then
						selfSay("Good show! You have completed 20 hunting tasks for the 'Paw and Fur - Hunting Elite. You have earned the right to join the ranks of those known as {Big game} {hunter}. Congratulations! ...", cid)
						delayedSay("From now on I'll buy more trophies from you!", 10000, cid)
					elseif talkState[talkUser] == 53 then
						selfSay("Spiffing! You have done 30 hunting tasks! From now on you can call yourself a {Trophy hunter}. As a reward I have this special backpack for you and in addition you can sell some more rare trophies to me.", cid)
					elseif talkState[talkUser] == 54 then
						selfSay("Congratulations! You have made the highest rank: {Elite hunter}. If haven't yet done so ask me for the {special task}.", cid)
							if promotion[i].item == "yes" then
								doPlayerAddItem(cid, promotion[i].what, promotion[i].count)
							end
					end
			end
		end
	end
end

I want something like this:

LUA:
if getPlayerStorageValue(cid, 10003, huntsman) then
opentradechannel
else selfSay("You don't have the required rank to trade items here", cid)

got it?

thanks for your attemption
 
i think if you add this to the npc that he wil open the trade channel

Code:
if msgcontains(msg, 'trade') and getPlayerStorageValue(cid, 10003, huntsman) then
selfsay(cid,18)
elseif(getPlayerStorageValue(cid, 10003, huntsman) == -1) then
selfSay("You don't have the required rank to trade items here", cid)
		end
	end


MESSAGE_SENDTRADE could also work as selfsay but i dont know that for sure i took the command from my npc system xD
i forgot to add the 2x end its updated
 
Last edited:
Ok, thanks a lot

I'll gonna take a shower, just got back from work, gonna eat something and try here :]

I'll update the post after testing, thanks again.

hohoho it worked

I've changed somethings :]
 
Last edited:
Back
Top