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

Need NPC for custom promotions (rep++)

fexark

New Member
Joined
May 3, 2009
Messages
89
Reaction score
0
Guys im searching or i need a npc that can promote but with custom vocations, for example i have 2 vocations : ranger and mage and i want mage be able to choose between druid or sorcerer and the ranger can choose for paladin or knight, please i need this npcs scripts, the vocations i said are random but the idea i think its pretty clear.

Please help me rep++ to who do this npc.
Tfs 0.2.1 Tibia 8.7
 
I don't know what NPC libraries your TFS version has, so if this doesn't work, please do post here :)

Untested code, so some stupid errors might have slipped :)
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 onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid)			end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid)		end


local SORCERER_VOCATION = 1
local DRUID_VOCATION = 2
local PALADIN_VOCATION = 3
local KNIGHT_VOCATION = 4
local MAGE_VOCATION = 5
local RANGER_VOCATION = 6


function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


	if msgcontains(msg, "promote") or msgcontains(msg, "promotion") and not talkState[talkUser] > 0 then
		if getPlayerVocation(cid) == MAGE_VOCATION then
			selfSay("I see you are a mage, I can promote you to either a 'sorcerer' or a 'druid', which path do you want to follow?", cid)
			talkState[talkUser] = 10
		elseif getPlayerVocation(cid) == RANGER_VOCATION then
			selfSay("I see you are a ranger, I can promote you to either a 'paladin' or a 'knight', which path do you want to follow?", cid)
			talkState[talkUser] = 20
		end
	elseif(msgcontains(msg, "sorcerer") and talkState[talkUser] == 10) then
		selfSay("A sorcerer, are you sure?", cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, "druid") and talkState[talkUser] == 10) then
		selfSay("A druid, are you sure?", cid)
		talkState[talkUser] = 2
	elseif(msgcontains(msg, "paladin") and talkState[talkUser] == 20) then
		selfSay("A paladin, are you sure?", cid)
		talkState[talkUser] = 3
	elseif(msgcontains(msg, "knight") and talkState[talkUser] == 20) then
		selfSay("A knight, are you sure?", cid)
		talkState[talkUser] = 4
	elseif msgcontains(msg, "yes") and talkState[talkUser] >= 1 and talkState[talkUser] <= 4 then
		selfSay("Very well, your choice has been made!", cid)
		setPlayerVocation(cid, talkState[talkUser])
		talkState[talkUser] = 0
	elseif msgcontains(msg, "no") and talkState[talkUser] >= 1 and talkState[talkUser] <= 4 then
		selfSay("I know it is a big decision, please do take your time.", cid)
		talkState[talkUser] = 0
	else
		selfSay("I'm sorry, but I couldn't understand what you said, please start over.", cid)
		talkState[talkUser] = 0
	end
	return true
end


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