Advertisement
Guest User

Rush Plugin

a guest
Jul 30th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1.  
  2. #include <sourcemod>
  3. #include <cstrike>
  4. #include <sdktools>
  5. #include <sdktools_functions>
  6.  
  7. new CTs
  8. new Ts
  9. new equal
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. public Plugin myinfo =
  17. {
  18. name = "TeamRushAnnouncer",
  19. author = "ichi",
  20. description = "Announces Team to Rush",
  21. version = "1.0",
  22. url = "http://www.sourcemod.net/"
  23. }
  24.  
  25.  
  26. public void OnPluginStart()
  27. {
  28.  
  29. HookEvent("round_start" , RoundStart , EventHookMode_PostNoCopy)
  30. HookEvent("player_death" , Event_PlayerDeath , EventHookMode_PostNoCopy )
  31. HookEvent("player_disconnect" , Event_PlayerDisconnect , EventHookMode_PostNoCopy )
  32. RegConsoleCmd("sm_rush", Command_SmRush, " Tell which Team should Rush")
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39. public RoundStart(Handle:event, const String:name[], bool:dontBroadcast )
  40. {
  41. UpdatePlayerCounts()
  42. Ts = 0
  43. CTs = 0
  44. equal = 0
  45. CreateTimer(1.0 , UpdatePlayerCountsTimer)
  46.  
  47. }
  48.  
  49.  
  50.  
  51.  
  52. public Event_PlayerDeath (Handle:event, const String:name[], bool:dontBroadcast)
  53. {
  54. UpdatePlayerCounts()
  55. }
  56.  
  57. public Event_PlayerDisconnect (Handle:event, const String:name[], bool:dontBroadcast)
  58. {
  59. UpdatePlayerCounts()
  60. }
  61.  
  62.  
  63.  
  64. public Action:RoundStartTimer(Handle:timer)
  65. {
  66. UpdatePlayerCounts()
  67. CreateTimer(0.1 , UpdatePlayerCountsTimer)
  68. }
  69.  
  70. public Action:UpdatePlayerCountsTimer(Handle:timer)
  71.  
  72. {
  73. CreateTimer(0.1 , UpdatePlayerCountsTimer)
  74. UpdatePlayerCounts()
  75. }
  76.  
  77.  
  78.  
  79.  
  80. public Action:Command_SmRush(client, args)
  81. {
  82.  
  83. CreateTimer(0.1, Rush)
  84.  
  85. }
  86.  
  87. public Action:Rush(Handle:timer)
  88. {
  89. if (Ts != CTs)
  90. {
  91. if (Ts < CTs)
  92. {
  93. PrintToChatAll("Counter-Terrorist Rush")
  94. }
  95.  
  96.  
  97.  
  98. else if (Ts > CTs)
  99. {
  100.  
  101. {
  102. PrintToChatAll("Terrorist Rush")
  103. }
  104. }
  105. }
  106. else if (Ts == CTs)
  107. {
  108. if (equal == 1)
  109. {
  110. PrintToChatAll("Terrorist Rush")
  111. }
  112. else if (equal == 2)
  113. {
  114. PrintToChatAll("Counter-Terrorist Rush")
  115. }
  116. else if (euqal == 0)
  117. {
  118. PrintToChatAll("Equal Teams ")
  119. }
  120.  
  121. }
  122.  
  123.  
  124. }
  125.  
  126.  
  127. UpdatePlayerCounts()
  128. {
  129. Ts = 0
  130. CTs = 0
  131. for(new i = 1; i <= MaxClients; i++)
  132. {
  133. if (IsClientInGame(i) && IsPlayerAlive(i))
  134. {
  135. if (GetClientTeam(i) == 2)
  136. {
  137.  
  138. Ts++
  139.  
  140.  
  141.  
  142. }
  143. else if (GetClientTeam(i) == 3)
  144. {
  145. CTs++
  146.  
  147. }
  148.  
  149. }
  150. }
  151. {
  152. if (Ts != CTs)
  153. {
  154. if (Ts < CTs)
  155. {
  156. equal = 2
  157. }
  158. else if (Ts > CTs)
  159. {
  160. equal = 1
  161. }
  162. }
  163. }
  164.  
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement