Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.39 KB | None | 0 0
  1. function onSay(cid, item, param)
  2.  
  3.     local topic = nil
  4.    
  5.     if param == "" then
  6.         doPlayerSendTextMessage(cid, 18, "Welcome to taskmanager. Here are some commands you can use to get started.\n!task monster-name, !task cancel, !task list, !task current")
  7.     end
  8.    
  9.     -- Cancel task
  10.     if param == "cancel rotworm" then
  11.         doPlayerSendTextMessage(cid, 18, "Are you sure you want to cancel this task? Say '!task yes' to confirm or '!task no' to decline.")
  12.         topic = 1
  13.     elseif topic == 1 then
  14.         if param == "yes" then
  15.             doPlayerSendTextMessage(cid, 18, "So be it. Your progress on the rotworm task has been wiped out. Do you want to start a new task?")
  16.             topic = nil
  17.         else
  18.             doPlayerSendTextMessage(cid, 18, "No? Then you will keep your progress in the rotworm task.")
  19.             topic = nil
  20.         end
  21.     if param == "cancel dragon" then
  22.         doPlayerSendTextMessage(cid, 18, "Are you sure you want to cancel this task? Say '!task yes' to confirm or '!task no' to decline.")
  23.         topic = 2
  24.     elseif topic == 2 then
  25.         if param == "yes" then
  26.             doPlayerSendTextMessage(cid, 18, "So be it. Your progress on the dragon task has been wiped out. Do you want to start a new task?")
  27.             topic = nil
  28.         else
  29.             doPlayerSendTextMessage(cid, 18, "No? Then you will keep your progress in the dragon task.")
  30.             topic = nil
  31.         end
  32.  
  33.     -- Keywords
  34.     elseif param == "monster" then
  35.         doPlayerSendTextMessage(cid, 18, "For example, say '!task rotworm' to start the rotworm task.")
  36.     elseif param == "cancel" then
  37.         doPlayerSendTextMessage(cid, 18, "For example, say '!task cancel rotworm' to cancel the rotworm task.")
  38.     elseif param == "current" or param == "progress" then
  39.         local k = getPlayerStorageValue
  40.         doPlayerSendTextMessage(cid, 18, and
  41.         k(cid, 100) >= 0 "You are currently in the rotworm task. Your progress report is: ".. 200 - k .. " killed rotworms." or
  42.         k(cid, 101) >= 0 "You are currently in the dragon task. Your progress report is: ".. 500 - k .. " killed dragons." or
  43.        
  44.         "You have not yet begun a task. Would you like to do so, you can see the avaialbe task by saying '!task list'.")
  45.     elseif param == "list" then
  46.         doShowTextDialog(cid, 1948, "Available tasks:\nRotworms [200]\nDragons [500]")
  47.    
  48.     -- Egnition from this point
  49.     -- Rotworms
  50.     elseif param == "rotworm" then
  51.         local v = getPlayerStorageValue(cid, 100)
  52.         local a = 200
  53.         if getPlayerStorageValue(cid, 200) > 0 then
  54.             if v < (a + 1) and v > 0 then
  55.                 doPlayerSendTextMessage(cid, 18, "You have killed ".. v .." ".. param ..". You have to kill ".. a - v .." more to finish the task.")
  56.             elseif v < 1 then
  57.                 doPlayerSendTextMessage(cid, 18, "".. param .." task has been started. Kill ".. a.. " ".. param .." to claim your price.")
  58.                 setPlayerStorageValue(cid, 100, 0)
  59.                 setPlayerStorageValue(cid, 200, 1)
  60.             elseif getPlayerStorageValue(cid, 100) > a then
  61.                 doPlayerSendTextMessage(cid, 18, "You have already finished this task.")
  62.             elseif getPlayerStorageValue(cid, 100) == a then
  63.                 -- Stop the killcount on 200 or on the local variable 'a'
  64.                 doPlayerSendTextMessage(cid, 18, "Congratulations! You have finished the "... param .." task.")
  65.                 doPlayerAddItem(cid, 2152, 50)
  66.                 setPlayerStorageValue(cid, 100, v + 1)
  67.             end
  68.         else
  69.             doPlayerSendTextMessage(cid, 18, "You have already taken on a task. Please finish or cancel it first.")
  70.         end
  71.     -- Dragons
  72.     elseif param == "dragon" then
  73.         local v = getPlayerStorageValue(cid, 101)
  74.         local a = 500
  75.         if getPlayerStorageValue(cid, 200) > 0 then
  76.             if v < (a + 1) and v > 0 then
  77.                 doPlayerSendTextMessage(cid, 18, "You have killed ".. v .." ".. param ..". You have to kill ".. a - v .." more to finish the task.")
  78.             elseif v < 1 then
  79.                 doPlayerSendTextMessage(cid, 18, "".. param .." task has been started. Kill ".. a.. " ".. param .." to claim your price.")
  80.                 setPlayerStorageValue(cid, 101, 0)
  81.                 setPlayerStorageValue(cid, 200, 1)
  82.             elseif getPlayerStorageValue(cid, 101) > a then
  83.                 doPlayerSendTextMessage(cid, 18, "You have already finished this task.")
  84.             elseif getPlayerStorageValue(cid, 101) == a then
  85.                 -- Stop the killcount on 500 or on the local variable 'a'
  86.                 doPlayerSendTextMessage(cid, 18, "Congratulations! You have finished the "... param .." task.")
  87.                 doPlayerAddItem(cid, 2152, 50)
  88.                 setPlayerStorageValue(cid, 101, v + 1)
  89.             end
  90.         else
  91.             doPlayerSendTextMessage(cid, 18, "You have already taken on a task. Please finish or cancel it first.")
  92.         end
  93.     end
  94.     return false
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement