• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Npc Help

juansanchez

Advanced OT User
Joined
Apr 2, 2015
Messages
223
Reaction score
160
What's up otland people, this is my first post here, but i'm not going to introduce myself..
Anyways, i was wondering if anyone her could help me create 2 npcs, for a quest.

Quite simple, you talk to the first one, get the mission, go talk to the second one (you can only talk to the second one if you talk to the first one) get the items he wants, go back to him, give him the items, he will give you another item, then you go back to the first one, talk to him, he'll take this items off you, and give you your reward.

I dont have a scripit here so you could use as a base, if anyone can help me, i'll be very greatfull.
If someone needs more info about the NPC, just let me know.
 
The server version would be the most helpful information you could post. :P

As for the quest, you can use talkstates and storageId's to make the npc.
 
The server version would be the most helpful information you could post. :p

As for the quest, you can use talkstates and storageId's to make the npc.

8.6 is the version :P sorry i forgot, and i dont know how to make any of the stuff you said xD
 
8.6 is the client version, I need the server version.. lol
The very first line of your start-up will show this.
jSIZeL9.png
 
Oh, sorry :P here you go

[02/04/2015 01:49:30] Styller Yourots, version 0.7.5 (Styller Yourots)
[02/04/2015 01:49:30] Styller Yourots 8.60 criado por LeozeraRox.
[02/04/2015 01:49:30] Compilado versao 8.60 por LeozeraRox - 31/07/2010.
[02/04/2015 01:49:30] Sources do Robson Dias! Obrigado!
[02/04/2015 01:49:30] Um Salve ao XTibia: http://xtibia.com.
 

So limos, the last scripit in the Post worked perfectly, but i wanted the second npc, to ask for something before giving the item to the player, could you adapt it for me? I wanted the npc to ask for 4 items.

If you dont know the scripit that i'm talking about it's this one:

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

local storage = 5003

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, "sacred berry potion") then
if getPlayerStorageValue(cid, storage) == -1 then -- When the player didn't go to NPC1 first, because NPC1 sets the storagevalue to 1.
selfSay("What?", cid)
elseif getPlayerStorageValue(cid, storage) == 1 then -- In NPC1 the storagevalue is set to 1, so this means the player accepted that mission.
selfSay("Ah, I just heard about someone who needed this potion, It's to help NPC1 right?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 2 then -- In NPC2 the storagevalue was set to 2, when going back to NPC1 it will be set to 3, so storagevalue 2 means the player didn't go back to NPC1 yet.
selfSay("Go give the potion, he will feel alot better after drinking it.", cid)
else -- if the storagevalue is not -1, 1 or 2, so someone says 'sacred berry potion' again after giving the potion to NPC1.
selfSay("You gave NPC1 the potion? Thats great, he will feel alot better soon.", cid)
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
-- You don't need to check for storagevalue here, because there is only 1 question you can answer with yes.
selfSay("That's very kind of you, here it is.", cid)
doPlayerAddItem(cid, 10089, 1) -- to add the potion
setPlayerStorageValue(cid, storage, 2) -- set storagevalue to 2 so NPC1 knows the player talked with NPC2
talkState[talkUser] = 0
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
The idea behind the post is for you to learn how to make the npc's yourself. :P
There is literally greentext everywhere explaining what is happening.
If you haven't already, download Notepad++.
If will be the best thing you ever download for scripting.. unless of course you reallly want to start scripting.. in which case you'll start downloading more optimised programs. :P
 
The idea behind the post is for you to learn how to make the npc's yourself. :p
There is literally greentext everywhere explaining what is happening.
If you haven't already, download Notepad++.
If will be the best thing you ever download for scripting.. unless of course you reallly want to start scripting.. in which case you'll start downloading more optimised programs. :p

I know the ideia behind is for you to learn how to do it, but this things are just, waaay too complex xD, i'm still trying to learn how to make the second npc ask for a item before giving you the item, but it just doesnt make sense to me...
 
Back
Top