• 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!

Lua Quest NPC

hasbro

Member
Joined
Feb 15, 2009
Messages
287
Reaction score
6
I'm making one global quest and i need help in this script..
Lua:
 -- start shit
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
--returns how many msgs he have said already
function cancelNPCTalk(events)
  local ret=1
  for aux=1,table.getn(events) do
     if events[aux].done==FALSE then
        stopEvent(events[aux].event)
     else
        ret=ret+1
     end
  end
  events=nil
  return(ret)
end
 
function doCreatureSayWithDelay(cid,text,type,delay,e)
   if delay<=0 then
      doCreatureSay(cid,text,type)
   else
      local func=function(pars)
                    doCreatureSay(pars.cid,pars.text,pars.type)
                    pars.e.done=TRUE
                 end
      e.done=FALSE
      e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
   end
end

function doNPCTalkALot(msgs,interval)
  local e={}
  local ret={}
  if interval==nil then interval=3000 end --3 seconds is default time between messages
  for aux=1,table.getn(msgs) do
      e[aux]={}
      doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux])
      table.insert(ret,e[aux])
  end
  return(ret)
end
--end shit :P


function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end      
-- zmienne lokalne
   local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg,'fight') then
npcHandler:say("You can help in the fight against the hive. There are several {missions} available to destabilise the hive. Just ask for them if you want to learn more. After completing many missions you might be worthy to get a {reward}.",cid)	
end
if msgcontains(msg,'mission') then
if getPlayerStorageValue(cid,10056) == 8 then
doPlayerAddExperience(cid,400)
end
if getPlayerStorageValue(cid,10054) == 1 then
npcHandler:say("You are not done yet, foolish mortal.",cid)
end
npcHandler:say("As usual you could try to {blind} the hive, you might disrupt its {digestion}, you could gather {acid} or you can {disable} the swarm pores. ...",cid)
npcHandler:say("Due to our recent success, the hive\'s defences are broken and it is also possible to {kill} the guards or to {break} the control crystals ...", cid)
end
if msgcontains(msg,'disable') and getPlayerStorageValue(cid,10056) == -1  then
npcHandler:say("The hive can even transport and control several eggs. They can be used to quickly create some lesser {Hive Born}. Though unremarkable on their own, their sheer number and unceasing assaults are a threat. ...",cid)
npcHandler:say("You can use a special goo to disrupt the spawn pores of the hive in the east. Disable 7 of them to stop their threat. Do you want to take this mission?",cid)
talkState[talkUser] = 1
elseif msgcontains(msg,'yes') then
if talkState[talkUser] == 1 then
npcHandler:say("Fine. I\'ll await your return. If you lose the goo, you'll have to {buy} new one.",cid)
setPlayerStorageValue(cid,10054,1)
talkState[talkUser] = 2
elseif msgcontains(msg,'no') then
if talkState[talkUser] == 1 then
npcHandler:say("As you wish. Then choose another one.",cid)
end
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top