Guest User

Untitled

a guest
May 5th, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1. -- The first argument of the function below is the ID of a mission type, it must be unique!
  2. local obj = MISSIONS.NewMissionType("example")
  3.  
  4.     -- Disable the mission type
  5.     -- As the addon is most likely loaded after all other addons,
  6.     -- you can check for specific a specific condition.
  7.     -- (Example: Does my global addon table exist?)
  8.     obj:SetDisabled(true)
  9.  
  10.     -- Set the Imgur ID of the image which will be downloaded by clients and be used.
  11.     --At the moment, other image platforms are not supported.
  12.     -- Images are loaded using a proxy so even players from Turkey should be able to see them.
  13.     obj:SetImgurIconID("nJU8Mrd")
  14.  
  15.     -- This is the string that will be displayed.
  16.     -- ":value:" will be replaced with the current (formatted!) progress.
  17.     obj:SetDescription("This is an example mission which requires :value: amount of something")
  18.  
  19.     -- obj:AddTier(progressRequired, rewardOverride)
  20.     -- Those must be kept in order!
  21.     obj:AddTier(10, 1000)
  22.     obj:AddTier(20, 5000)
  23.     obj:AddTier(30, 10000)
  24.  
  25.     -- Save the progress instantly after it changes?
  26.     obj:SetSaveOnChange(true)
  27.  
  28.     -- Instantly network progress changes to the player?
  29.     obj:SetNetworkOnChange(true)
  30.  
  31.     -- This function allows to modify the displayed value of a mission type.
  32.     obj:SetFormatFunction(function(value)
  33.         return value .. " points"
  34.     end)
  35.  
  36.     -- This function allows you to check if a player is eligible to get this specific mission assigned.
  37.     -- Return false to exclude it from a player's possible mission pool.
  38.     obj:SetEligibleFunction(function(p)
  39.         return false
  40.     end)
  41.  
  42.     -- obj:AddHook(hookName, function(self, ...))
  43.     -- "self" is the mission object, it will always be added as first argument
  44.     obj:AddHook("EntityTakeDamage", function(self, target, damageInfo)
  45.         -- example code
  46.         local mission = target:Missions():Get(self)
  47.         if (mission) then
  48.             mission:AddProgress(1)
  49.         end
  50.     end)
  51.  
  52.     -- obj:AddTimer(timerID, delay, repetitions) Check out https://wiki.facepunch.com/gmod/timer.Create
  53.     -- The first function argument will be the mission object
  54.     obj:AddTimer("SomeTimerID", 1, 0, function(self)
  55.         -- your code here
  56.     end)
  57.  
  58. -- Don't forget to register the mission at the end.
  59. obj:Register()
Add Comment
Please, Sign In to add comment