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

Lua need help with an npc

Elaney

Member
Joined
Jan 1, 2009
Messages
1,561
Reaction score
12
Location
Sweden
What isnt working is doPlayerSetVocation(cid, 8)

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 getplayervoc = getPlayerVocation(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if msgcontains(msg, 'elite knight') then
		if getPlayerLevel(cid) >= 1 and getplayervoc == 1  then
			selfSay('Do you want to promote yourself to an Elite knight for 100000 gold?', cid)
		else
			selfSay('Your not an knight.', cid)
			talkState[talkUser] = 1
		end                     
	elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
		if  getPlayerLevel(cid) >= 1 and getplayervoc == 2 then
			doPlayerSetVocation(cid, 8)
			selfSay('You are now promoted to an Elite knight.', cid)
			talkState[talkUser] = 0
		else 
			selfSay('gtfo', cid)
		end
	elseif msgcontains(msg, 'Royal paladin') then
		if getPlayerLevel(cid) >= 1 and getplayervoc == 3 then
			selfSay('Do you want to promote yourself to an royal paladin for 100000 gold?', cid)
		else
			selfSay('You need to be level 1000.', cid)
			talkState[talkUser] = 1
		end
		elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
		if  getPlayerLevel(cid) >= 1 and getplayervoc == 3 then
			doPlayerSetVocation(cid, 12)
			selfSay('You are now promoted to an royal paladin.', cid)
			talkState[talkUser] = 0
		else 
			selfSay('gtfo', cid)
		end
        end
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Use this one:
Lua:
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({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})
	node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 100000, level = 1000, promotion = 1, text = 'Congratulations! You are now promoted.'})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true})

npcHandler:addModule(FocusModule:new())
 

Similar threads

Back
Top