• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Quest NPC - Do job and Recive item.

ewcke

Santiria 8.60
Joined
Apr 13, 2009
Messages
39
Reaction score
1
--------------------------------------------------
--------------------------------------------------

I've now fixed this NPC script. Here it the result.

Bast.xml
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Bast" script="data/npc/scripts/quest npc bast.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="133" head="20" body="39" legs="45" feet="7" addons="0"/>
</npc>

quest npc bast.lua
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local storage = 20000

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

function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, "hi") or msgcontains(msg, "hello") and (not npcHandler:isFocused(cid)) then
if getPlayerStorageValue(cid, storage) < 1 then
selfSay("Please {help} me!", cid, TRUE)
Topic[talkUser] = 0
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Have you brought the Golden Falcon and the Horne's?", cid, TRUE)
Topic[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 2 then
selfSay("Oh hello my wife is doing fine!", cid, TRUE)
Topic[talkUser] = 0
end
npcHandler:addFocus(cid)
return true
end
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
selfSay("Good bye.", cid, TRUE)
Topic[talkUser] = 0
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "quest") or msgcontains(msg, "mission") or msgcontains(msg, "task") or msgcontains(msg, "help") or (msgcontains(msg, "medicine") and getPlayerStorageValue(cid, storage) > 0) then
if getPlayerStorageValue(cid, storage) < 1 then
npcHandler:say("Oh please help me.. I need to get the left and right horne of a Morgaroth and a Golden Falcon of the barbarians. I would be really glad if you could get those things for me!", cid)
setPlayerStorageValue(cid, storage, 1)
Topic[talkUser] = 0
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Have you brought the required items?", cid, TRUE)
Topic[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 2 then
selfSay("Thank you so much, take this itams as a gift from me!", cid, TRUE)
Topic[talkUser] = 0
end
elseif Topic[talkUser] == 1 then
if msgcontains(msg, "yes") then
if getPlayerItemCount(cid, 2337) >= 1 and getPlayerItemCount(cid, 2338) >= 1 and getPlayerItemCount(cid, 9003) >= 1 then
doPlayerRemoveItem(cid, 2337, 1)
doPlayerRemoveItem(cid, 2338, 1)
doPlayerRemoveItem(cid, 9003, 1)
npcHandler:say("Oh please take this items.", cid)
doPlayerAddItem(cid, 2160, 100)
doPlayerAddItem(cid, 9932, 1)
setPlayerStorageValue(cid, storage, 2)
else
npcHandler:say("YOU DON'T HAVE THEM! PLEASE HURRY THE FUCK UP!", cid)
end
else
npcHandler:say("PLEASE HURRY!", cid)
end
Topic[talkUser] = 0
end
return TRUE
end

npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Back
Top