• 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 of Missions

roii12

New Member
Joined
Mar 28, 2013
Messages
38
Reaction score
0
Location
Santiago de Chile
1)I want to make a story of mission several NPC.
you have to go by talking with NPCs, unable to jump one
and to move to another npc you have to finish the previous mission.

2)similar to the above, but they are npc's a repeat, Missions giving diferenets than before

plzz!
 
What exactly are you looking for? What kind of missions, how much missions, how is the second npc involved with the first one and can you make a conversation example (between the player and the npc)?
 
limos: a npc you a mission and a storage you finish with that storage can talk to another npc and you a mission, the mission temrinar the other storage you to talk to another npc and so on.


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


function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end


local storage = 4444 --Storage to be needed
local busy = "Sorry, im busy right now" --No quest message
local mission1 = "Oh yes i need help in a mission, you can help me?" --Message dysplayed when you got the right storage
local mission2 = "Fine, search my map!" --Message displayed when you say yes to accept the mission
--Comment, try to watch closely, down at nodes there are the text and you can edit it to the npc respond
local storageset = 4445 --Storage id to be put on 1 when you accept the mission
npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|.") --Greeting message

function storage(cid, message, keywords, parameters, node)
if(cid ~= npcHandler.focus) then
return false
end
if getPlayerStorageValue(cid, storage) == 1 then
npcHandler:say(mission1, cid)
else
npcHandler:say(busy, cid)
npcHandler:resetNpc()
end
return true
end

function storage1(cid, message, keywords, parameters, node)
if(cid ~= npcHandler.focus) then
return false
end
npcHandler:say(mission2, cid)
doSetPlayerStorageValue(cid, storageset, 1)
npcHandler:resetNpc()
return true
end

local node1 = keywordHandler:addKeyword({'raiden'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Raiden is the best scripter :D'})
local node2 = keywordHandler:addKeyword({'mission'}, storage)
local node3 = node2:addChildKeyword({'yes'}, storage1)
local node3 = node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'No?, cmon mate'})

npcHandler:addModule(FocusModule:new())
 
try with this one mate

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


function onCreatureAppear(cid)	 npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid)	 npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)	 npcHandlernCreatureSay(cid, type, msg) end
function onThink()	 npcHandlernThink() end


npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|.") --Greeting message

function storage(cid, message, keywords, parameters, node)
if(cid ~= npcHandler.focus) then
return false
end

local storage = 4444 --Storage to be needed
local busy = "Sorry, im busy right now" --No quest message
local mission1 = "Oh yes i need help in a mission, you can help me?" --Message dysplayed when you got the right storage

if getPlayerStorageValue(cid, storage) == 1 then
npcHandler:say(mission1, cid)
else
npcHandler:say(busy, cid)
npcHandler:resetNpc()
end
return true
end

function storage1(cid, message, keywords, parameters, node)
if(cid ~= npcHandler.focus) then
return false
end

local mission2 = "Fine, search my map!" --Message displayed when you say yes to accept the mission
local storageset = 4445 --Storage id to be put on 1 when you accept the mission

npcHandler:say(mission2, cid)
doSetPlayerStorageValue(cid, storageset, 1)
npcHandler:resetNpc()
return true
end

local node1 = keywordHandler:addKeyword({'raiden'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Raiden is the best scripter '})
local node2 = keywordHandler:addKeyword({'mission'}, storage)
local node3 = node2:addChildKeyword({'yes'}, storage1)
local node3 = node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'No?, cmon mate'})

npcHandler:addModule(FocusModule:new())
 
With an npc conversation example I mean something like this.
Code:
Player: mission
NPC1: Your mission is to get 1 sword

Player: mission
NPC1: Did you get the sword?
Player: yes
-- Player gives sword
NPC1: Thanks, now go to NPC2 for your next mission.
But then how it should be with the idea you had for your npcs.
 
Limos something like

player: mission
npc: you need go to the cave and bring me x item!

after:
player: mission
npc: you brought the items?
player: yes
npc: thx, now you need go to talk with x NPC

NPc2:
Player: hi
Npc: hi
Player: mission
NPC: you need learn xxx spell with xxx NPC

Npc3:
npc:You talk with npc2'
Player: yes
Npc: and you want?
player: i need learn a spell
Npc: for learn spell you need give me all you experience withd kill monster, kill xxx monster
Player: bye

after:
npc: you kill monster
Player: yes
npc: you learn spell, now you need go to talk with npc2

Npc2:
you learned spell
player: yes
NpC: give the reward
 
