NPC Mission

Discussion in 'Programming & Scripting' started by Limos, Mar 10, 2014.

  1. Itutorial

    Itutorial Active Member

    Joined:
    Dec 23, 2014
    Messages:
    743
    A way to set the distance for an NPC to listen to a play? TFS 1.2
     
  2. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
  3. Itutorial

    Itutorial Active Member

    Joined:
    Dec 23, 2014
    Messages:
    743
    That doesn't seem to change anything
     
  4. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
    Did you restart the server?
     
  5. Itutorial

    Itutorial Active Member

    Joined:
    Dec 23, 2014
    Messages:
    743
    of course :p
     
  6. Activity

    Activity Member

    Joined:
    Apr 7, 2016
    Messages:
    159
    what if i need to do alot of monsters? i understood the creatureevents one.
     
  7. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
  8. Activity

    Activity Member

    Joined:
    Apr 7, 2016
    Messages:
    159
  9. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
    What kind of example do you mean, can you be more specific about what you are looking for?
     
  10. Activity

    Activity Member

    Joined:
    Apr 7, 2016
    Messages:
    159
    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},
    
     
  11. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
    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
    },
    
     
    Activity likes this.
  12. Activity

    Activity Member

    Joined:
    Apr 7, 2016
    Messages:
    159
    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
     
  13. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
    Yes, and change the storages so they match with the ones in the NPC script.
     
    Activity likes this.
  14. Activity

    Activity Member

    Joined:
    Apr 7, 2016
    Messages:
    159
    Last thing, Like this?
    Code:
      [2] = {
                    monsters = {
                            {name = "Rats", count = 20, storage = 21900},
                            {name = "Rotworms", count = 26, storage = 21901}
    
    But what about Start value?
     
    Last edited: Apr 13, 2016
  15. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
    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.
     
    Activity likes this.
  16. Activity

    Activity Member

    Joined:
    Apr 7, 2016
    Messages:
    159
    thanks, gonna try it.
     
  17. Activity

    Activity Member

    Joined:
    Apr 7, 2016
    Messages:
    159
    @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.
    [​IMG]
    and the monster being like this when i kill rotworm.
    [​IMG]
     
  18. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
  19. StreamSide

    StreamSide Joseluis Gonzalez

    Joined:
    Aug 31, 2007
    Messages:
    2,515
    Code:
    function isSummon(cid)
            return (isCreature(cid) == TRUE and (getCreatureMaster(cid) ~= cid)) and TRUE or FALSE
        end
     
    Activity likes this.
  20. Activity

    Activity Member

    Joined:
    Apr 7, 2016
    Messages:
    159

Share This Page