• 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] Teleports with monster count

Cloow

Active Member
Joined
May 10, 2010
Messages
1,086
Reaction score
35
searched around the forum to long now, im requesting as in title an npc that will teleport you if you have killed enough of monster.
Something alike task npc but reward is travel opportunity
 
Player: hi
npc: Hello, to pass here I want you to kill 15 Dragon Lords and 5 Wyrms. Can you do that?
player: yes
npc: Perfect, come and talk to me when you finished your task.

After the task is done

Player: hi
NPC: Oh, so you completed the task I gave you?
Player: yes
NPC: Alright, you proven yourself worthy of to acces the next floor.
player: next floor
Npc: There we go.
-- Teleports the player

- - - Updated - - -

bump

anyone?
 
You will need this for the actual killing part. It's a creaturescript that counts the kills.

Found it by searching:

Lua:
local monsters = {
	-- name = storage
	["rat"] = 3200,
	["troll"] = 3201,
	["rotworm"] = 3202,
	["dragon"] = 3203,
	["dragon lord"] = 3204,
	["demon"] = 3205,
}

function onKill(cid, target)
	if(isPlayer(target) ~= TRUE) then
		local master = getCreatureMaster(target)
		if(master and master ~= target) then return FALSE end

		local name = getCreatureName(target)
		local monster = monsters[string.lower(name)]
		if(monster) then
			local killedMonsters = getPlayerStorageValue(cid, monster)
			if(killedMonsters == -1) then
				killedMonsters = 1
			end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed " .. killedMonsters .. " " .. name .. " " .. (killedMonsters > 1 and "'s." or "")
			setPlayerStorageValue(cid, monster, killedMonsters + 1)
		end
	end
	return true
end
Now all you need is an NPC to assign the task, check the storages, and teleport the player. ^_^
 
NPC
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)
 
	local config = {
		storage = 24558, -- npcstorage and startstorage for the monsters
		pos = {x = 1000, y = 1000, z = 7},
		dragonlord = {amount = 15, storage = 32000},
		wyrm = {amount = 5, storage = 32001}
	}


	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	if not npcHandler:isFocused(cid) then
		if msgcontains(msg, 'hello') or msg == 'hi' then
			if getPlayerStorageValue(cid, config.storage) == -1 then
				selfSay("Hello, to pass here I want you to kill 15 Dragon Lords and 5 Wyrms. Can you do that?", cid)
				talkState[talkUser] = 1
			elseif getPlayerStorageValue(cid, config.storage) == 1 then
				selfSay("Oh, so you completed the task I gave you?", cid)
				talkState[talkUser] = 1
			else
				selfSay("You can go now to the {next floor}.", cid)
				talkState[talkUser] = 2
			end
			npcHandler:addFocus(cid)
		else
			return false
		end
	end
 
	if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if getPlayerStorageValue(cid, config.storage) == -1 then
			selfSay("Perfect, come and talk to me when you finished your task.", cid)
			setPlayerStorageValue(cid, config.storage, 1)
			talkState[talkUser] = 0
		elseif getPlayerStorageValue(cid, config.storage) == 1 then
			local dragonlordcount = config.dragonlord.amount - (getPlayerStorageValue(cid, config.dragonlord.storage) +1)
			local wyrmcount = config.wyrm.amount - (getPlayerStorageValue(cid, config.wyrm.storage) +1)
			if getPlayerStorageValue(cid, config.dragonlord.storage) == config.dragonlord.amount and getPlayerStorageValue(cid, config.wyrm.storage) == config.wyrm.amount then
				selfSay("Alright, you proven yourself worthy of to acces the {next floor}.", cid)
				setPlayerStorageValue(cid, config.storage, 2)
				talkState[talkUser] = 2
			elseif getPlayerStorageValue(cid, config.dragonlord.storage) == config.dragonlord.amount then
				selfSay("You still need to kill "..wyrmcount.." "..(wyrmcount == 1 and "Wyrm" or "Wyrms")..".", cid)
			elseif getPlayerStorageValue(cid, config.wyrm.storage) == config.wyrm.amount then
				selfSay("You still need to kill "..dragonlordcount.." "..(dragonlordcount == 1 and "Dragon Lord" or "Dragon Lords")..".", cid)
			else
				selfSay("You still need to kill "..wyrmcount.." "..(wyrmcount == 1 and "Wyrm" or "Wyrms").." and "..dragonlordcount.." "..(dragonlordcount == 1 and "Dragon Lord" or "Dragon Lords")..".", cid)
			end
		end
	elseif(msgcontains(msg, 'next floor') and talkState[talkUser] == 2) then
		selfSay("There we go.", cid)
		doTeleportThing(cid, config.pos)
	elseif (msgcontains(msg, 'no')) then
		selfSay("Oh well, I guess not then.", cid)
	elseif (msgcontains(msg, 'bye')) then
		selfSay("Bye.", cid)
		npcHandler:releaseFocus(cid)
	end
	return true
end
 
npcHandler:setMessage(MESSAGE_FAREWELL, "Well, what are you waiting for, I don't have all day!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

CreatureEvent
Lua:
function onKill(cid, target)

local config = {
	["dragon lord"] = {amount = 15, storage = 32000, startstorage = 24558},
	["wyrm"] = {amount = 5, storage = 32001, startstorage = 24558}
}

local monster = config[getCreatureName(target):lower()]

	if(isPlayer(target)) or not monster then
		return true
	end

	if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage) +1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) == 1 then		
		setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Task message: "..(getPlayerStorageValue(cid, monster.storage) +1).."/"..monster.amount.." "..getCreatureName(target).."s killed.")
	end
	if (getPlayerStorageValue(cid, monster.storage) +1) == monster.amount then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you have killed "..(getPlayerStorageValue(cid, monster.storage) +1).." "..getCreatureName(target).."s and finished the "..getCreatureName(target).." mission.")
		setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
	end
	return true
end
 
Last edited:
Back
Top