NPC1
Lua:
-- NPC1
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 storage = 11205 
 
	if(msgcontains(msg, "mission")) then
		if(getPlayerStorageValue(cid, storage) == -1) then
			selfSay("You need to go to the cave and bring me x item.", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif(getPlayerStorageValue(cid, storage) == 1) then
			selfSay("You brought the item?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) >= 2) then
			selfSay("Thanks again for your item.", cid)
		end
	elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1) then
		if doPlayerRemoveItem(cid, 2376, 1) then
			selfSay("Thx, now you need to talk with NPC2.", cid)
			setPlayerStorageValue(cid, storage, 2)
		else
			selfSay("You don't have the item.", cid)
		end
		talkState[talkUser] = 0
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

NPC2
Lua:
-- NPC2
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 storage = 11205 
 
	if(msgcontains(msg, "mission")) then
		if(getPlayerStorageValue(cid, storage) == -1) then
			selfSay("I heard NPC1 is looking for some item in a cave.", cid)
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			selfSay("You need learn xx spell with NPC3.", cid)
			setPlayerStorageValue(cid, storage, 3)
		elseif(getPlayerStorageValue(cid, storage) == 5) then
			selfSay("You learned spell?", cid)
			talkState[talkUser] = 1
		else
			selfSay("Hm..", cid)
		end
	elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1) then
		selfSay("Here is your reward, although I don't know what it is because roi12 forgot to say it.", cid)
		setPlayerStorageValue(cid, storage, 6)
		talkState[talkUser] = 0
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

NPC3
Lua:
-- NPC3
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 storage = 11205 
	local monsterstorage = 24901
 
	if(msgcontains(msg, "mission")) then
		if(getPlayerStorageValue(cid, storage) == -1) then
			selfSay("I heard NPC1 is looking for some item in a cave.", cid)
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			selfSay("NPC1 told you to go to NPC2.", cid)
		elseif(getPlayerStorageValue(cid, storage) == 3) then
			selfSay("You talk with NPC2?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) == 4) then
			selfSay("You kill monster?", cid)
			talkState[talkUser] = 1
		else
			selfSay("Good job killing the monster.", cid)
		end
	elseif(msgcontains(msg, "yes") and talkState[talkUser] == 1) then
		if(getPlayerStorageValue(cid, storage) == 3) then
			selfSay("And you want?", cid)
			talkState[talkUser] = 2
		elseif(getPlayerStorageValue(cid, storage) == 4) then
			if(getPlayerStorageValue(cid, monsterstorage) >= 1) then
				selfSay("You learn spell, now you need go to talk with NPC2", cid)
				doPlayerLearnInstantSpell(cid, "Death Strike")
				setPlayerStorageValue(cid, storage, 5)
			else
				selfSay("You didn't kill the monster.", cid)
			end
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, "spell") and talkState[talkUser] == 2) then
		selfSay("For learn spell you need give me all you experience withd kill monster, kill xxx monster.", cid)
		setPlayerStorageValue(cid, storage, 4)
		talkState[talkUser] = 0
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

creaturescript
Lua:
function onKill(cid, target)

	if isPlayer(target) then
		return true
	end

	if getCreatureName(target):lower() == "dragon" then
		if getPlayerStorageValue(cid, 11205) == 4 and getPlayerStorageValue(cid, 24901) == -1 then		
			setPlayerStorageValue(cid, 24901, 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed the monster, you can go back to NPC3 now for your spell.")
		end
	end
	return true
end
 
Last edited:
thx
have a small problem:
1) [28/05/2013 13:50:43] [Warning - Event::loadScript] Event onDeath not found (data/creaturescripts/scripts/Killmonster.lua)


and the reward I want is only a storage plzz!
 
Last edited:
The creaturescript is onKill, not onDeath.
Example for TFS 0.3.
XML:
<event type="kill" name="Monster" event="script" value="monster.lua"/>
Example for TFS 0.2.
XML:
<event type="kill" name="Monster" script="monster.lua"/>

Also don't forget to add the name in login.lua
Lua:
registerCreatureEvent(cid, "Monster")
 
creaturescript
Lua:
function onKill(cid, target)

	if isPlayer(target) then
		return true
	end

	if getCreatureName(target):lower() == "dragon" then
		if getPlayerStorageValue(cid, 11205) == 4 and getPlayerStorageValue(cid, 24901) == -1 then		
			setPlayerStorageValue(cid, 24901, 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed the monster, you can go back to NPC3 now for your spell.")
		end
	end
	return true
end
This.
If you kill the monster, you should get a message.
 
Last edited:
thanks now I worked!!

a small query, 1)as you added to storage needed to talk

2)and you can put a npc with 3 different functions?
example: 1) talk to the
***************** 2) (with another storage) you ask an object
**************** 3) (with another storage) sell spell
 
1) player need storage to talk with npc
2) npc have 3 functions
first: just talk and that storage1
second: just talk and that storage2 but need storageX to talk for second time
three: give a mission buy need storage Y yo talk for three time
 
1) player need storage to talk with npc
2) npc have 3 functions
first: just talk and that storage1
second: just talk and that storage2 but need storageX to talk for second time
three: give a mission buy need storage Y yo talk for three time

try to use the translator or just try to write well
 
Back
Top