CreatureEvent [CreatureEvent/Npc] Killing in the name of...

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by Darkhaos, Mar 16, 2011.

  1. Knight God

    Knight God Active Member

    Joined:
    Oct 19, 2008
    Messages:
    1,180
    Likes Received:
    20
    Best Answers:
    0
  2. rafaelclaumann

    rafaelclaumann New Member

    Joined:
    Jul 7, 2011
    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    player can chose the task?
     
  3. GOD Suimy

    GOD Suimy Member

    Joined:
    Sep 11, 2012
    Messages:
    98
    Likes Received:
    14
    Best Answers:
    0
    Darkhaos I have a problem with this script, I killed 2 trolls and the Npc say this:

    15:41 Grizzly Adams: Current 0 Trolls killed, you need to kill 100.

    SO it doesn't work :S?
     
  4. djtuca

    djtuca Technical Support

    Joined:
    Jun 25, 2011
    Messages:
    198
    Likes Received:
    2
    Best Answers:
    0
    Nice Script
     
    Last edited: May 29, 2013
  5. mct

    mct New Member

    Joined:
    May 7, 2013
    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Not count the killed monsters :/
     
  6. Danger II

    Danger II FluppiX.com

    Joined:
    Nov 21, 2012
    Messages:
    1,457
    Likes Received:
    388
    Best Answers:
    6
    You doin something wrong, this script works 100% :)
     
  7. Wavoz

    Wavoz Oldschooler

    Joined:
    Jul 10, 2011
    Messages:
    974
    Likes Received:
    52
    Best Answers:
    0
    Not working for me :(
    There are like no working task scripts out there... This one is so far the best but IT DOESN'T COUNT THE KILLS... I also tried addings tags to monsters, still nothing....


    13:16 Grizzly Adams: Current 0 Trolls killed, you need to kill 100.
     
  8. djtuca

    djtuca Technical Support

    Joined:
    Jun 25, 2011
    Messages:
    198
    Likes Received:
    2
    Best Answers:
    0
    how to make cancel current task?
     
  9. mct

    mct New Member

    Joined:
    May 7, 2013
    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    I have no more ideas.

    I pasted the code 100%, Im using tfs 0.3.6pl7.... and not count the monsters kill :(
     
  10. 70011983

    70011983 :)

    Joined:
    Nov 21, 2011
    Messages:
    292
    Likes Received:
    43
    Best Answers:
    1
    For that:
    local THESNAPPER_POSITION = {x = 100, y = 100, z = 7}

    Do I put the position of the teleport that leads to the boss or where the boss spawns?
     
  11. Ray Rewind

    Ray Rewind Doctor

    Joined:
    Jun 6, 2009
    Messages:
    1,350
    Likes Received:
    74
    Best Answers:
    0
    How the system work to kill the boss??? will the NPC spawn a portal to get to the boss or what?
     
  12. Diemorko

    Diemorko Member

    Joined:
    Jan 31, 2011
    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    How to make it work on TFS 1.0? there is not 000-constant.lua
    I want it with quest log, ANy one can help me? :)
     
  13. LuisPro

    LuisPro World War <3

    Joined:
    May 10, 2009
    Messages:
    424
    Likes Received:
    49
    Best Answers:
    1
    +1
     
  14. Lifer420

    Lifer420 Well-Known Member

    Joined:
    Jul 27, 2009
    Messages:
    1,485
    Likes Received:
    188
    Best Answers:
    0
    Using on tfs 0.4, script isnt working. Getting this error.

    grizzly.png
     
    Ryxy likes this.
  15. psychosisneamia

    psychosisneamia ~Beginner~

    Joined:
    Jun 7, 2012
    Messages:
    162
    Likes Received:
    7
    Best Answers:
    0
    @Darkhaos I get this error

    [21/04/2014 13:26:36] [Error - Npc interface]
    [21/04/2014 13:26:36] data/npc/scripts/killinginthenameof.lua:eek:nCreatureSay
    [21/04/2014 13:26:36] Description:
    [21/04/2014 13:26:36] data/npc/scripts/killinginthenameof.lua:124: attempt to concatenate field 'raceName' (a nil value)
    [21/04/2014 13:26:36] stack traceback:
    [21/04/2014 13:26:36] data/npc/scripts/killinginthenameof.lua:124: in function 'callback'
    [21/04/2014 13:26:36] data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
    [21/04/2014 13:26:36] data/npc/scripts/killinginthenameof.lua:92: in function <data/npc/scripts/killinginthenameof.lua:92>
     
  16. blaahsnos

    blaahsnos New Member

    Joined:
    May 2, 2013
    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Npc not count monsters killed =/
     
  17. Ryxy

    Ryxy SYN - Morta8.6

    Joined:
    Jul 23, 2013
    Messages:
    96
    Likes Received:
    5
    Best Answers:
    0
    I have the same "error" than @Lifer420

    I'm using "TFS 0.4"

    [9:31:28.254] [Error - LuaInterface::loadFile] data/npc/scripts/killinginthename
    of.lua:90: function arguments expected near ':'
    [9:31:28.255] [Warning - NpcEvents::NpcEvents] Cannot load script: data/npc/scri
    pts/killinginthenameof.lua
    [9:31:28.257] data/npc/scripts/killinginthenameof.lua:90: function arguments exp
    ected near ':'
     
  18. Fiodor

    Fiodor Lua & Maps

    Joined:
    Mar 14, 2009
    Messages:
    400
    Likes Received:
    10
    Best Answers:
    0
    Everything works, but NPC does not give any reward (he says "congratulations etc." but no reward)
    how to fix it? :/
    0.4 tfs

    Code (Text):
    1.  
    2. local THESNAPPER_POSITION = {x = 100, y = 100, z = 7}
    3. local HIDE_POSITION = {x = 100, y = 100, z = 7}
    4. local THEBLOODTUSK_POSITION = {x = 100, y = 100, z = 7}
    5. local SHARDHEAD_POSITION = {x = 100, y = 100, z = 7}
    6. local THUL_POSITION = {x = 100, y = 100, z = 7}
    7. local ESMERALDA_POSITION = {x = 100, y = 100, z = 7}
    8. local THEOLDWIDOW_POSITION = {x = 100, y = 100, z = 7}
    9. local THEMANY_POSITION = {x = 100, y = 100, z = 7}
    10. local LEVIATHAN_POSITION = {x = 100, y = 100, z = 7}
    11. local STONECRACKER_POSITION = {x = 100, y = 100, z = 7}
    12. local THENOXIUSSPAWN_POSITION = {x = 100, y = 100, z = 7}
    13. local MERIKHTHESLAUGHTERER_POSITION = {x = 100, y = 100, z = 7}
    14. local FAHIMTHEWISE_POSITION = {x = 100, y = 100, z = 7}
    15. local RANDOMPIRATEBOSS_POSITION = {x = 100, y = 100, z = 7}
    16. local THEHORNEDFOX_POSITION = {x = 100, y = 100, z = 7}
    17. local NECROPHARUS_POSITION = {x = 100, y = 100, z = 7}
    18.  
    19.  
    20. local tasks =
    21. {
    22. [1] = {questStarted = 1510, questStorage = 65000, killsRequired = 100, raceName = "Trolls", rewards = {{enable = true, type = "exp", values = 200}, {enable = true, type = "money", values = 200}}},
    23.  
    24. [2] = {questStarted = 1511, questStorage = 65001, killsRequired = 150, raceName = "Goblins", rewards = {{enable = true, type = "exp", values = 300}, {enable = true, type = "money", values = 250}}},
    25.  
    26. [3] = {questStarted = 1512, questStorage = 65002, killsRequired = 300, raceName = "Rotworms", rewards = {{enable = true, type = "exp", values = 1000}, {enable = true, type = "money", values = 400}}},
    27.  
    28. [4] = {questStarted = 1513, questStorage = 65003, killsRequired = 500, raceName = "Cyclops", rewards = {{enable = true, type = "exp", values = 3000}, {enable = true, type = "money", values = 800}}},
    29.  
    30. [5] = {questStarted = 1514, questStorage = 65004, killsRequired = 300, raceName = "Crocodiles", rewards = {{enable = true, type = "exp", values = 800}, {enable = true, type = "boss", values = THESNAPPER_POSITION}, {enable = true, type = "points", values = 7}}},
    31.  
    32. [6] = {questStarted = 1515, questStorage = 65005, killsRequired = 300, raceName = "Tarantulas", rewards = {{enable = true, type = "money", values = 1500}, {enable = true, type = "boss", values = HIDE_POSITION}, {enable = true, type = "points", values = 2}}},
    33.  
    34. [7] = {questStarted = 1516, questStorage = 65006, killsRequired = 150, raceName = "Carniphilas", rewards = {{enable = true, type = "item", values = 2160,1}, {enable = false, type = "points", values = 1}}},
    35.  
    36. [8] = {questStarted = 1517, questStorage = 65007, killsRequired = 200, raceName = "Stone Golems", rewards = {{enable = true, type = "exp", values = 2000}, {enable = true, type = "points", values = 1}}},
    37.  
    38. [9] = {questStarted = 1518, questStorage = 65008, killsRequired = 300, raceName = "Mammoths", rewards = {{enable = true, type = "exp", values = 4000}, {enable = true, type = "item", values = 2160,1}}},
    39.  
    40. [10] = {questStarted = 1519, questStorage = 65009, killsRequired = 300, raceName = "Ice Golems", rewards = {{enable = true, type = "exp", values = 15000}, {enable = true, type = "boss", values = SHARDHEAD_POSITION}, {enable = true, type = "points", values = 2}}},
    41.  
    42. [11] = {questStarted = 1520, questStorage = 65010, killsRequired = 300, raceName = "Quaras Scout", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
    43.  
    44. [12] = {questStarted = 1521, questStorage = 65011, killsRequired = 300, raceName = "Quaras", rewards = {{enable = true, type = "exp", values = 12000}, {enable = true, type = "boss", values = THUL_POSITION}, {enable = true, type = "points", values = 2}}},
    45.  
    46. [13] = {questStarted = 1522, questStorage = 65012, killsRequired = 70, raceName = "Water Elementals", rewards = {{enable = true, type = "exp", values = 7000}, {enable = true, type = "points", values = 1}}},
    47.  
    48. [14] = {questStarted = 1523, questStorage = 65013, killsRequired = 70, raceName = "Earth Elementals", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
    49.  
    50. [15] = {questStarted = 1524, questStorage = 65014, killsRequired = 70, raceName = "Energy Elementals", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "points", values = 1}}},
    51.  
    52. [16] = {questStarted = 1525, questStorage = 65015, killsRequired = 70, raceName = "Fire Elementals", rewards = {{enable = true, type = "exp", values = 7000}, {enable = true, type = "points", values = 1}}},
    53.  
    54. [17] = {questStarted = 1526, questStorage = 65016, killsRequired = 200, raceName = "Mutated Rats", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "boss", values = ESMERALDA_POSITION}, {enable = true, type = "points", values = 2}}},
    55.  
    56. [18] = {questStarted = 1527, questStorage = 65017, killsRequired = 500, raceName = "Giant Spiders", rewards = {{enable = true, type = "exp", values = 5000}, {enable = true, type = "boss", values = THEOLDWIDOW_POSITION}, {enable = true, type = "points", values = 2}}},
    57.  
    58. [19] = {questStarted = 1528, questStorage = 65018, killsRequired = 2000, raceName = "Hydras", rewards = {{enable = true, type = "boss", values = THEMANY_POSITION}, {enable = true, type = "points", values = 4}}},
    59.  
    60. [20] = {questStarted = 1529, questStorage = 65019, killsRequired = 2000, raceName = "Sea Serpents", rewards = {{enable = true, type = "boss", values = LEVIATHAN_POSITION}, {enable = true, type = "points", values = 4}}},
    61.  
    62. [21] = {questStarted = 1530, questStorage = 65020, killsRequired = 2000, raceName = "Behemoths", rewards = {{enable = true, type = "boss", values = STONECRACKER_POSITION}, {enable = true, type = "points", values = 4}}},
    63.  
    64. [22] = {questStarted = 1531, questStorage = 65021, killsRequired = 1500, raceName = "Serpents Spawn", rewards = {{enable = true, type = "teleport", values = THENOXIUSSPAWN_POSITION}, {enable = true, type = "points", values = 4}}},
    65.  
    66. [23] = {questStarted = 1532, questStorage = 65022, killsRequired = 500, raceName = "Green Djinns", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = MERIKHTHESLAUGHTERER_POSITION}}},
    67.  
    68. [24] = {questStarted = 1533, questStorage = 65023, killsRequired = 500, raceName = "Blue Djinns", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = FAHIMTHEWISE_POSITION}}},
    69.  
    70. [25] = {questStarted = 1534, questStorage = 65024, killsRequired = 3000, raceName = "Pirates1", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}, {enable = true, type = "boss", values = RANDOMPIRATEBOSS_POSITION}}},
    71.  
    72. [26] = {questStarted = 1535, questStorage = 65025, killsRequired = 3000, raceName = "Pirates2", rewards = {{enable = true, type = "exp", values = 10000}, {enable = true, type = "money", values = 5000}}},
    73.  
    74. [27] = {questStarted = 1536, questStorage = 65026, killsRequired = 5000, raceName = "Minotaurs", rewards = {{enable = true, type = "boss", values = THEHORNEDFOX_POSITION}}},
    75.  
    76. [28] = {questStarted = 1537, questStorage = 65027, killsRequired = 4000, raceName = "Magicians1", rewards = {{enable = true, type = "boss", values = NECROPHARUS_POSITION}}},
    77.  
    78. [29] = {questStarted = 1538, questStorage = 65028, killsRequired = 1000, raceName = "Magicians2", rewards = {{enable = true, type = "exp", values = 40000}}},
    79.  
    80. [30] = {questStarted = 1539, questStorage = 65029, killsRequired = 6666, raceName = "Demons", rewards = {{enable = true, type = "storage", values = {65535, 1}}}}
    81. }
    82.  
    83. local rankStorage = 32150
    84. local choose = {}
    85.  
    86. local keywordHandler = KeywordHandler:new()
    87. local npcHandler = NpcHandler:new(keywordHandler)
    88. NpcSystem.parseParameters(npcHandler)
    89. local talkState = {}
    90.  
    91. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
    92. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
    93. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
    94. function onThink() npcHandler:onThink() end
    95.  
    96. function getTasksStarted(cid)
    97. local tmp = {}
    98. for k, v in pairs(tasks) do
    99. if getCreatureStorage(cid, v.questStarted) == 1 then
    100. table.insert(tmp, k)
    101. end
    102. end
    103. return tmp
    104. end
    105.  
    106. function getTaskByName(name)
    107. for k, v in pairs(tasks) do
    108. if v.raceName:lower() == name:lower() then
    109. return k
    110. end
    111. end
    112. return false
    113. end
    114.  
    115. function creatureSayCallback(cid, type, msg)
    116.  
    117. if(not npcHandler:isFocused(cid)) then
    118. return false
    119. end
    120. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
    121. if isInArray({"task", "tasks"}, msg:lower()) then
    122. selfSay("There you can see the following tasks, please tell me the number of the task that you want to do.", cid)
    123. local text = ""
    124. for i = 1, table.maxn(tasks) do
    125. text = text .. (text == "" and "" or "\n") .. i .. " - " .. tasks.raceName .. (getCreatureStorage(cid, tasks.questStarted) == 1 and " [...]" or getCreatureStorage(cid, tasks.questStarted) == 2 and " [x]" or "")
    126. end
    127. return doShowTextDialog(cid, 5956, text)
    128.  
    129. elseif getTaskByName(msg) or tasks[tonumber(msg)] then
    130. msg = (getTaskByName(msg) or tonumber(msg))
    131. if getCreatureStorage(cid, tasks[msg].questStarted) == 1 then
    132. selfSay("You already started this task.", cid)
    133. talkState[talkUser] = 0
    134. return true
    135. end
    136. if getCreatureStorage(cid, tasks[msg].questStarted) == 2 then
    137. selfSay("You already finished this task.", cid)
    138. talkState[talkUser] = 0
    139. return true
    140. end
    141. if tasks[msg].level and getPlayerLevel(cid) < tasks[msg].level then
    142. selfSay("You need level " .. tasks[msg].level .. " or higher to make this task.", cid)
    143. talkState[talkUser] = 0
    144. return true
    145. end
    146. selfSay("Are you sure that do you want to start the task number " .. msg .. "? In this task you will need to defeat " .. tasks[msg].killsRequired .. " " .. tasks[msg].raceName .. ".", cid)
    147. choose[cid] = msg
    148. talkState[talkUser] = 1
    149. elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
    150. doCreatureSetStorage(cid, tasks[choose[cid]].questStarted, 1)
    151. selfSay("You have started the task number " .. choose[cid] .. ", remember... in this task you will need to defeat " .. tasks[choose[cid]].killsRequired .. " " .. tasks[choose[cid]].raceName .. ". Good luck!", cid)
    152. talkState[talkUser] = 0
    153. return true
    154.  
    155. elseif msg:lower() == "report" then
    156. local t = getTasksStarted(cid)
    157. local response = "You are currently making " .. (#t > 1 and "these" or "this") .. " task" .. (#t > 1 and "s" or "") .. ":\n"
    158. if table.maxn(t) > 0 then
    159. for _, tsk in ipairs(t) do
    160. if getCreatureStorage(cid, tasks[tsk].questStorage) < 0 then doCreatureSetStorage(cid, tasks[tsk].questStorage, 0) end
    161. response = response .. " Name: " .. tasks[tsk].raceName .. " Kills: " .. getCreatureStorage(cid, tasks[tsk].questStorage) .. " - " .. tasks[tsk].killsRequired .. ".\n"
    162. end
    163. response = response .. "Please say report and the name of the task that do you want to report, example: 'Report Trolls'."
    164. return selfSay(response, cid)
    165. else
    166. return selfSay("You need to start at least one task first.", cid)
    167. end
    168. elseif string.sub(msg:lower(), 0, 6) == "report" then
    169. local t = getTaskByName(string.sub(msg, 8, string.len(msg)))
    170. if not t then
    171. return selfSay("That task does not exists.", cid)
    172. end
    173.  
    174. if getCreatureStorage(cid, tasks[t].questStarted) == 2 then
    175. return selfSay("You already finished this task.", cid)
    176. end
    177.  
    178. if getCreatureStorage(cid, tasks[t].questStarted) < 1 then
    179. return selfSay("You don't have started this task.", cid)
    180. end
    181.  
    182. if tasks[t].killsRequired > getCreatureStorage(cid, tasks[t].questStorage) then
    183. return selfSay("Current " .. getCreatureStorage(cid, tasks[t].questStorage) .. " " .. tasks[t].raceName .. " killed, you need to kill " .. tasks[t].killsRequired .. ".", cid)
    184. end
    185.  
    186. for i = 1, table.maxn(tasks[t].rewards) do
    187. if(tasks[t].rewards.enable) then
    188. if isInArray({"boss", "teleport", 1}, tasks[t].rewards.type) then
    189. doTeleportThing(cid, tasks[t].rewards.values)
    190. elseif isInArray({"exp", "experience", 2}, tasks[t].rewards.type) then
    191. doPlayerAddExperience(cid, tasks[t].rewards.values)
    192. elseif isInArray({"item", 3}, tasks[t].rewards.type) then
    193. doPlayerAddItem(cid, v.rewards.values[1], tasks[t].rewards.values[2])
    194. elseif isInArray({"money", 4}, tasks[t].rewards.type) then
    195. doPlayerAddMoney(cid, tasks[t].rewards.values)
    196. elseif isInArray({"storage", "stor", 5}, tasks[t].rewards.type) then
    197. doCreatureSetStorage(cid, tasks[t].rewards.values[1], tasks[t].rewards.values[2])
    198. elseif isInArray({"points", "rank", 2}, tasks[t].rewards.type) then
    199. doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + tasks[t].rewards.values)
    200. else
    201. print("[Warning - Npc::KillingInTheNameOf] Wrong reward type: " .. (tasks[t].rewards.type or "nil") .. ", reward could not be loaded.")
    202. end
    203. end
    204. end
    205. local rank = getCreatureStorage(cid, rankStorage)
    206. selfSay("Great!... you have finished the task number " .. t .. "" .. (rank > 4 and ", you are a " or "") .. "" .. (((rank > 4 and rank < 10) and ("Huntsman") or (rank > 9 and rank < 20) and ("Ranger") or (rank > 19 and rank < 30) and ("Big Game Hunter") or (rank > 29 and rank < 50) and ("Trophy Hunter") or (rank > 49) and ("Elite Hunter")) or "") .. ". Good job.", cid)
    207. return doCreatureSetStorage(cid, tasks[t].questStarted, 2)
    208. end
    209. return true
    210. end
    211.  
    212. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    213. npcHandler:addModule(FocusModule:new())
    and i have this bug in console while talking to npc, but I don't think it connects with reward bug

    Code (Text):
    1.  
    2. [15:12:39.203] [Error - NpcScript Interface]
    3. [15:12:39.203] data/npc/scripts/killinginthenameof.lua:onCreatureSay
    4. [15:12:39.203] Description:
    5. [15:12:39.203] data/npc/scripts/killinginthenameof.lua:124: attempt to concatenate field 'raceName' (a nil value)
    6. [15:12:39.203] stack traceback:
    7. [15:12:39.203]  data/npc/scripts/killinginthenameof.lua:124: in function 'callback'
    8. [15:12:39.204]  data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
    9. [15:12:39.204]  data/npc/scripts/killinginthenameof.lua:92: in function <data/npc/scripts/killinginthenameof.lua:92>
    10.  
     
  19. hellboy

    hellboy Active Member

    Joined:
    Apr 6, 2008
    Messages:
    354
    Likes Received:
    50
    Best Answers:
    1

    Try change: (in 123 line)
    Code (Text):
    1.  
    2.        for i = 1, table.maxn(tasks) do
    3.            text = text .. (text == "" and "" or "\n") .. i .. " - " .. tasks.raceName .. (getCreatureStorage(cid, tasks.questStarted) == 1 and " [...]" or getCreatureStorage(cid, tasks.questStarted) == 2 and " [x]" or "")
    4.        end
    5.  
    To:
    Code (Text):
    1.  
    2.        for i = 1, table.maxn(tasks) do
    3.            text = text .. (text == "" and "" or "\n") .. i .. " - " .. tasks[i].raceName .. (getCreatureStorage(cid, tasks[i].questStarted) == 1 and " [...]" or getCreatureStorage(cid, tasks[i].questStarted) == 2 and " [x]" or "")
    4.        end
    5.  
     
  20. Fiodor

    Fiodor Lua & Maps

    Joined:
    Mar 14, 2009
    Messages:
    400
    Likes Received:
    10
    Best Answers:
    0
    Thanks, now that bug doesn't appear and NPC shows me list of tasks (he didn't do it before)

    But Grizzly Adams still does not give any rewards :/ Everything works fine, until this moment :/ anyone has an idea? no bugs in console, tf 0.4
     

Share This Page

Loading...