Advertisement
Guest User

CS:S Hit N Run by Shavit

a guest
Jun 10th, 2013
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 16.65 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <cstrike>
  4. #include <sdkhooks>
  5. #include <morecolors>
  6. #include <smlib>
  7.  
  8. #undef REQUIRE_EXTENSIONS
  9. #include <steamtools>
  10.  
  11. #pragma semicolon 1
  12.  
  13. new String:PREFIX[] = "{cyan}[Hit N Run]{default}";
  14. new String:gS_Music[][] = {"clock_sound.mp3", "infected2.wav", "loser.wav", "winsound1.mp3", "winsound2.mp3", "winsound3.mp3", "winsound4.mp3", "winsound5.mp3", "winsound6.mp3", "winsound7.mp3"};
  15.  
  16. new Handle:gH_Restart_Timer = INVALID_HANDLE;
  17. new Handle:gH_Infection_Timer = INVALID_HANDLE;
  18. new Handle:gH_Infection_Timer2 = INVALID_HANDLE;
  19. new Handle:gH_Enabled = INVALID_HANDLE;
  20. new bool:gB_Enabled;
  21. new gI_Offset_Ammo = -1;
  22. new gI_Infected = -1;
  23. new gI_HaloSprite = -1;
  24. new gI_BeamSprite = -1;
  25. new bool:gB_Allow_Respawn;
  26. new bool:gB_Someone_Won;
  27.  
  28. public Plugin:myinfo =
  29. {
  30.     name = "Hit N Run",
  31.     author = "ml/shavit & Hyuna (Roy) for sounds",
  32.     description = "Hit N Run plugin for CS:S.",
  33.     version = "1.0.2",
  34.     url = "-none-"
  35. }
  36.  
  37. public OnPluginStart()
  38. {
  39.     AddCommandListener(Command_Block, "explode");
  40.     AddCommandListener(Command_Block, "jointeam");
  41.     AddCommandListener(Command_Block, "kill");
  42.     AddCommandListener(Command_Block, "drop");
  43.     AddCommandListener(Command_Block, "buy");
  44.     AddCommandListener(Command_Block, "rebuy");
  45.     AddCommandListener(Command_Block, "autobuy");
  46.    
  47.     AddCommandListener(Command_Jointeam, "jointeam");
  48.    
  49.     gH_Enabled = CreateConVar("sm_hitnrun_enabled", "1", "Hit N Run is enabled?", FCVAR_PLUGIN|FCVAR_NOTIFY, true, 0.0, true, 1.0);
  50.     gB_Enabled = GetConVarBool(gH_Enabled);
  51.    
  52.     HookConVarChange(gH_Enabled, OnConVarChanged);
  53.    
  54.     if(gB_Enabled)
  55.     {
  56.         SetConVarString(FindConVar("mp_humanteam"), "T");
  57.         SetConVarInt(FindConVar("mp_friendlyfire"), 1);
  58.         SetConVarInt(FindConVar("mp_limitteams"), 0);
  59.         SetConVarInt(FindConVar("sv_ignoregrenaderadio"), 1);
  60.     }
  61.    
  62.     else
  63.     {
  64.         SetConVarString(FindConVar("mp_humanteam"), "any");
  65.         SetConVarInt(FindConVar("mp_friendlyfire"), 0);
  66.         SetConVarInt(FindConVar("sv_ignoregrenaderadio"), 0);
  67.     }
  68.    
  69.     RegAdminCmd("sm_reload_hnr", Command_Reload, ADMFLAG_GENERIC, "Reload Hit N Run");
  70.    
  71.     HookEvent("player_spawn", Player_Spawn);
  72.     HookEvent("weapon_fire", Weapon_Fire);
  73.     HookEvent("round_start", Round_Start, EventHookMode_Pre);
  74.    
  75.     for(new i = 1; i <= MaxClients; i++)
  76.     {
  77.         if(IsValidClient(i))
  78.         {
  79.             OnClientPutInServer(i);
  80.         }
  81.     }
  82.    
  83.     gI_Offset_Ammo = FindSendPropInfo("CCSPlayer", "m_iAmmo");
  84.    
  85.     if(gI_Offset_Ammo == -1)
  86.     {
  87.         SetFailState("Unable to find offset for ammo.");
  88.     }
  89.    
  90.     CreateTimer(0.25, Timer_Beacon, INVALID_HANDLE, TIMER_REPEAT);
  91.     CreateTimer(10.0, Timer_Restart, INVALID_HANDLE, TIMER_REPEAT);
  92.    
  93.     gB_Allow_Respawn = true;
  94.     gB_Someone_Won = false;
  95. }
  96.  
  97. public OnMapStart()
  98. {
  99.     gI_BeamSprite = PrecacheModel("materials/sprites/laserbeam.vmt", true);
  100.     gI_HaloSprite = PrecacheModel("materials/sprites/glow01.vmt", true);
  101.    
  102.     decl String:File[128];
  103.    
  104.     for(new i; i < sizeof(gS_Music); i++)
  105.     {
  106.         Format(File, 128, "hit_n_run/%s", gS_Music[i]);
  107.         PrecacheSound(File, true);
  108.        
  109.         Format(File, 128, "sound/%s", File);
  110.         AddFileToDownloadsTable(File);
  111.     }
  112.    
  113.     gH_Infection_Timer = INVALID_HANDLE;
  114.     gH_Infection_Timer2 = INVALID_HANDLE;
  115. }
  116.  
  117. public OnConVarChanged(Handle:ConVar, const String:OldVal[], const String:NewVal[])
  118. {
  119.     if(ConVar == gH_Enabled)
  120.     {
  121.         gB_Enabled = bool:StringToInt(NewVal);
  122.        
  123.         if(gB_Enabled)
  124.         {
  125.             SetConVarString(FindConVar("mp_humanteam"), "T");
  126.             SetConVarInt(FindConVar("mp_friendlyfire"), 1);
  127.             SetConVarInt(FindConVar("mp_limitteams"), 0);
  128.             SetConVarInt(FindConVar("sv_ignoregrenaderadio"), 1);
  129.         }
  130.        
  131.         else
  132.         {
  133.             SetConVarString(FindConVar("mp_humanteam"), "any");
  134.             SetConVarInt(FindConVar("mp_friendlyfire"), 0);
  135.             SetConVarInt(FindConVar("sv_ignoregrenaderadio"), 0);
  136.         }
  137.     }
  138. }
  139.  
  140. public Action:Command_Reload(client, args)
  141. {
  142.     ServerCommand("sm plugins reload hitnrun");
  143.    
  144.     return Plugin_Handled;
  145. }
  146.  
  147. public Action:OnPlayerRunCmd(client, &buttons)
  148. {
  149.     if(!IsValidClient(client, true) || !gB_Enabled)
  150.     {
  151.         return Plugin_Continue;
  152.     }
  153.    
  154.     decl String:weapon[32];
  155.     GetClientWeapon(client, weapon, 32);
  156.    
  157.     if(buttons & IN_ATTACK)
  158.     {
  159.         if(!(StrEqual(weapon, "weapon_knife") || StrEqual(weapon, "weapon_scout") || StrContains(weapon, "gren") != -1 || StrContains(weapon, "smoke") != -1 || StrContains(weapon, "flash") != -1))
  160.         {
  161.             buttons &= ~IN_ATTACK;
  162.            
  163.             return Plugin_Changed;
  164.         }
  165.     }
  166.    
  167.     return Plugin_Continue;
  168. }
  169.  
  170. public OnClientDisconnect(client)
  171. {
  172.     if(gI_Infected == client)
  173.     {
  174.         if(!gB_Someone_Won)
  175.         {
  176.             if(gH_Infection_Timer != INVALID_HANDLE)
  177.             {
  178.                 CloseHandle(gH_Infection_Timer);
  179.                
  180.                 gH_Infection_Timer = INVALID_HANDLE;
  181.             }
  182.            
  183.             Kill_Infection(INVALID_HANDLE);
  184.            
  185.             gH_Infection_Timer = CreateTimer(20.0, Kill_Infection, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  186.         }
  187.     }
  188. }
  189.  
  190. public OnClientPutInServer(client)
  191. {
  192.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  193.     SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  194.     SDKHook(client, SDKHook_ThinkPost, ThinkPost);
  195. }
  196.  
  197. public ThinkPost(client)
  198. {
  199.     if(IsValidClient(client, true))
  200.     {
  201.         SetEntProp(client, Prop_Send, "m_bSpotted", 0);
  202.     }
  203. }
  204.  
  205. public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
  206. {
  207.     if(!gB_Enabled)
  208.     {
  209.         return Plugin_Continue;
  210.     }
  211.    
  212.     if(attacker == gI_Infected && victim != gI_Infected)
  213.     {
  214.         SetEntityRenderMode(attacker, RENDER_NORMAL);
  215.         SetEntityRenderColor(attacker);
  216.        
  217.         gI_Infected = victim;
  218.        
  219.         SetEntityRenderMode(victim, RENDER_TRANSALPHA);
  220.         SetEntityRenderColor(victim, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
  221.        
  222.         CPrintToChatAllEx(victim, "%s {teamcolor}%N{default} has infected {teamcolor}%N{default}.", PREFIX, attacker, victim);
  223.        
  224.         EmitSoundToClient(victim, "hit_n_run/infected2.wav");
  225.     }
  226.    
  227.     return Plugin_Handled;
  228. }
  229.  
  230. public Action:Command_Block(client, const String:command[], args)
  231. {
  232.     if(StrEqual(command, "jointeam"))
  233.     {
  234.         if(IsValidClient(client) && GetClientTeam(client) != CS_TEAM_T)
  235.         {
  236.             return Plugin_Continue;
  237.         }
  238.     }
  239.    
  240.     if(gB_Enabled)
  241.     {
  242.         return Plugin_Handled;
  243.     }
  244.    
  245.     if(StrEqual(command, "kill") || StrEqual(command, "explode"))
  246.     {
  247.         if(!IsValidClient(client) || GetClientTeam(client) != CS_TEAM_T)
  248.         {
  249.             return Plugin_Handled;
  250.         }
  251.     }
  252.    
  253.     return Plugin_Continue;
  254. }
  255.  
  256. public Action:WeaponCanUse(client, weapon)
  257. {
  258.     if(gB_Enabled)
  259.     {
  260.         decl String:Weapon[32];
  261.         GetEntityClassname(weapon, Weapon, 32);
  262.        
  263.         if(!(StrEqual(Weapon, "weapon_knife") || StrEqual(Weapon, "weapon_scout") || StrContains(Weapon, "gren") != -1 || StrContains(Weapon, "smoke") != -1 || StrContains(Weapon, "flash") != -1))
  264.         {
  265.             return Plugin_Handled;
  266.         }
  267.     }
  268.    
  269.     return Plugin_Continue;
  270. }
  271.  
  272. public Action:Player_Spawn(Handle:Event, const String:Name[], bool:DontBroadcast)
  273. {
  274.     if(!gB_Enabled)
  275.     {
  276.         return Plugin_Continue;
  277.     }
  278.    
  279.     new client = GetClientOfUserId(GetEventInt(Event, "userid"));
  280.    
  281.     if(!IsValidClient(client))
  282.     {
  283.         return Plugin_Continue;
  284.     }
  285.    
  286.     CreateTimer(0.1, KillLate, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
  287.    
  288.     SetEntityRenderMode(client, RENDER_NORMAL);
  289.     SetEntityRenderColor(client);
  290.    
  291.     if(GetClientTeam(client) == CS_TEAM_T)
  292.     {
  293.         GivePlayerItem(client, "weapon_scout");
  294.         GivePlayerItem(client, "weapon_hegrenade");
  295.         GivePlayerItem(client, "weapon_flashbang");
  296.         GivePlayerItem(client, "weapon_smokegrenade");
  297.     }
  298.    
  299.     return Plugin_Continue;
  300. }
  301.  
  302. public Action:GiveWeapons(Handle:Timer, any:serial)
  303. {
  304.     new client = GetClientFromSerial(serial);
  305.    
  306.     if(!IsValidClient(client, true))
  307.     {
  308.         return Plugin_Handled;
  309.     }
  310.    
  311.     return Plugin_Handled;
  312. }
  313.  
  314. public Action:Weapon_Fire(Handle:Event, const String:Name[], bool:DontBroadcast)
  315. {
  316.     if(!gB_Enabled)
  317.     {
  318.         return Plugin_Continue;
  319.     }
  320.    
  321.     new client = GetClientOfUserId(GetEventInt(Event, "userid"));
  322.    
  323.     if(!IsValidClient(client, true))
  324.     {
  325.         return Plugin_Continue;
  326.     }
  327.    
  328.     new Weapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY);
  329.    
  330.     decl String:sWeapon[32];
  331.     GetClientWeapon(client, sWeapon, 32);
  332.    
  333.     if(!StrEqual(sWeapon, "weapon_scout"))
  334.     {
  335.         return Plugin_Continue;
  336.     }
  337.    
  338.     SetEntData(client, gI_Offset_Ammo + (GetEntProp(Weapon, Prop_Send, "m_iPrimaryAmmoType") * 4), 9999, 4, true);
  339.    
  340.     return Plugin_Continue;
  341. }
  342.  
  343. public Action:Round_Start(Handle:Event, const String:Name[], bool:DontBroadcast)
  344. {
  345.     if(!gB_Enabled)
  346.     {
  347.         return Plugin_Continue;
  348.     }
  349.    
  350.     gB_Allow_Respawn = true;
  351.     gB_Someone_Won = false;
  352.    
  353.     gI_Infected = -1;
  354.    
  355.     if(gH_Infection_Timer2 != INVALID_HANDLE)
  356.     {
  357.         CloseHandle(gH_Infection_Timer2);
  358.        
  359.         gH_Infection_Timer2 = INVALID_HANDLE;
  360.     }
  361.    
  362.     if(gH_Infection_Timer != INVALID_HANDLE)
  363.     {
  364.         CloseHandle(gH_Infection_Timer);
  365.        
  366.         gH_Infection_Timer = INVALID_HANDLE;
  367.     }
  368.    
  369.     if(gH_Restart_Timer != INVALID_HANDLE)
  370.     {
  371.         CloseHandle(gH_Restart_Timer);
  372.        
  373.         gH_Restart_Timer = INVALID_HANDLE;
  374.     }
  375.    
  376.     CPrintToChatAll("%s The infected player will get back from the hospital in {khaki}10{default} seconds.", PREFIX);
  377.    
  378.     gH_Infection_Timer2 = CreateTimer(10.0, Infection, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
  379.    
  380.     return Plugin_Continue;
  381. }
  382.  
  383. public Action:Infection(Handle:Timer)
  384. {
  385.     gB_Allow_Respawn = false;
  386.    
  387.     if(gH_Infection_Timer != INVALID_HANDLE)
  388.     {
  389.         CloseHandle(gH_Infection_Timer);
  390.     }
  391.    
  392.     gH_Infection_Timer = INVALID_HANDLE;
  393.    
  394.     gH_Infection_Timer2 = INVALID_HANDLE;
  395.    
  396.     gI_Infected = GetRandomPlayer();
  397.    
  398.     if(gI_Infected == -1 || !IsValidClient(gI_Infected, true))
  399.     {
  400.         return Plugin_Stop;
  401.     }
  402.    
  403.     new Count = 0;
  404.    
  405.     for(new i = 1; i <= MaxClients; i++)
  406.     {
  407.         if(IsValidClient(i, true))
  408.         {
  409.             Count++;
  410.         }
  411.     }
  412.    
  413.     if(Count <= 1)
  414.     {
  415.         return Plugin_Stop;
  416.     }
  417.    
  418.     EmitSoundToClient(gI_Infected, "hit_n_run/infected2.wav");
  419.     PrintCenterTextAll("%N is infected with the sickness!", gI_Infected);
  420.     PrintHintTextToAll("%N is infected with the sickness!", gI_Infected);
  421.     CPrintToChatAllEx(gI_Infected, "%s {teamcolor}%N{default} is infected with the sickness!", PREFIX, gI_Infected);
  422.     CPrintToChatEx(gI_Infected, gI_Infected, "%s {teamcolor}%N{default}, you are infected! Spread this sickness by {khaki}shooting your teammates{default}.", PREFIX, gI_Infected);
  423.    
  424.     CPrintToChatAll("%s The infected player {valve}MUST{default} transfer his sickness in 20 seconds or he will die.", PREFIX);
  425.    
  426.     PlayForAll("hit_n_run/clock_sound.mp3");
  427.    
  428.     for(new i = 1; i <= MaxClients; i++)
  429.     {
  430.         if(IsValidClient(i, true) && i != gI_Infected)
  431.         {
  432.             SetEntityRenderMode(i, RENDER_NORMAL);
  433.         }
  434.     }
  435.    
  436.     SetEntityRenderMode(gI_Infected, RENDER_TRANSALPHA);
  437.     SetEntityRenderColor(gI_Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
  438.    
  439.     gH_Infection_Timer = CreateTimer(20.0, Kill_Infection, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  440.    
  441.     return Plugin_Stop;
  442. }
  443.  
  444. public Action:Kill_Infection(Handle:Timer)
  445. {
  446.     if(WinnerCheck())
  447.     {
  448.         gH_Infection_Timer = INVALID_HANDLE;
  449.        
  450.         return Plugin_Stop;
  451.     }
  452.    
  453.     if(IsValidClient(gI_Infected, true))
  454.     {
  455.         ForcePlayerSuicide(gI_Infected);
  456.        
  457.         EmitSoundToClient(gI_Infected, "hit_n_run/loser.wav");
  458.     }
  459.    
  460.     else
  461.     {
  462.         gI_Infected = GetRandomPlayer();
  463.     }
  464.    
  465.     if(WinnerCheck())
  466.     {
  467.         gH_Infection_Timer = INVALID_HANDLE;
  468.        
  469.         return Plugin_Stop;
  470.     }
  471.    
  472.     gI_Infected = GetRandomPlayer();
  473.    
  474.     EmitSoundToClient(gI_Infected, "hit_n_run/infected2.wav");
  475.     PrintCenterTextAll("%N is infected with the sickness!", gI_Infected);
  476.     PrintHintTextToAll("%N is infected with the sickness!", gI_Infected);
  477.     CPrintToChatAllEx(gI_Infected, "%s {teamcolor}%N{default} is infected with the sickness!", PREFIX, gI_Infected);
  478.     CPrintToChatEx(gI_Infected, gI_Infected, "%s {teamcolor}%N{default}, you are infected! Spread this sickness by {khaki}shooting your teammates{default}.", PREFIX, gI_Infected);
  479.    
  480.     CPrintToChatAll("%s The infected player {valve}MUST{default} transfer his sickness in 20 seconds or he will die.", PREFIX);
  481.    
  482.     PlayForAll("hit_n_run/clock_sound.mp3");
  483.    
  484.     if(IsValidClient(gI_Infected, true))
  485.     {
  486.         for(new i = 1; i <= MaxClients; i++)
  487.         {
  488.             if(IsValidClient(i, true))
  489.             {
  490.                 if(i != gI_Infected)
  491.                 {
  492.                     SetEntityRenderMode(gI_Infected, RENDER_TRANSALPHA);
  493.                     SetEntityRenderColor(gI_Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
  494.                 }
  495.             }
  496.         }
  497.        
  498.         SetEntityRenderMode(gI_Infected, RENDER_TRANSALPHA);
  499.         SetEntityRenderColor(gI_Infected, GetRandomInt(1, 255), GetRandomInt(1, 255), GetRandomInt(1, 255));
  500.     }
  501.    
  502.     return Plugin_Continue;
  503. }
  504.  
  505. stock bool:WinnerCheck()
  506. {
  507.     new Count = 0;
  508.    
  509.     for(new i = 1; i <= MaxClients; i++)
  510.     {
  511.         if(IsValidClient(i, true))
  512.         {
  513.             Count++;
  514.         }
  515.     }
  516.    
  517.     if(Count <= 1)
  518.     {
  519.         CreateTimer(1.5, Winner);
  520.        
  521.         return true;
  522.     }
  523.    
  524.     return false;
  525. }
  526.  
  527. public Action:Winner(Handle:Timer)
  528. {
  529.     gI_Infected = GetRandomPlayer();
  530.    
  531.     if(gI_Infected == -1)
  532.     {
  533.         return Plugin_Stop;
  534.     }
  535.    
  536.     gB_Someone_Won = true;
  537.    
  538.     PrintCenterTextAll("%N is the winner!", gI_Infected);
  539.     PrintHintTextToAll("%N is the winner!", gI_Infected);
  540.     CPrintToChatAllEx(gI_Infected, "%s {teamcolor}%N{selfmade} is the winner!", PREFIX, gI_Infected);
  541.    
  542.     new Float:Time = 0.0;
  543.    
  544.     decl String:MusicFile[128];
  545.     new Song = Math_GetRandomInt(1, 7);
  546.     Format(MusicFile, 128, "hit_n_run/winsound%d.mp3", Song);
  547.    
  548.     if(Song == 6)
  549.     {
  550.         Song = 7;
  551.        
  552.         Format(MusicFile, 128, "hit_n_run/winsound7.mp3", Song);
  553.     }
  554.    
  555.     PlayForAll(MusicFile);
  556.    
  557.     switch(Song)
  558.     {
  559.         case 1: Time = 28.0;
  560.         case 2: Time = 25.0;
  561.         case 3: Time = 18.0;
  562.         case 4: Time = 17.0;
  563.         case 5: Time = 19.5;
  564.         case 7: Time = 22.0;
  565.     }
  566.    
  567.     CreateTimer(Time, Restart);
  568.    
  569.     return Plugin_Handled;
  570. }
  571.  
  572. public Action:Restart(Handle:Timer)
  573. {
  574.     CS_TerminateRound(0.0, CSRoundEnd_VIPEscaped);
  575.    
  576.     return Plugin_Handled;
  577. }
  578.  
  579. public Action:Timer_Beacon(Handle:Timer)
  580. {
  581.     for(new i = 1; i <= MaxClients; i++)
  582.     {
  583.         if(IsValidClient(i, true))
  584.         {
  585.             if(i == gI_Infected)
  586.             {
  587.                 new Float:vec[3];
  588.                 GetClientAbsOrigin(i, vec);
  589.                 vec[2] += 10;
  590.                
  591.                 new Color[4];
  592.                
  593.                 Color[0] = GetRandomInt(1, 255);
  594.                 Color[1] = GetRandomInt(1, 255);
  595.                 Color[2] = GetRandomInt(1, 255);
  596.                 Color[3] = GetRandomInt(150, 255);
  597.                
  598.                 TE_SetupBeamRingPoint(vec, 10.0, 50.0, gI_BeamSprite, gI_HaloSprite, 0, 15, 0.5, 5.0, 0.0, Color, 10, 0);
  599.                 TE_SendToAll();
  600.             }
  601.         }
  602.     }
  603.    
  604.     if(LibraryExists("SteamTools"))
  605.     {
  606.         Steam_SetGameDescription("CS:S - Hit N Run");
  607.     }
  608.    
  609.     return Plugin_Continue;
  610. }
  611.  
  612. public OnEntityCreated(entity, const String:classname[])
  613. {
  614.     if(IsValidEntity(entity) && IsValidEdict(entity))
  615.     {
  616.         if(StrEqual(classname, "func_buyzone") || StrContains(classname, "func_bombsite"))
  617.         {
  618.             SDKHook(entity, SDKHook_Spawn, OnSpawn);
  619.         }
  620.     }
  621. }
  622.  
  623. public Action:OnSpawn(entity)
  624. {
  625.     AcceptEntityInput(entity, "Disable");
  626.    
  627.     return Plugin_Continue;
  628. }
  629.  
  630. public Action:Command_Jointeam(client, const String:command[], args)
  631. {
  632.     if(gB_Enabled)
  633.     {
  634.         decl String:arg1[32];
  635.         GetCmdArgString(arg1, 32);
  636.         TrimString(arg1);
  637.         StripQuotes(arg1);
  638.        
  639.         if(arg1[0] != '2')
  640.         {
  641.             FakeClientCommand(client, "jointeam 2");
  642.         }
  643.     }
  644.    
  645.     return Plugin_Continue;
  646. }
  647.  
  648. public Action:Timer_Restart(Handle:Timer)
  649. {
  650.     new Count = 0;
  651.    
  652.     for(new i = 1; i <= MaxClients; i++)
  653.     {
  654.         if(IsValidClient(i) && GetClientTeam(i) != CS_TEAM_NONE && GetClientTeam(i) != CS_TEAM_SPECTATOR)
  655.         {
  656.             Count++;
  657.         }
  658.     }
  659.    
  660.     if(Count <= 1)
  661.     {
  662.         CPrintToChatAll("%s No players are available to play Hit N Run, restarting the game!", PREFIX);
  663.        
  664.         SetConVarInt(FindConVar("mp_restartgame"), 1);
  665.     }
  666.    
  667.     return Plugin_Continue;
  668. }
  669.  
  670. public Action:KillLate(Handle:Timer, any:serial)
  671. {
  672.     new client = GetClientFromSerial(serial);
  673.    
  674.     if(!IsValidClient(client, true))
  675.     {
  676.         return Plugin_Handled;
  677.     }
  678.    
  679.     Client_HideRadar(client);
  680.    
  681.     if(!gB_Allow_Respawn || gB_Someone_Won)
  682.     {
  683.         ForcePlayerSuicide(client);
  684.        
  685.         CPrintToChatEx(client, client, "%s Sorry {teamcolor}%N{default}, I killed you because you came too late.", PREFIX, client);
  686.     }
  687.    
  688.     return Plugin_Handled;
  689. }
  690.  
  691. void:Client_HideRadar(client)
  692. {
  693.     SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", 3600.0);
  694.     SetEntPropFloat(client, Prop_Send, "m_flFlashMaxAlpha", 0.5);
  695. }
  696.  
  697. stock bool:IsValidClient(client, bool:alive = false)
  698. {
  699.     return bool:(client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (alive == false || IsPlayerAlive(client)));
  700. }
  701.  
  702. stock GetRandomPlayer()
  703. {
  704.     new clients[MaxClients+1];
  705.     new Count;
  706.    
  707.     for(new i = 1; i <= MaxClients; i++)
  708.     {
  709.         if(IsValidClient(i, true) && (GetClientTeam(i) == CS_TEAM_T))
  710.         {
  711.             clients[Count++] = i;
  712.         }
  713.     }
  714.     return (Count == 0)? -1:clients[GetRandomInt(0, Count - 1)];
  715. }
  716.  
  717. stock PlayForAll(const String:Sound[])
  718. {
  719.     for(new i = 1; i <= MaxClients; i++)
  720.     {
  721.         if(IsValidClient(i))
  722.         {
  723.             EmitSoundToClient(i, Sound);
  724.         }
  725.     }
  726. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement