Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3. #include <sdktools>
  4. #include <shavit>
  5.  
  6. public Plugin myinfo =
  7. {
  8. name = "[shavit] Course utilities",
  9. author = "Prefix",
  10. description = "Course maps utilities for shavit's bhop timer.",
  11. version = SHAVIT_VERSION,
  12. url = "https://github.com/shavitush/bhoptimer"
  13. }
  14.  
  15. public void OnPluginStart() {
  16. HookEvent("player_death", Event_PlayerDeath);
  17. }
  18.  
  19. public void OnClientPutInServer(int client)
  20. {
  21. SDKHook(client, SDKHook_OnTakeDamage, Hook_OnTakeDamage);
  22. }
  23.  
  24.  
  25. public Action Hook_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
  26. {
  27. if(!IsValidClient(victim))
  28. return Plugin_Continue;
  29. // Check if there is no start zone in map, let it skip.
  30. if(!Shavit_ZoneExists(Zone_Start, Track_Main) || !Shavit_ZoneExists(Zone_End, Track_Main)) {
  31. return Plugin_Handled;
  32. }
  33. // Check if it is world damage and client is not running timer atm
  34. if ((attacker == 0 || attacker >= MaxClients) && Shavit_GetTimerStatus(victim) != Timer_Running)
  35. return Plugin_Handled;
  36.  
  37. return Plugin_Continue;
  38. }
  39.  
  40. public void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime) {
  41. if(IsValidClient(client)) CreateTimer(0.1, SlayPlayer, client);
  42. }
  43. public Action SlayPlayer(Handle timer, any client)
  44. {
  45. if(IsValidClient(client))
  46. return;
  47. ForcePlayerSuicide(client);
  48. FragsPlusOne(client);
  49. }
  50.  
  51. public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
  52. {
  53. event.BroadcastDisabled = true;
  54. int client = GetClientOfUserId(event.GetInt("userid"));
  55. if(IsValidClient(client))
  56. return Plugin_Continue;
  57. FragsPlusOne(client);
  58.  
  59. return Plugin_Continue;
  60. }
  61. public void FragsPlusOne(int client) {
  62. if(!IsValidClient(client))
  63. return;
  64. int frags = GetClientFrags(client);
  65. int newfrags = frags + 1;
  66. SetEntProp(client, Prop_Data, "m_iFrags", newfrags);
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement