Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <morecolors>
- #include <cstrike>
- #undef REQUIRE_PLUGIN
- #include <updater>
- #define PLUGIN_VERSION "1.0.9"
- #define UPDATE_URL "http://dl.dropboxusercontent.com/u/36622494/hns/hns.txt"
- #define HIDE (0x0001 | 0x0010)
- #define SHOW (0x0002)
- new Handle:g_HnsEna = INVALID_HANDLE;
- new Handle:g_HnsTime = INVALID_HANDLE;
- new Handle:g_hInformTimer = INVALID_HANDLE;
- new String:Doors[][] = {"func_door", "func_movelinear", "func_door_rotating"};
- new time_left = 0;
- public Plugin:myinfo = {
- name = "Hide 'N' Seek",
- author = "iDragon(edited by Eden.Campo)",
- description = "Hide 'N' Seek for jail servers. The T's need to find and kill the CT's",
- version = PLUGIN_VERSION,
- url = ""
- };
- public OnPluginStart()
- {
- if(LibraryExists("updater"))
- {
- Updater_AddPlugin(UPDATE_URL);
- }
- g_HnsEna = CreateConVar("sm_hns_enabled", "0", "Is Hide 'N' Seek enabled?");
- g_HnsTime = CreateConVar("sm_hns_time_to_hide", "60", "Time to blind T before starting the game");
- HookConVarChange(g_HnsEna, OnHnsStatusChanged);
- HookEvent("round_start", EventRoundStart, EventHookMode_PostNoCopy);
- RegConsoleCmd("jointeam", CommandJoinTeam);
- RegAdminCmd("sm_hns", Command_HNS, ADMFLAG_GENERIC, "Enable or Disable the mod")
- RegAdminCmd("sm_forcehnsupdate", Command_HNSUpdate, ADMFLAG_ROOT, "Updates the mod")
- AutoExecConfig(true, "HnS");
- }
- public OnPluginEnd()
- {
- if (g_hInformTimer != INVALID_HANDLE)
- KillTimer(g_hInformTimer);
- }
- public OnMapEnd()
- {
- if (g_hInformTimer != INVALID_HANDLE)
- KillTimer(g_hInformTimer);
- }
- public OnMapStart()
- {
- ServerCommand("sm_hns_enabled 0");
- }
- public OnLibraryAdded(const String:name[])
- {
- if (StrEqual(name, "updater"))
- {
- Updater_AddPlugin(UPDATE_URL);
- }
- }
- public Action:Command_HNS(client, args)
- {
- new String:int[32];
- GetCmdArg(1, int, sizeof(int));
- if (strcmp(int, "1") == 0)
- {
- ServerCommand("sm_hns_enabled %s", int);
- //CPrintToChatAll("{green}[HNS] {default}HNS is now {lightgreen}enabled{default}!");
- }
- else
- {
- if (strcmp(int, "0") == 0) {
- ServerCommand("sm_hns_enabled %s", int);
- //CPrintToChatAll("{green}[HNS] {default}HNS is now {lightgreen}disabled{default}!");
- }
- else
- CPrintToChat(client, "{green}[HNS] {default}Must be a value between 0 or 1!");
- }
- CPrintToChatAll("{green}[HNS] {default}HNS is now {lightgreen}%s{default}!", g_HnsEna? "enabled":"disabled");
- return Plugin_Handled;
- }
- public Action:Command_HNSUpdate(client, args)
- {
- Updater_ForceUpdate();
- CPrintToChatAll("{green}[HNS] {default}Forced update check on hns.smx");
- return Plugin_Continue;
- }
- public OnHnsStatusChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
- {
- if (StringToInt(newVal))
- {
- ServerCommand("mp_forcecamera 1");
- ServerCommand("sv_alltalk 0");
- ServerCommand("sm_hosties_lr 0");
- ServerCommand("mp_restartgame 3");
- }
- else
- {
- ServerCommand("mp_forcecamera 0");
- ServerCommand("sv_alltalk 1");
- ServerCommand("sm_hosties_lr 1");
- ServerCommand("mp_restartgame 1");
- }
- }
- public Action:CommandJoinTeam(client, args)
- {
- if (GetConVarInt(g_HnsEna) == 1)
- {
- new String:TeamChosen[8];
- GetCmdArg(1, TeamChosen, sizeof(TeamChosen));
- if (StrEqual(TeamChosen, "1") && (GetUserAdmin(client) == INVALID_ADMIN_ID))
- {
- CPrintToChat(client,"{green}[HNS] {default}You are not allowed to join the Spectators team while HNS is running!");
- return Plugin_Handled;
- }
- }
- return Plugin_Continue;
- }
- public Action:OnClientCommand(client, args)
- {
- if(GetConVarInt(g_HnsEna) == 1)
- {
- new String:cmd[16];
- GetCmdArg(0, cmd, sizeof(cmd));
- if (StrEqual(cmd, "sm_openall"))
- {
- CPrintToChat(client,"{green}[HNS] {default}You are not allowed to use this command while HNS is running!");
- return Plugin_Handled;
- }
- }
- return Plugin_Continue;
- }
- public EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if (GetConVarInt(g_HnsEna) == 1)
- {
- time_left = GetConVarInt(g_HnsTime);
- CPrintToChatAll("{green}[HNS] {default}CTs have %i seconds to hide!", time_left);
- if (g_hInformTimer != INVALID_HANDLE)
- {
- KillTimer(g_hInformTimer);
- g_hInformTimer = INVALID_HANDLE;
- }
- g_hInformTimer = CreateTimer(1.0, TimeLeft_Timer, _, TIMER_REPEAT);
- }
- }
- public Action:TimeLeft_Timer(Handle:timer)
- {
- if(GetConVarInt(g_HnsEna) == 1)
- {
- if(time_left == 0)
- {
- PrintCenterTextAll("Time Is UP! you may go search now for the CTs");
- PrintHintTextToAll("Time Is UP! you may go search now for the CTs");
- CPrintToChatAll("{green}[HNS] {default}Time Is UP! you may go search now for the CTs");
- FindDoors();
- for (new i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- if (GetClientTeam(i) == 2)
- {
- ScreenFade(i, 0, 0, 0, 255, 0, HIDE); // client, R,G,B,ALPHA,Duration(mili-second),type
- if (IsPlayerAlive(i))
- {
- GivePlayerItem(i, "weapon_m4a1");
- GivePlayerItem(i, "weapon_deagle");
- }
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- }
- return Plugin_Stop;
- }
- else
- {
- time_left--;
- PrintHintTextToAll("Time Left to Hide %02i:%02i", time_left / 60, time_left % 60);
- PrintCenterTextAll("Time Left to Hide %02i:%02i", time_left / 60, time_left % 60);
- for (new i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i))
- {
- if (GetClientTeam(i) == 2)
- ScreenFade(i, 0, 0, 0, 255, 2000, SHOW); //client, R,G,B,ALPHA,Duration(mili-second),type
- }
- }
- return Plugin_Continue;
- }
- }
- return Plugin_Stop; // HNS is disable, let's disable this timer too.
- }
- public Action:FindDoors()
- {
- new Entity = 0;
- for(new i = 0; i < sizeof(Doors); i++)
- while((Entity = FindEntityByClassname(Entity, Doors[i])) != -1)
- AcceptEntityInput(Entity, "Open");
- }
- //Fade the screen
- public ScreenFade(client, red, green, blue, alpha, duration, type)
- {
- new Handle:msg;
- msg = StartMessageOne("Fade", client);
- BfWriteShort(msg, 1500);
- BfWriteShort(msg, duration);
- BfWriteShort(msg, type);
- BfWriteByte(msg, red);
- BfWriteByte(msg, green);
- BfWriteByte(msg, blue);
- BfWriteByte(msg, alpha);
- EndMessage();
- }
- stock bool:IsValidClient( Client, bool:bAlive = false )
- {
- if( Client >= 1 && Client <= MaxClients && IsClientConnected( Client ) && IsClientInGame( Client ) && !IsFakeClient( Client ) && !IsClientSourceTV( Client ) && ( bAlive == false || IsPlayerAlive( Client ) ) )
- {
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement