ItsMods

Full Version: Anti SpawnKills
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

Sorry for my bad English again, but I'm still a Swiss since my last topic Wink

I would like to release this small anti spawnkills plugin.
I made it because this week i played a lot on the face off maps, and sometimes the respawns were terribly bads....
You can set a deadline by which the players can not kill or be killed. (after spawn)
And you can chosse if it tells to players when they shot/are shoted by players during that free spawn time...

Add those lines to the sv_config.ini :
Code:
[AntiSpawnKills]
Enabled=1
// 0 or 1
SpawnFreeDelay=3
// Free time with no kills / deaths possible in seconds
SpawnFreeDelayShotInfo=1
// Indicate to the attacker and the victim when they shot/are shoted by players during the free spawn delay

Csharp source code :
CSHARP Code
  1. using System;
  2. using System.Collections;
  3. using System.Text;
  4.  
  5. using Addon;
  6.  
  7. namespace AntiSpawnKills
  8. {
  9. public class Class1 : CPlugin
  10. {
  11. // Create an array of datetimes
  12. private DateTime[] players_list = new DateTime[18];
  13. // Store the plugin status
  14. private string enabled = "0";
  15. // Store the free spawn delay
  16. private int free_spawn_delay = 0;
  17. // Store the free spawn delay shot info
  18. private int free_spawn_delay_shot_info = 0;
  19.  
  20. public override void OnServerLoad()
  21. {
  22. // Get the plugin status
  23. enabled = GetServerCFG("AntiSpawnKills", "Enabled", "0");
  24. // Get the free spawn delay
  25. free_spawn_delay = Int32.Parse(GetServerCFG("AntiSpawnKills", "SpawnFreeDelay", "2"));
  26. // Get the free spawn delay shot info
  27. free_spawn_delay_shot_info = Int32.Parse(GetServerCFG("AntiSpawnKills", "SpawnFreeDelayShotInfo", "1"));
  28. // Print plugin loaded
  29. ServerPrint("Plugin AntiSpawnKills loaded! (Enabled => " + enabled + ")");
  30. }
  31.  
  32. public override void OnPlayerSpawned(ServerClient Client)
  33. {
  34. // If plugin is enabled
  35. if (enabled == "1")
  36. {
  37. // Store the player spawn DateTime
  38. players_list[Client.ClientNum] = DateTime.Now;
  39. }
  40. }
  41.  
  42. public override int OnPlayerDamaged(ServerClient Attacker, ServerClient Victim, String Weapon, int Damage)
  43. {
  44. // If plugin is enabled
  45. if (enabled == "1")
  46. {
  47. // If the attacker is not the victim
  48. if (Attacker.XUID != Victim.XUID)
  49. {
  50. if (DateTime.Now.Subtract(players_list[Attacker.ClientNum]).TotalSeconds <= free_spawn_delay)
  51. {
  52. // If the Attacker is in free spawn delay
  53. // Set damage to 0
  54. Damage = 0;
  55. // If free spawn delay shot info is enabled
  56. if (free_spawn_delay_shot_info == 1)
  57. {
  58. TellClient(Attacker.ClientNum, "Impossible to kill during free spawn (" + Math.Round(free_spawn_delay - DateTime.Now.Subtract(players_list[Attacker.ClientNum]).TotalSeconds, 2) + " s. left)", true);
  59. TellClient(Victim.ClientNum, "You were shoted by a player in free spawn (" + Math.Round(free_spawn_delay - DateTime.Now.Subtract(players_list[Attacker.ClientNum]).TotalSeconds, 2) + " s. left)", true);
  60. }
  61. }
  62. else if (DateTime.Now.Subtract(players_list[Victim.ClientNum]).TotalSeconds <= free_spawn_delay)
  63. {
  64. // If the Victim is in free spawn delay
  65. // Set damage to 0
  66. Damage = 0;
  67. // If free spawn delay shot info is enabled
  68. if (free_spawn_delay_shot_info == 1)
  69. {
  70. TellClient(Attacker.ClientNum, "The player is in free spawn (" + Math.Round(free_spawn_delay - DateTime.Now.Subtract(players_list[Victim.ClientNum]).TotalSeconds, 2) + " s. left)", true);
  71. TellClient(Victim.ClientNum, "You were shoted during free spawn (" + Math.Round(free_spawn_delay - DateTime.Now.Subtract(players_list[Victim.ClientNum]).TotalSeconds, 2) + " s. left)", true);
  72. }
  73. }
  74. }
  75. }
  76. // Return the final damage
  77. return Damage;
  78. }
  79. }
  80. }


I'm open to every suggestions or comments.
Have Fun!
Nice release, is nice to see new plugins getting released everyday Cool
Thanks!
I'll do my best to do good plugins Wink