Advertisement
xNos

Untitled

Apr 15th, 2013
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <morecolors>
  4. #include <cstrike>
  5. #undef REQUIRE_PLUGIN
  6. #include <updater>
  7.  
  8. #define PLUGIN_VERSION "1.0.9"
  9. #define UPDATE_URL "http://dl.dropboxusercontent.com/u/36622494/hns/hns.txt"
  10.  
  11. #define HIDE (0x0001 | 0x0010)
  12. #define SHOW (0x0002)
  13.  
  14. new Handle:g_HnsEna = INVALID_HANDLE;
  15. new Handle:g_HnsTime = INVALID_HANDLE;
  16. new Handle:g_hInformTimer = INVALID_HANDLE;
  17.  
  18. new String:Doors[][] = {"func_door", "func_movelinear", "func_door_rotating"};
  19.  
  20. new time_left = 0;
  21.  
  22. public Plugin:myinfo = {
  23. name = "Hide 'N' Seek",
  24. author = "iDragon(edited by Eden.Campo)",
  25. description = "Hide 'N' Seek for jail servers. The T's need to find and kill the CT's",
  26. version = PLUGIN_VERSION,
  27. url = ""
  28. };
  29.  
  30. public OnPluginStart()
  31. {
  32. if(LibraryExists("updater"))
  33. {
  34. Updater_AddPlugin(UPDATE_URL);
  35. }
  36.  
  37. g_HnsEna = CreateConVar("sm_hns_enabled", "0", "Is Hide 'N' Seek enabled?");
  38. g_HnsTime = CreateConVar("sm_hns_time_to_hide", "60", "Time to blind T before starting the game");
  39.  
  40. HookConVarChange(g_HnsEna, OnHnsStatusChanged);
  41.  
  42. HookEvent("round_start", EventRoundStart, EventHookMode_PostNoCopy);
  43.  
  44. RegConsoleCmd("jointeam", CommandJoinTeam);
  45.  
  46. RegAdminCmd("sm_hns", Command_HNS, ADMFLAG_GENERIC, "Enable or Disable the mod")
  47. RegAdminCmd("sm_forcehnsupdate", Command_HNSUpdate, ADMFLAG_ROOT, "Updates the mod")
  48.  
  49. AutoExecConfig(true, "HnS");
  50. }
  51.  
  52. public OnPluginEnd()
  53. {
  54. if (g_hInformTimer != INVALID_HANDLE)
  55. KillTimer(g_hInformTimer);
  56. }
  57.  
  58. public OnMapEnd()
  59. {
  60. if (g_hInformTimer != INVALID_HANDLE)
  61. KillTimer(g_hInformTimer);
  62. }
  63.  
  64. public OnMapStart()
  65. {
  66. ServerCommand("sm_hns_enabled 0");
  67. }
  68.  
  69. public OnLibraryAdded(const String:name[])
  70. {
  71. if (StrEqual(name, "updater"))
  72. {
  73. Updater_AddPlugin(UPDATE_URL);
  74. }
  75. }
  76.  
  77. public Action:Command_HNS(client, args)
  78. {
  79. new String:int[32];
  80. GetCmdArg(1, int, sizeof(int));
  81. if (strcmp(int, "1") == 0)
  82. {
  83. ServerCommand("sm_hns_enabled %s", int);
  84. //CPrintToChatAll("{green}[HNS] {default}HNS is now {lightgreen}enabled{default}!");
  85. }
  86. else
  87. {
  88. if (strcmp(int, "0") == 0) {
  89. ServerCommand("sm_hns_enabled %s", int);
  90. //CPrintToChatAll("{green}[HNS] {default}HNS is now {lightgreen}disabled{default}!");
  91. }
  92. else
  93. CPrintToChat(client, "{green}[HNS] {default}Must be a value between 0 or 1!");
  94. }
  95. CPrintToChatAll("{green}[HNS] {default}HNS is now {lightgreen}%s{default}!", g_HnsEna? "enabled":"disabled");
  96. return Plugin_Handled;
  97. }
  98.  
  99. public Action:Command_HNSUpdate(client, args)
  100. {
  101. Updater_ForceUpdate();
  102. CPrintToChatAll("{green}[HNS] {default}Forced update check on hns.smx");
  103. return Plugin_Continue;
  104. }
  105.  
  106. public OnHnsStatusChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
  107. {
  108. if (StringToInt(newVal))
  109. {
  110. ServerCommand("mp_forcecamera 1");
  111. ServerCommand("sv_alltalk 0");
  112. ServerCommand("sm_hosties_lr 0");
  113. ServerCommand("mp_restartgame 3");
  114. }
  115. else
  116. {
  117. ServerCommand("mp_forcecamera 0");
  118. ServerCommand("sv_alltalk 1");
  119. ServerCommand("sm_hosties_lr 1");
  120. ServerCommand("mp_restartgame 1");
  121. }
  122. }
  123.  
  124. public Action:CommandJoinTeam(client, args)
  125. {
  126. if (GetConVarInt(g_HnsEna) == 1)
  127. {
  128. new String:TeamChosen[8];
  129. GetCmdArg(1, TeamChosen, sizeof(TeamChosen));
  130.  
  131. if (StrEqual(TeamChosen, "1") && (GetUserAdmin(client) == INVALID_ADMIN_ID))
  132. {
  133. CPrintToChat(client,"{green}[HNS] {default}You are not allowed to join the Spectators team while HNS is running!");
  134. return Plugin_Handled;
  135. }
  136. }
  137. return Plugin_Continue;
  138. }
  139.  
  140. public Action:OnClientCommand(client, args)
  141. {
  142. if(GetConVarInt(g_HnsEna) == 1)
  143. {
  144. new String:cmd[16];
  145. GetCmdArg(0, cmd, sizeof(cmd));
  146.  
  147. if (StrEqual(cmd, "sm_openall"))
  148. {
  149. CPrintToChat(client,"{green}[HNS] {default}You are not allowed to use this command while HNS is running!");
  150. return Plugin_Handled;
  151. }
  152. }
  153. return Plugin_Continue;
  154. }
  155.  
  156. public EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  157. {
  158. if (GetConVarInt(g_HnsEna) == 1)
  159. {
  160. time_left = GetConVarInt(g_HnsTime);
  161. CPrintToChatAll("{green}[HNS] {default}CTs have %i seconds to hide!", time_left);
  162. if (g_hInformTimer != INVALID_HANDLE)
  163. {
  164. KillTimer(g_hInformTimer);
  165. g_hInformTimer = INVALID_HANDLE;
  166. }
  167. g_hInformTimer = CreateTimer(1.0, TimeLeft_Timer, _, TIMER_REPEAT);
  168. }
  169. }
  170.  
  171. public Action:TimeLeft_Timer(Handle:timer)
  172. {
  173. if(GetConVarInt(g_HnsEna) == 1)
  174. {
  175. if(time_left == 0)
  176. {
  177. PrintCenterTextAll("Time Is UP! you may go search now for the CTs");
  178. PrintHintTextToAll("Time Is UP! you may go search now for the CTs");
  179. CPrintToChatAll("{green}[HNS] {default}Time Is UP! you may go search now for the CTs");
  180. FindDoors();
  181. for (new i = 1; i <= MaxClients; i++)
  182. {
  183. if (IsValidClient(i))
  184. {
  185. if (GetClientTeam(i) == 2)
  186. {
  187. ScreenFade(i, 0, 0, 0, 255, 0, HIDE); // client, R,G,B,ALPHA,Duration(mili-second),type
  188. if (IsPlayerAlive(i))
  189. {
  190. GivePlayerItem(i, "weapon_m4a1");
  191. GivePlayerItem(i, "weapon_deagle");
  192. }
  193. return Plugin_Handled;
  194. }
  195. return Plugin_Continue;
  196. }
  197. }
  198. return Plugin_Stop;
  199. }
  200. else
  201. {
  202. time_left--;
  203. PrintHintTextToAll("Time Left to Hide %02i:%02i", time_left / 60, time_left % 60);
  204. PrintCenterTextAll("Time Left to Hide %02i:%02i", time_left / 60, time_left % 60);
  205. for (new i = 1; i <= MaxClients; i++)
  206. {
  207. if (IsValidClient(i))
  208. {
  209. if (GetClientTeam(i) == 2)
  210. ScreenFade(i, 0, 0, 0, 255, 2000, SHOW); //client, R,G,B,ALPHA,Duration(mili-second),type
  211. }
  212. }
  213. return Plugin_Continue;
  214. }
  215. }
  216. return Plugin_Stop; // HNS is disable, let's disable this timer too.
  217. }
  218.  
  219.  
  220. public Action:FindDoors()
  221. {
  222. new Entity = 0;
  223. for(new i = 0; i < sizeof(Doors); i++)
  224. while((Entity = FindEntityByClassname(Entity, Doors[i])) != -1)
  225. AcceptEntityInput(Entity, "Open");
  226. }
  227.  
  228. //Fade the screen
  229. public ScreenFade(client, red, green, blue, alpha, duration, type)
  230. {
  231. new Handle:msg;
  232.  
  233. msg = StartMessageOne("Fade", client);
  234. BfWriteShort(msg, 1500);
  235. BfWriteShort(msg, duration);
  236. BfWriteShort(msg, type);
  237. BfWriteByte(msg, red);
  238. BfWriteByte(msg, green);
  239. BfWriteByte(msg, blue);
  240. BfWriteByte(msg, alpha);
  241. EndMessage();
  242. }
  243. stock bool:IsValidClient( Client, bool:bAlive = false )
  244. {
  245. if( Client >= 1 && Client <= MaxClients && IsClientConnected( Client ) && IsClientInGame( Client ) && !IsFakeClient( Client ) && !IsClientSourceTV( Client ) && ( bAlive == false || IsPlayerAlive( Client ) ) )
  246. {
  247. return true;
  248. }
  249.  
  250. return false;
  251. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement