Guest User

SetObjectivesForPlayers

a guest
Jun 29th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.13 KB | None | 0 0
  1. -- Okay its a bit more than i thought first hehe
  2.  
  3. -- These 2 variables can be put somewhere but at best in no function
  4. T1LooseCounter = 0
  5. T2LooseCounter = 0
  6.  
  7. -- A new function put it somewhere ( you can also put the soviet and allies call in if you want to )
  8. SetupPlayers = function()
  9.     Multi0 = Player.GetPlayer("Multi0")
  10.     if Multi0 ~= nil then
  11.         WinTheGame1 = Multi0.AddPrimaryObjective("Kill all enemys!")
  12.     else
  13.         T1LooseCounter = T1LooseCounter +1
  14.     end
  15.     Multi1 = Player.GetPlayer("Multi1")
  16.     if Multi1 ~= nil then
  17.         WinTheGame2 = Multi1.AddPrimaryObjective("Kill all enemys!")
  18.     else
  19.         T1LooseCounter = T1LooseCounter +1
  20.     end
  21.     Multi2 = Player.GetPlayer("Multi2")
  22.     if Multi2 ~= nil then
  23.         WinTheGame3 = Multi2.AddPrimaryObjective("Kill all enemys!")
  24.     else
  25.         T1LooseCounter = T1LooseCounter +1
  26.     end
  27.     Multi3 = Player.GetPlayer("Multi3")
  28.     if Multi3 ~= nil then
  29.         WinTheGame4 = Multi3.AddPrimaryObjective("Kill all enemys!")
  30.     else
  31.         T2LooseCounter = T2LooseCounter +1
  32.     end
  33.     Multi4 = Player.GetPlayer("Multi4")
  34.     if Multi4 ~= nil then
  35.         WinTheGame5 = Multi4.AddPrimaryObjective("Kill all enemys!")
  36.     else
  37.         T2LooseCounter = T2LooseCounter +1
  38.     end
  39.     Multi5 = Player.GetPlayer("Multi5")
  40.     if Multi5 ~= nil then
  41.         WinTheGame6 = Multi5.AddPrimaryObjective("Kill all enemys!")
  42.     else
  43.         T2LooseCounter = T2LooseCounter +1
  44.     end
  45. end
  46.  
  47. -- Just add this to your Worldloaded = function()  at best at the top
  48.  
  49.     SetupPlayers()
  50.    
  51.  
  52.  
  53. -- Just add this to your Tick = function()
  54.  
  55.     if Multi0 ~= nil and Multi0.HasNoRequiredUnits() and not P1Lost then
  56.         P1Lost = true
  57.         Multi0.MarkFailedObjective(WinTheGame1)
  58.         T1LooseCounter = T1LooseCounter +1
  59.     end
  60.     if Multi1 ~= nil and Multi1.HasNoRequiredUnits() and not P2Lost then
  61.         P2Lost = true
  62.         Multi1.MarkFailedObjective(WinTheGame2)
  63.         T1LooseCounter = T1LooseCounter +1
  64.     end
  65.     if Multi2 ~= nil and Multi2.HasNoRequiredUnits() and not P3Lost then
  66.         P3Lost = true
  67.         Multi2.MarkFailedObjective(WinTheGame3)
  68.         T1LooseCounter = T1LooseCounter +1
  69.     end
  70.     if Multi3 ~= nil and Multi3.HasNoRequiredUnits() and not P4Lost then
  71.         P4Lost = true
  72.         Multi3.MarkFailedObjective(WinTheGame4)
  73.         T2LooseCounter = T2LooseCounter +1
  74.     end
  75.     if Multi4 ~= nil and Multi4.HasNoRequiredUnits() and not P5Lost then
  76.         P5Lost = true
  77.         Multi4.MarkFailedObjective(WinTheGame5)
  78.         T2LooseCounter = T2LooseCounter +1
  79.     end
  80.     if Multi5 ~= nil and Multi5.HasNoRequiredUnits() and not P6Lost then
  81.         P5Lost = true
  82.         Multi5.MarkFailedObjective(WinTheGame6)
  83.         T2LooseCounter = T2LooseCounter +1
  84.     end
  85.     if T1LooseCounter == 3 then
  86.         Team2Won()
  87.     end
  88.     if T2LooseCounter == 3 then
  89.         Team1Won()
  90.     end
  91.  
  92. -- 2 seperate functions stand alone like SetupPlayers
  93. Team2Won = function()
  94.     if not P4Lost then
  95.         Multi3.MarkCompletedObjective(WinTheGame4)
  96.     end
  97.     if not P5Lost then
  98.         Multi4.MarkCompletedObjective(WinTheGame5)
  99.     end
  100.     if not P6Lost then
  101.         Multi5.MarkCompletedObjective(WinTheGame6)
  102.     end
  103. end
  104.  
  105. Team1Won = function()
  106.     if not P1Lost then
  107.         Multi0.MarkCompletedObjective(WinTheGame1)
  108.     end
  109.     if not P2Lost then
  110.         Multi1.MarkCompletedObjective(WinTheGame2)
  111.     end
  112.     if not P3Lost then
  113.         Multi2.MarkCompletedObjective(WinTheGame3)
  114.     end
  115. end
Add Comment
Please, Sign In to add comment