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

add lvl to this npc

kimokimo

Kimo
Joined
Jan 25, 2011
Messages
821
Solutions
6
Reaction score
156
GitHub
karimadnan
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

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 vocationName = ''
if getPlayerVocation(cid) == 9-4 then
vocationName = 'white wizard'
elseif getPlayerVocation(cid) == 10-4 then
vocationName = 'holy Shaman'
elseif getPlayerVocation(cid) == 11-4 then
vocationName = 'deadly archer'
elseif getPlayerVocation(cid) == 12-4 then
vocationName = 'elite Berserker'
else
vocationName = 'You do not match any vocation'
end
	if(msgcontains(msg, 'prize')) then
	if getPlayerStorageValue(cid,20008) <= 0 then
		selfSay('if you reach lvl 500 say {promotion} for all of your hard work.', cid)
		talkState[talkUser] = 1
		else
		selfSay('Begone!.', cid)
		doTeleportThing(cid,{x = 1000, y = 1000, z = 7},false)	
	end
	elseif(msgcontains(msg, 'promotion') and talkState[talkUser] == 1) then
		setPlayerPromotionLevel(cid, 2)
		setPlayerStorageValue(cid, 20008, 1)
		selfSay('You have shown to me that you have mastered each aspect of your vocation. From this point on you may call yourself a '..vocationName..', Ask me to {leave} when you are ready.', cid)
		talkState[talkUser] = 0
end
	return true
end

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

can anyone make if player got lvl 500 or higher can get promotion from this npc
 
What do you mean by "9-4"? That is what confuses me. Here is what I came up with:

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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 thinkCallback(cid)
	if math.random(300) == 1 then
		npcHandler:say("Are you tired of being picked on? Get promoted TODAY!")
	end
	return true
end

local position = {x = 1000, y = 1000, z = 7}
local storage = 20008
local vocs = {
	[{5, 9}] = "White Wizard",
	[{6, 10}] = "Holy Shaman",
	[{7, 11}] = "Deadly Archer",
	[{8, 12}] = "Elite Berserker"
}

function creatureSayCallback(cid, type, msg)
	for voc, t in pairs(vocs) do
		if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and (not npcHandler:isFocused(cid)) then
			npcHandler:say(getPlayerSex(cid) == 0 and "Well hello there lovely lady, are you here to become promoted?" or "Good day sir, are you here to become promoted?", cid)
			npcHandler:addFocus(cid)
			Topic[cid] = 1
		elseif Topic[cid] == 1 then
			if msgcontains(msg, "yes") or msgcontains(msg, "promote") then
				if getPlayerLevel(cid) >= 500 then
					if isInArray(voc[1], getPlayerVocation(cid)) then
						if not isInArray(voc[2], getPlayerVocation(cid)) and getPlayerStorageValue(cid, storage) < 0 then
							npcHandler:say("Are you sure you want to do this? This decision is IRREVERSIBLE!", cid)
							Topic[cid] = 2
						else
							npcHandler:say("What are you doing here? You are already promoted. BE GONE!", cid)
							doTeleportThing(cid, position, false)
							Topic[cid] = nil
						end
					else
						npcHandler:say("It seems you do not have the proper vocation to get the second promotion.", cid)
						Topic[cid] = nil
					end
				else
					npcHandler:say("Your level does not reflect a great enough responsibility. DO NOT WASTE MY TIME!", cid)
					Topic[cid] = nil
				end
			end
		elseif Topic[cid] == 2 then
			if msgcontains(msg, "yes") then
				doPlayerSetPromotionLevel(cid, 2)
				npcHandler:say("Congratulations! You have been promoted to {" .. t .. "}!", cid)
				setPlayerStorageValue(cid, storage, 1)
				doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
				Topic[cid] = nil
			elseif msgcontains(msg, "no") then
				npcHandler:say("FINE! Then do not bother me...", cid)
				Topic[cid] = nil
			end
		elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
			npcHandler:say("Farewell.", cid)
			Topic[cid] = nil
			npcHandler:releaseFocus(cid)
		end
	end
	
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "How rude of you!")
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
 
Back
Top