• 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] Exp giver -request

krille09

Belden
Joined
Aug 15, 2007
Messages
4,892
Reaction score
55
Location
Stockholm, Sweden
I would like to request a NPC that when somebody greets the npc (and checks if he is level 1)
and the player ask about exp/level (diffrent keywords to same question) ...



NPC CHAT said:
Player [1]: Hello
NPC: Hello, are you here for take your levels and just go straight to main? (if true then hand out 4200 exp (lvl 8))
Player [1]: Yes
NPC: Okey then, have some nice time in main land.
Something l
 
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 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, "exp") or msgcontains(msg, "level")) then
		selfSay("Hello, are you here for take your levels and just go straight to main?", cid)
		talkState[talkUser] = 1
	elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if (getPlayerLevel(cid) == 1) then
			doPlayerAddExperience(cid, (4200 - getPlayerExperience(cid)))
			selfSay("Okey then, have some nice time in main land.", cid)
		else
			selfSay("Sorry, but you are higher than 1.")
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
		talkState[talkUser] = 0
		selfSay("Ok then.", cid)
	end

	return true
end

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