DaBOSS54320

Bully LUA: Arcrace1 Example

Apr 14th, 2016
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. function MissionSetup()
  2.   -- Get original position:
  3.   a = AreaGetVisible()
  4.   x,y,z = PlayerGetPosXYZ()
  5.  
  6.   -- Move player in front of dorm (if you do not move the player somewhere, the script will fail to start for some reason):
  7.   AreaTransitionXYZ(0,270,-110,6)
  8.  
  9.   -- Spawn allies:
  10.   local leader = gPlayer
  11.   for i,model in {102,85,146} do
  12.     local ally = PedCreateXYZ(model,270+i,-110,6)
  13.     PedSetPedToTypeAttitude(ally,13,4)
  14.     PedRecruitAlly(leader,ally)
  15.     leader = ally
  16.   end
  17.  
  18.   -- Spawn enemies:
  19.   enemies = {}
  20.   for i,model in {20,16,121} do
  21.     local enemy = PedCreateXYZ(model,270-i,-110,6)
  22.     PedSetPedToTypeAttitude(enemy,13,0)
  23.     PedAttackPlayer(enemy,1)
  24.     AddBlipForChar(enemy,0,26,1)
  25.     table.insert(enemies,enemy)
  26.   end
  27.  
  28.   -- Make Jocks and Bullies hate each other:
  29.   PedSetTypeToTypeAttitude(2,11,0)
  30.   PedSetTypeToTypeAttitude(11,2,0)
  31.  
  32.   -- Disable trouble meter:
  33.   DisablePunishmentSystem(true)
  34.  
  35.   -- Disable authority:
  36.   originalModelStatus = {}
  37.   for model = 49,52 do
  38.     originalModelStatus[model] = PedGetUniqueModelStatus(model)
  39.     PedSetUniqueModelStatus(model,-1)
  40.   end
  41. end
  42.  
  43. function MissionCleanup()
  44.   -- Return to where player originally was:
  45.   AreaTransitionXYZ(a,x,y,z)
  46.  
  47.   -- Re-enable trouble meter:
  48.   DisablePunishmentSystem(false)
  49.  
  50.   -- Restore authority:
  51.   for model,status in originalModelStatus do
  52.     PedSetUniqueModelStatus(model,status)
  53.   end
  54. end
  55.  
  56. function main()
  57.   -- Wait until all enemies are dead:
  58.   repeat
  59.     Wait(0)
  60.   until AllEnemiesDead(enemies)
  61.  
  62.   -- Succeed the mission:
  63.   MissionSucceed()
  64. end
  65.  
  66. function AllEnemiesDead(t)
  67.   -- Check if any peds in the table are still valid and not dead:
  68.   for i,ped in t do
  69.     if PedIsValid(ped) and not PedIsDead(ped) then
  70.       return false
  71.     end
  72.   end
  73.  
  74.   -- If the function did not return "false" by now, that must mean all the peds are dead, so return true:
  75.   return true
  76. end
Advertisement
Add Comment
Please, Sign In to add comment