Advertisement
Guest User

Fail

a guest
Mar 10th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.85 KB | None | 0 0
  1. function GM:ShowTeam()
  2.  
  3. if ( IsValid( TeamSelectFrame ) ) then return end
  4.  
  5. -- Simple team selection box
  6. TeamSelectFrame = vgui.Create( "DPanel" )
  7. TeamSelectFrame:SetPos(0,0)
  8. TeamSelectFrame:SetSize( ScrW(), ScrH() )
  9.  
  10. end
  11.  
  12. local controls = {}
  13. if input.LookupBinding( "duck" ) then table.insert( controls, { string.upper( input.LookupBinding( "duck" ) ), ( "Ducken" ) } ) end
  14. if input.LookupBinding( "attack2" ) then table.insert( controls, { string.upper( input.LookupBinding( "attack2" ) ), ( "Attacke 2" ) } ) end
  15. if input.LookupBinding( "gm_showhelp" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showhelp" ) ), ( "Hilfe" ) } ) end
  16. if input.LookupBinding( "gm_showteam" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showteam" ) ), ( "Team Auswahl" ) } ) end
  17. if input.LookupBinding( "gm_showspare2" ) then table.insert( controls, { string.upper( input.LookupBinding( "gm_showspare2" ) ), ( "F4 :O" ) } ) end
  18.  
  19. local controlsOffsetY = 180
  20.  
  21. for _, v in pairs( controls ) do
  22. local ControlKey = vgui.Create( "DLabel", TeamSelectFrame )
  23. ControlKey:SetPos( ScrW() / 2 + 340, controlsOffsetY )
  24. ControlKey:SetSize( 80, 40 )
  25. ControlKey:SetFont("robot_smaller")
  26. ControlKey:SetText( v[1] )
  27. ControlKey:SetTextColor( clrs.lightgrey )
  28. ControlKey:SetContentAlignment( 5 )
  29. function ControlKey:Paint( w, h)
  30. draw.RoundedBox( 0, 0, 0, w, h, clrs.red )
  31. end
  32.  
  33. local ControlDesc = vgui.Create( "DLabel", TeamSelectFrame )
  34. ControlDesc:SetPos( ScrW() / 2 + 420, controlsOffsetY )
  35. ControlDesc:SetSize( 200, 40 )
  36. ControlDesc:SetFont("robot_small")
  37. ControlDesc:SetText( v[2] )
  38. ControlDesc:SetTextColor( clrs.lightgrey )
  39. ControlDesc:SetContentAlignment( 5 )
  40. function ControlDesc:Paint( w, h)
  41. draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
  42. end
  43.  
  44. controlsOffsetY = controlsOffsetY + 80
  45. end
  46.  
  47. local HeaderImage = vgui.Create("DImage", TeamSelectFrame)
  48. HeaderImage:SetSize( 285, 96 )
  49. HeaderImage:SetPos( 0, 60 )
  50. HeaderImage:SetImage( "vgui/gw/logo_main.png" )
  51. HeaderImage:CenterHorizontal()
  52.  
  53. --Hiding Button
  54. local TeamHidingPanel = vgui.Create( "DPanel", TeamSelectFrame )
  55. TeamHidingPanel:SetPos( ScrW() / 2 - 300, 180 )
  56. TeamHidingPanel:SetSize( 280, 280 )
  57. function TeamHidingPanel:Paint( w, h )
  58. draw.RoundedBox( 0, 0, 0, w, h, team.GetColor(TEAM_JACK) )
  59. end
  60.  
  61. local TeamHidingModel = vgui.Create( "DModelPanel", TeamHidingPanel )
  62. TeamHidingModel:SetSize( 280, 280 )
  63. TeamHidingModel:SetModel( "models/player/gman_high.mdl" )
  64. local seq, dur = TeamHidingModel.Entity:LookupSequence("gesture_wave")
  65. TeamHidingModel.Entity:SetSequence(seq)
  66. TeamHidingModel.Entity:SetAngles( Angle( 0, 70, 0 ) )
  67. TeamHidingModel.Entity:DrawShadow(true)
  68. timer.Simple(dur-0.2,function() if !TeamHidingModel.Entity then return end TeamHidingModel.Entity:SetSequence("idle_all_01") TeamHidingModel.Entity:SetAngles( Angle( 0, 0, 0 ) ) end)
  69. function TeamHidingModel:LayoutEntity( ent )
  70. self:RunAnimation()
  71. end
  72.  
  73. local TeamHidingButton = vgui.Create( "DButton", TeamHidingPanel )
  74. function TeamHidingButton.DoClick()
  75. if self:IsBalancedToJoin(TEAM_JACK) then
  76. self:HideTeam() RunConsoleCommand( "changeteam", TEAM_JACK )
  77. end
  78. end
  79. TeamHidingButton:SetFont( "robot_normal" )
  80. TeamHidingButton:SetTextColor( clrs.lightgrey )
  81. TeamHidingButton:SetText( ( "Team Jack" ) .. "(" .. team.NumPlayers( TEAM_JACK ) .. ")" )
  82. TeamHidingButton:SetSize( 280, 280 )
  83. function TeamHidingButton:Paint( w, h )
  84. return
  85. end
  86. function TeamHidingButton:Think()
  87. self:SetText( ( "Team Jack" ) .. "(" .. team.NumPlayers( TEAM_JACK ) .. ")" )
  88. end
  89.  
  90. --Seeking Button
  91. local TeamSeekingPanel = vgui.Create( "DPanel", TeamSelectFrame )
  92. TeamSeekingPanel:SetPos( ScrW() / 2 + 20, 180 )
  93. TeamSeekingPanel:SetSize( 280, 280 )
  94. function TeamSeekingPanel:Paint( w, h )
  95. draw.RoundedBox( 0, 0, 0, w, h, team.GetColor(TEAM_SOLUTAR) )
  96. end
  97.  
  98. local TeamSeekingModel = vgui.Create( "DModelPanel", TeamSeekingPanel )
  99. TeamSeekingModel:SetSize( 280, 280 )
  100. TeamSeekingModel:SetModel( "models/player/Police.mdl" )
  101. function TeamSeekingModel:LayoutEntity( ent )
  102. ent:SetAngles( Angle( 0, 30, 0 ) )
  103. end
  104.  
  105. local TeamSeekingButton = vgui.Create( "DButton", TeamSeekingPanel )
  106. function TeamSeekingButton.DoClick()
  107. if self:IsBalancedToJoin(TEAM_SOLUTAR) then
  108. self:HideTeam() RunConsoleCommand( "changeteam", TEAM_SOLUTAR )
  109. end
  110. end
  111. TeamSeekingButton:SetFont( "robot_normal" )
  112. TeamSeekingButton:SetTextColor( clrs.lightgrey )
  113. TeamSeekingButton:SetText( ( "Team Solutar" ) .. "(" .. team.NumPlayers( TEAM_SOLUTAR ) .. ")" )
  114. TeamSeekingButton:SetSize( 280, 280 )
  115. function TeamSeekingButton:Paint( w, h )
  116. return
  117. end
  118. function TeamSeekingButton:Think()
  119. self:SetText( ( "Team Solutar" ) .. "(" .. team.NumPlayers( TEAM_SOLUTAR ) .. ")" )
  120. end
  121.  
  122. --spectate and auto buttons
  123. local TeamSpectateButton = vgui.Create( "DButton", TeamSelectFrame )
  124. TeamSpectateButton:SetPos( ScrW() / 2 - 300, 500 )
  125. TeamSpectateButton:SetSize( 600, 40 )
  126. TeamSpectateButton:SetFont("robot_small")
  127. TeamSpectateButton:SetText( ( "Zuschauen" ) )
  128. TeamSpectateButton:SetTextColor( clrs.lightgrey )
  129. function TeamSpectateButton.DoClick() self:HideTeam() RunConsoleCommand( "changeteam", TEAM_SPECTATOR ) end
  130. function TeamSpectateButton:Paint( w, h)
  131. draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
  132. end
  133.  
  134. local TeamAutoButton = vgui.Create( "DButton", TeamSelectFrame )
  135. TeamAutoButton:SetPos( ScrW() / 2 - 300, 580 )
  136. TeamAutoButton:SetSize( 600, 40 )
  137. TeamAutoButton:SetFont("robot_small")
  138. TeamAutoButton:SetText( ( "Auto Team" ) )
  139. TeamAutoButton:SetTextColor( clrs.lightgrey )
  140. function TeamAutoButton.DoClick() self:HideTeam() RunConsoleCommand( "changeteam", team.BestAutoJoinTeam() ) end
  141. function TeamAutoButton:Paint( w, h)
  142. draw.RoundedBox( 0, 0, 0, w, h, clrs.grey )
  143. end
  144.  
  145. TeamSelectFrame:SetSize( ScrW(), ScrH() )
  146. TeamSelectFrame:Center()
  147. TeamSelectFrame:MakePopup()
  148. TeamSelectFrame:SetKeyboardInputEnabled( false )
  149.  
  150. function TeamSelectFrame:Paint(w,h)
  151. return
  152. end
  153.  
  154. function TeamSelectFrame:Think()
  155. if GAMEMODE:GetRoundState() == NAV_GEN then
  156. self:Remove()
  157. self = nil
  158. end
  159. end
  160.  
  161. local GMVersion = vgui.Create( "DLabel", TeamSelectFrame )
  162. GMVersion:SetPos( ScrW() - 400, ScrH() - 40 )
  163. GMVersion:SetSize( 400, 40 )
  164. GMVersion:SetFont("robot_medium")
  165. GMVersion:SetText( "Version " .. GAMEMODE.Version )
  166. GMVersion:SetTextColor( clrs.lightgrey )
  167. GMVersion:SetContentAlignment( 6 )
  168. function GMVersion:Paint( w, h)
  169. return
  170. end
  171.  
  172.  
  173.  
  174. function GM:IsBalancedToJoin( teamid )
  175.  
  176. if LocalPlayer():Team() == teamid then return true end
  177.  
  178. if teamid == TEAM_SOLUTAR then
  179. if team.NumPlayers( TEAM_SOLUTAR ) > team.NumPlayers( TEAM_JACK ) or (LocalPlayer():Team() == TEAM_JACK && team.NumPlayers( TEAM_SOLUTAR ) == team.NumPlayers( TEAM_JACK )) then
  180. return false
  181. end
  182. elseif teamid == TEAM_JACK then
  183. if team.NumPlayers( TEAM_JACK ) > team.NumPlayers( TEAM_SOLUTAR ) or (LocalPlayer():Team() == TEAM_SOLUTAR && team.NumPlayers( TEAM_SOLUTAR) == team.NumPlayers( TEAM_JACK )) then
  184. return false
  185. end
  186. end
  187. return true
  188. end
  189.  
  190. function GM:HideTeam()
  191.  
  192. if ( IsValid(TeamSelectFrame) ) then
  193. TeamSelectFrame:Remove()
  194. TeamSelectFrame = nil
  195. end
  196. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement