Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 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", true );
  96. return;
  97. }
  98.  
  99. spectateType = maps\mp\gametypes\_tweakables::getTweakableValue( "game", "spectatetype" );
  100.  
  101. switch( spectateType )
  102. {
  103. case 0: // disabled
  104. self allowSpectateTeam( "allies", false );
  105. self allowSpectateTeam( "axis", false );
  106. self allowSpectateTeam( "freelook", false );
  107. self allowSpectateTeam( "none", false );
  108.  
  109. break;
  110. case 1: // team/player only
  111. if ( !level.teamBased )
  112. {
  113. self allowSpectateTeam( "allies", true );
  114. self allowSpectateTeam( "axis", true );
  115. self allowSpectateTeam( "none", true );
  116. self allowSpectateTeam( "freelook", false );
  117. }
  118. else if ( isDefined( team ) && (team == "allies" || team == "axis") )
  119. {
  120. self allowSpectateTeam( team, true );
  121. self allowSpectateTeam( getOtherTeam( team ), false );
  122. self allowSpectateTeam( "freelook", false );
  123. self allowSpectateTeam( "none", false );
  124. }
  125. else
  126. {
  127. self allowSpectateTeam( "allies", false );
  128. self allowSpectateTeam( "axis", false );
  129. self allowSpectateTeam( "freelook", false );
  130. self allowSpectateTeam( "none", false );
  131. }
  132. break;
  133. case 2: // free
  134. self allowSpectateTeam( "allies", true );
  135. self allowSpectateTeam( "axis", true );
  136. self allowSpectateTeam( "freelook", true );
  137. self allowSpectateTeam( "none", true );
  138. break;
  139. }
  140.  
  141. if ( isDefined( team ) && (team == "axis" || team == "allies") )
  142. {
  143. if ( isdefined(level.spectateOverride[team].allowFreeSpectate) )
  144. self allowSpectateTeam( "freelook", true );
  145.  
  146. if (isdefined(level.spectateOverride[team].allowEnemySpectate))
  147. self allowSpectateTeam( getOtherTeam( team ), true );
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement