-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpunishhumiliationkill.sp
69 lines (55 loc) · 1.87 KB
/
punishhumiliationkill.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <sourcemod>
#include <sdktools_functions>
#include <sdktools_sound>
#include <tf2>
#define PLUGIN_VERSION "1.0.0"
// Might want to change this to pre so we can prevent deaths.
#define HOOK_MODE EventHookMode_Post
static bool:eventHooked = false;
public Plugin:myinfo = {
name = "[TF2] Punish Humiliation Kill",
author = "Daverball",
description = "Punishes players for attemping to kill other people during humiliation mode.",
version = PLUGIN_VERSION,
url = "https://github.com/Daverball/punishhumiliationkill"
}
public OnPluginStart() {
HookEvent("teamplay_round_start", Event_RoundStart);
HookEvent("teamplay_round_win", Event_RoundWin);
}
public Event_RoundStart(Event:event, const String:name[], bool:dontBroadcast) {
if (eventHooked) {
UnhookEvent("player_death", Event_PlayerDeath, HOOK_MODE);
eventHooked = false;
}
}
public Event_RoundWin(Event:event, const String:name[], bool:dontBroadcast) {
HookEvent("player_death", Event_PlayerDeath, HOOK_MODE);
eventHooked = true;
}
public Action Event_PlayerDeath(Event:event, const String:name[], bool:dontBroadcast) {
int attacker = event.GetInt("attacker");
int victim = event.GetInt("userid");
if (attacker == victim) {
// Can't punish a suicide
return Plugin_Handled;
}
int client_id = GetClientOfUserId(attacker);
if (client_id == 0) {
// Wasn't killed by a player
return Plugin_Handled;
}
TF2_StunPlayer(client_id, 2.0, 0.5, TF_STUNFLAGS_SMALLBONK, 0);
CreateTimer(0.6, Timer_SlapPlayer, client_id);
CreateTimer(1.0, Timer_SlapPlayer, client_id);
CreateTimer(1.3, Timer_SlapPlayer, client_id);
CreateTimer(1.6, Timer_SlapPlayer, client_id);
CreateTimer(1.9, Timer_KillPlayer, client_id);
return Plugin_Handled;
}
public Action Timer_SlapPlayer(Handle timer, any client_id) {
SlapPlayer(client_id, 0);
}
public Action Timer_KillPlayer(Handle timer, any client_id) {
ForcePlayerSuicide(client_id);
}