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

A way to set the distance for an NPC to listen to a play? TFS 1.2
 
local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} 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 = 5002 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, "mission") then if getPlayerStorageValue(cid, storage) == -1 then selfSay("I have a mission for you to kill 5 dragons and 3 dragon lords, do you accept?", cid) talkState[talkUser] = 1 elseif getPlayerStorageValue(cid, storage) == 1 then selfSay("Did you kill 5 dragons and 3 dragon lords?", cid) talkState[talkUser] = 1 else selfSay("You already did the mission.", cid) end elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then if getPlayerStorageValue(cid, storage) == -1 then selfSay("Good, come back when you killed them.", cid) setPlayerStorageValue(cid, storage, 1) else if getPlayerStorageValue(cid, 19000) == 5 and getPlayerStorageValue(cid, 19001) == 3 then selfSay("Good job, here is your reward.", cid) doPlayerAddItem(cid, 2160, 5) doPlayerAddExp(cid, 50000) setPlayerStorageValue(cid, storage, 2) else selfSay("You didn't kill them all.", cid) end end talkState[talkUser] = 0 elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then selfSay("Ok then.", cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
what if i need to do alot of monsters? i understood the creatureevents one.
 
What kind of example do you mean, can you be more specific about what you are looking for?
 
What kind of example do you mean, can you be more specific about what you are looking for?
I'm using tfs 0.4 and i've mitrox script so what i need is like this
Code:
  [1] = {monsters= {
     {name = hydra, count = 12},
     {name = demon, count = 20},
 
The script I linked has this.
Code:
[2] = {
   monsters = {
     {name = "Rats", count = 20, storage = 21900},
     {name = "Rotworms", count = 26, storage = 21901}
   },
   message = "Thanks, for your next mission kill",
   level = 30,
   rewarditems = {
     {id = 2160, count = 5}
   },
   rewardexp = 40000
},
 
The script I linked has this.
Code:
[2] = {
   monsters = {
     {name = "Rats", count = 20, storage = 21900},
     {name = "Rotworms", count = 26, storage = 21901}
   },
   message = "Thanks, for your next mission kill",
   level = 30,
   rewarditems = {
     {id = 2160, count = 5}
   },
   rewardexp = 40000
},
So for tfs 0.4 i must use this one
http://pastebin.com/frSUfSrp
Code:
local config = {
     ['dragon'] = {amount = 5, storage = 19000, startstorage = 5002, startvalue = 1},
     ['dragon lord'] = {amount = 3, storage = 19001, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster or isSummon(target) then
         return true
     end

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..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 completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
 
Last thing, Like this?
Code:
  [2] = {
                monsters = {
                        {name = "Rats", count = 20, storage = 21900},
                        {name = "Rotworms", count = 26, storage = 21901}
local config = { ['Rats'] = {amount = 20, storage = 21900, startstorage = 5002, startvalue = 1}, ['Rotworms'] = {amount = 26, storage = 21901, startstorage = 5002, startvalue = 1} }
But what about Start value?
 
Last edited:
The startstorage should be the NPC storage, so 45551, the names of the monsters in the creaturescript should be without capital and s, so just rat and rotworm, the monster storage is correct.
 
The startstorage should be the NPC storage, so 45551, the names of the monsters in the creaturescript should be without capital and s, so just rat and rotworm, the monster storage is correct.
thanks, gonna try it.
 
@Limos I've did all what you said and this is the result
Code:
local config = {
     ['rat'] = {amount = 20, storage = 21900, startstorage = 45551, startvalue = 1},
     ['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 1},
     ['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 1}
}
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster or isSummon(target) then
         return true
     end

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..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 completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
when i'm trying to kill a monster that's what i found.
mn2hli.jpg

and the monster being like this when i kill rotworm.
jkf711.jpg
 
@Limos I've did all what you said and this is the result
Code:
local config = {
     ['rat'] = {amount = 20, storage = 21900, startstorage = 45551, startvalue = 1},
     ['rotworm'] = {amount = 26, storage = 21901, startstorage = 45551, startvalue = 1},
     ['dragon lord'] = {amount = 25, storage = 21902, startstorage = 45551, startvalue = 1}
}
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster or isSummon(target) then
         return true
     end

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..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 completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
when i'm trying to kill a monster that's what i found.
mn2hli.jpg

and the monster being like this when i kill rotworm.
jkf711.jpg

Code:
function isSummon(cid)
        return (isCreature(cid) == TRUE and (getCreatureMaster(cid) ~= cid)) and TRUE or FALSE
    end
 
Back
Top