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

random vocation

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 creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, "voc") then
		npcHandler:say("Would you like to receive your vocation?", cid)
		Topic[cid] = 1
	elseif Topic[cid] == 1 then
		if(msgcontains(msg, "yes")) then
			doPlayerSetVocation(cid, math.random(1, 4))
			npcHandler:say("Congratulations! You are now a " .. getPlayerVocationName(cid) .. ". Are you prepared to be teleported to your new town?", cid)
			Topic[cid] = 2
		else
			npcHandler:say("So be it.", cid)
			Topic[cid] = 0
		end
	elseif Topic[cid] == 2 then
		if(msgcontains(msg, "yes")) then
			local t = {
				[1] = {x = 100, y = 100, z = 7},
				[2] = {x = 100, y = 100, z = 7},
				[3] = {x = 100, y = 100, z = 7},
				[4] = {x = 100, y = 100, z = 7}
			}
			doTeleportThing(cid, t[getPlayerVocation(cid)], false)
			doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
			Topic[cid] = 0
		else
			npcHandler:say("Stop wasting my time!", cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, "bye") then
		npcHandler:say("Good bye.", cid)
		npcHandler:releaseFocus(cid)
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top