Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdkhooks>
- #include <sdktools>
- #include <shavit>
- public Plugin myinfo =
- {
- name = "[shavit] Course utilities",
- author = "Prefix",
- description = "Course maps utilities for shavit's bhop timer.",
- version = SHAVIT_VERSION,
- url = "https://github.com/shavitush/bhoptimer"
- }
- public void OnPluginStart() {
- HookEvent("player_death", Event_PlayerDeath);
- }
- public void OnClientPutInServer(int client)
- {
- SDKHook(client, SDKHook_OnTakeDamage, Hook_OnTakeDamage);
- }
- public Action Hook_OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
- {
- if(!IsValidClient(victim))
- return Plugin_Continue;
- // Check if there is no start zone in map, let it skip.
- if(!Shavit_ZoneExists(Zone_Start, Track_Main) || !Shavit_ZoneExists(Zone_End, Track_Main)) {
- return Plugin_Handled;
- }
- // Check if it is world damage and client is not running timer atm
- if ((attacker == 0 || attacker >= MaxClients) && Shavit_GetTimerStatus(victim) != Timer_Running)
- return Plugin_Handled;
- return Plugin_Continue;
- }
- public void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime) {
- if(IsValidClient(client)) CreateTimer(0.1, SlayPlayer, client);
- }
- public Action SlayPlayer(Handle timer, any client)
- {
- if(IsValidClient(client))
- return;
- ForcePlayerSuicide(client);
- FragsPlusOne(client);
- }
- public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
- {
- event.BroadcastDisabled = true;
- int client = GetClientOfUserId(event.GetInt("userid"));
- if(IsValidClient(client))
- return Plugin_Continue;
- FragsPlusOne(client);
- return Plugin_Continue;
- }
- public void FragsPlusOne(int client) {
- if(!IsValidClient(client))
- return;
- int frags = GetClientFrags(client);
- int newfrags = frags + 1;
- SetEntProp(client, Prop_Data, "m_iFrags", newfrags);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement