Advertisement
Guest User

Monorail

a guest
Jan 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. --[[
  2. Name: map_train.lua
  3.  
  4.  
  5. ]]--
  6.  
  7. if true then return end
  8. if CLIENT then return end
  9.  
  10. local stops = {
  11. {
  12. pos = Vector( 12279.451172, 7430.330078, 392.031250 ),
  13. spawns = {
  14. Vector( 12282.981445, 7309.088867, 399.031250 ),
  15. Vector( 12327.520508, 7314.607910, 399.031250 ),
  16. Vector( 12367.274414, 7278.159668, 399.031250 ),
  17. Vector( 12414.791992, 7312.104492, 399.031250 ),
  18. Vector( 12404.373047, 7278.121582, 399.031250 ),
  19. Vector( 12203.083984, 7284.069336, 399.031250 ),
  20. Vector( 12167.410156, 7328.417480, 399.031250 ),
  21. Vector( 12151.473633, 7277.078613, 399.031250 ),
  22. Vector( 12138.084961, 7330.957520, 399.031250 ),
  23. }
  24. },
  25. {
  26. pos = Vector( -5538.528320, 3308.584229, 656.031250 ),
  27. spawns = {
  28. Vector( -5538.528320, 3308.584229, 656.031250 ),
  29. Vector( -5442.108398, 3187.166504, 664.031250 ),
  30. Vector( -5380.911621, 3242.598633, 664.031250 ),
  31. Vector( -5429.504883, 3245.124512, 664.031250 ),
  32. Vector( -5409.329102, 3273.158203, 664.031250 ),
  33. Vector( -5383.536621, 3302.807617, 664.031250 ),
  34. Vector( -5426.561035, 3362.220215, 664.031250 ),
  35. Vector( -5401.589844, 3382.452393, 664.031250 ),
  36. Vector( -5439.534668, 3447.569824, 664.031250 ),
  37. }
  38. },
  39. {
  40. pos = Vector( -13479.913086, -7285.834473, 560.031250 ),
  41. spawns = {
  42. Vector( -13638.456055, -7413.760742, 568.031250 ),
  43. Vector( -13595.758789, -7413.867676, 568.031250 ),
  44. Vector( -13607.132813, -7349.273926, 568.031250 ),
  45. Vector( -13636.177734, -7306.140137, 568.031250 ),
  46. Vector( -13592.278320, -7284.170410, 568.031250 ),
  47. Vector( -13640.996094, -7256.720215, 568.031250 ),
  48. Vector( -13598.691406, -7221.742676, 568.031250 ),
  49. Vector( -13644.542969, -7172.869141, 568.031250 ),
  50. Vector( -13597.893555, -7147.773926, 568.031250 ),
  51. }
  52. },
  53. }
  54.  
  55. local seatPos = {
  56. { Vector( 165.798431, -44, 19.531385 ), Angle( 0, 0, 0 ) },
  57. { Vector( 137.323044, -44, 19.531385 ), Angle( 0, 0, 0 ) },
  58. { Vector( 108.823143, -44, 19.531385 ), Angle( 0, 0, 0 ) },
  59. { Vector( 81.032211, -44, 19.531385 ), Angle( 0, 0, 0 ) },
  60. { Vector( -81.053185, -44, 19.531385 ), Angle( 0, 0, 0 ) },
  61. { Vector( -109.533569, -44, 19.531385 ), Angle( 0, 0, 0 ) },
  62. { Vector( -137.283478, -44, 19.531385 ), Angle( 0, 0, 0 ) },
  63. { Vector( -165.033401, -44, 19.531385 ), Angle( 0, 0, 0 ) },
  64.  
  65. { Vector( 165.798431, 45, 19.531385 ), Angle( 0, 180, 0 ) },
  66. { Vector( 137.323044, 45, 19.531385 ), Angle( 0, 180, 0 ) },
  67. { Vector( 108.823143, 45, 19.531385 ), Angle( 0, 180, 0 ) },
  68. { Vector( 81.032211, 45, 19.531385 ), Angle( 0, 180, 0 ) },
  69. { Vector( -81.053185, 45, 19.531385 ), Angle( 0, 180, 0 ) },
  70. { Vector( -109.533569, 45, 19.531385 ), Angle( 0, 180, 0 ) },
  71. { Vector( -137.283478, 45, 19.531385 ), Angle( 0, 180, 0 ) },
  72. { Vector( -165.033401, 45, 19.531385 ), Angle( 0, 180, 0 ) },
  73. }
  74. local parentEntName = "Monorail_Train 1"
  75. local seats = {}
  76. local trainEnt
  77.  
  78. hook.Add( "InitPostEntity", "SetupMapTrain", function()
  79. local found
  80. for k, v in pairs( ents.GetAll() ) do
  81. if v:GetName() == parentEntName then
  82. found = v
  83. break
  84. end
  85. end
  86.  
  87. if not IsValid( found ) then return end
  88. trainEnt = found
  89.  
  90. for k, v in pairs( seatPos ) do
  91. local seat = ents.Create( "prop_vehicle_prisoner_pod" )
  92. seat:SetModel( "models/nova/airboat_seat.mdl" )
  93. seat:SetPos( trainEnt:LocalToWorld(v[1]) )
  94. seat:SetAngles( trainEnt:LocalToWorldAngles(v[2]) )
  95. seat:SetKeyValue( "vehiclescript", "scripts/vehicles/prisoner_pod.txt" )
  96. seat:SetKeyValue( "limitview", "0" )
  97. seat:Spawn()
  98. seat:Activate()
  99. seat:SetParent( trainEnt )
  100. seats[#seats +1] = seat
  101. end
  102. end )
  103.  
  104. hook.Add( "PlayerUse", "PlayerUseMapTrain", function( pPlayer, eEnt )
  105. if CurTime() < (pPlayer.m_intLastTrainUse or 0) then return end
  106. pPlayer.m_intLastTrainUse = CurTime() +5
  107.  
  108. if eEnt == trainEnt and not pPlayer:InVehicle() then
  109. if eEnt:GetVelocity():Length() <= 0.1 then
  110. for k, v in pairs( seats ) do
  111. if not IsValid( v:GetDriver() ) then
  112. pPlayer:EnterVehicle( v )
  113. pPlayer:EnterVehicle( v )
  114. pPlayer.m_intEnterTrainTime = CurTime() +1
  115. print "ENTER"
  116. end
  117. end
  118. end
  119. end
  120. end )
  121.  
  122. hook.Add( "PlayerLeaveVehicle", "PlayerExitMapTrain", function( pPlayer, eEnt )
  123. if eEnt:GetParent() == trainEnt and not pPlayer:InVehicle() then
  124. if CurTime() < (pPlayer.m_intEnterTrainTime or 0) then return end
  125. print "exit car"
  126. local stop
  127. local cur = math.huge
  128. for k, v in pairs( stops ) do
  129. if v.pos < cur then
  130. stop = v
  131. end
  132. end
  133.  
  134. if stop then
  135. local spawn = GAMEMODE.Util:FindSpawnPoint( v.spawns, 34 )
  136. if not spawn then
  137. spawn, _ = table.Random( v.spawns )
  138. end
  139.  
  140. pPlayer:SetPos( spawn )
  141. end
  142. end
  143. end )
  144.  
  145. hook.Add( "CanExitVehicle", "PlayerExitMapTrain", function( eEnt, pPlayer )
  146. if eEnt == trainEnt then
  147. if CurTime() < (pPlayer.m_intEnterTrainTime or 0) then return end
  148. return eEnt:GetVelocity():Length() <= 0.1
  149. end
  150. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement