Advertisement
Guest User

_spectating - Notesblok

a guest
Nov 19th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. init()
  2. {
  3. level.spectateOverride["allies"] = spawnstruct();
  4. level.spectateOverride["axis"] = spawnstruct();
  5.  
  6. level thread onPlayerConnect();
  7. }
  8.  
  9.  
  10. onPlayerConnect()
  11. {
  12. for(;;)
  13. {
  14. level waittill( "connected", player );
  15.  
  16. player thread onJoinedTeam();
  17. player thread onJoinedSpectators();
  18. player thread onSpectatingClient();
  19. }
  20. }
  21.  
  22.  
  23. onJoinedTeam()
  24. {
  25. self endon("disconnect");
  26.  
  27. for(;;)
  28. {
  29. self waittill( "joined_team" );
  30. self setSpectatePermissions();
  31. }
  32. }
  33.  
  34.  
  35. onJoinedSpectators()
  36. {
  37. self endon("disconnect");
  38.  
  39. for(;;)
  40. {
  41. self waittill( "joined_spectators" );
  42. self setSpectatePermissions();
  43. }
  44. }
  45.  
  46.  
  47. onSpectatingClient()
  48. {
  49. self endon("disconnect");
  50.  
  51. for( ;; )
  52. {
  53. self waittill( "spectating_cycle" );
  54.  
  55. // show the card for the player we're viewing. Could be undefined if the cyling failed
  56. spectatedPlayer = self GetSpectatingPlayer();
  57. if ( isDefined( spectatedPlayer ) )
  58. {
  59. self SetCardDisplaySlot( spectatedPlayer, 6 );
  60. }
  61. }
  62. }
  63.  
  64.  
  65.  
  66. updateSpectateSettings()
  67. {
  68. level endon ( "game_ended" );
  69.  
  70. for ( index = 0; index < level.players.size; index++ )
  71. level.players[index] setSpectatePermissions();
  72. }
  73.  
  74.  
  75. getOtherTeam( team )
  76. {
  77. if ( team == "axis" )
  78. return "allies";
  79. else if ( team == "allies" )
  80. return "axis";
  81. else
  82. return "none";
  83. }
  84.  
  85.  
  86. setSpectatePermissions()
  87. {
  88. team = self.sessionteam;
  89.  
  90. if ( level.gameEnded && gettime() - level.gameEndTime >= 2000 )
  91. {
  92. self allowSpectateTeam( "allies", false );
  93. self allowSpectateTeam( "axis", false );
  94. self allowSpectateTeam( "freelook", false );
  95. self allowSpectateTeam( "none", false );
  96. return;
  97. }
  98.  
  99.  
  100. if ( team == "spectator" )
  101. {
  102. self allowSpectateTeam( "allies", true );
  103. self allowSpectateTeam( "axis", true );
  104. self allowSpectateTeam( "freelook", false );
  105. self allowSpectateTeam( "none", true );
  106. return;
  107. }
  108.  
  109.  
  110. spectateType = maps\mp\gametypes\_tweakables::getTweakableValue( "game", "spectatetype" );
  111.  
  112. switch( spectateType )
  113. {
  114. case 0: // disabled
  115. self allowSpectateTeam( "allies", false );
  116. self allowSpectateTeam( "axis", false );
  117. self allowSpectateTeam( "freelook", false );
  118. self allowSpectateTeam( "none", true );
  119.  
  120. break;
  121. case 1: // team/player only
  122. if ( !level.teamBased )
  123. {
  124. self allowSpectateTeam( "allies", true );
  125. self allowSpectateTeam( "axis", true );
  126. self allowSpectateTeam( "none", true );
  127. self allowSpectateTeam( "freelook", false );
  128. }
  129. else if ( isDefined( team ) && (team == "allies" || team == "axis") )
  130. {
  131. self allowSpectateTeam( team, true );
  132. self allowSpectateTeam( getOtherTeam( team ), false );
  133. self allowSpectateTeam( "freelook", false );
  134. self allowSpectateTeam( "none", false );
  135. }
  136. else
  137. {
  138. self allowSpectateTeam( "allies", false );
  139. self allowSpectateTeam( "axis", false );
  140. self allowSpectateTeam( "freelook", false );
  141. self allowSpectateTeam( "none", false );
  142. }
  143. break;
  144. case 2: // free
  145. self allowSpectateTeam( "allies", true );
  146. self allowSpectateTeam( "axis", true );
  147. self allowSpectateTeam( "freelook", false );
  148. self allowSpectateTeam( "none", true );
  149. break;
  150. }
  151.  
  152. if ( isDefined( team ) && (team == "axis" || team == "allies") )
  153. {
  154. if ( isdefined(level.spectateOverride[team].allowFreeSpectate) )
  155. self allowSpectateTeam( "freelook", true );
  156.  
  157. if (isdefined(level.spectateOverride[team].allowEnemySpectate))
  158. self allowSpectateTeam( getOtherTeam( team ), true );
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement