-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLAB.sp
124 lines (114 loc) · 3.81 KB
/
LAB.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "MWorkShop.inc"
const LAB_hook_size = 1;
new bool:LAB_hook_enabled[LAB_hook_size];
LAB_SetLab(const lab)
{
switch(lab)
{
case 0:
{
if(LAB_hook_enabled[0]){
UnhookEvent("player_changeclass", Event_PlayerClass_Lab0, EventHookMode_Post);
UnhookEvent("player_spawn", Event_PlayerSpawn_Lab0, EventHookMode_Post);
}
else{
if (!HookEventEx("player_changeclass", Event_PlayerClass_Lab0, EventHookMode_Post)
||!HookEventEx("player_spawn", Event_PlayerSpawn_Lab0, EventHookMode_Post))
SetFailState("Could not hook an event.");
}
}
}
if(LAB_hook_enabled[lab])
LAB_hook_enabled[lab] = false;
else{
LAB_hook_enabled[lab] = true;
MWSSetState(true);
}
}
/*--------------------------------------------------------------------------------
/ Hooks
/-------------------------------------------------------------------------------*/
public Action:Event_PlayerClass_Lab0(Handle:event, const String:name[], const bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new any:class = GetEventInt(event, "class");
if (class == TFClass_Medic)
CreateTimer(0.25, Timer_L1_PlayerUberDelay, client);
return Plugin_Continue;
}
public Action:Event_PlayerSpawn_Lab0(Handle:event, const String:name[], const bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new TFClassType:class = TF2_GetPlayerClass(client);
if (class == TFClass_Medic)
CreateTimer(0.25, Timer_L1_PlayerUberDelay, client);
return Plugin_Continue;
}
/*--------------------------------------------------------------------------------
/ Timers
/-------------------------------------------------------------------------------*/
public Action:Timer_L1_PlayerUberDelay(Handle:timer, const any:client)
{
if (IsClientInGame(client)) {
new TFClassType:class = TF2_GetPlayerClass(client);
if (class == TFClass_Medic) {
new Float:uberlevel = GetConVarFloat(mws_l1_startuberlevel);
new index = GetPlayerWeaponSlot(client, 1);
if (index > 0)
SetEntPropFloat(index, Prop_Send, "m_flChargeLevel", uberlevel);
}
}
}
/*--------------------------------------------------------------------------------
/ Menus
/-------------------------------------------------------------------------------*/
public Menu_Lab(Handle:menu, const MenuAction:action, const client, const param)
{
if (action == MenuAction_Select)
{
new String:info[INFO_MAXLEN];
GetMenuItem(menu, param, info, INFO_MAXLEN);
LAB_SetLab(param);
LoadLabMenu(client);
}
else if (action == MenuAction_Cancel)
{
LoadMainMenu(client);
}
else if (action == MenuAction_End)
{
CloseHandle(menu);
}
}
/*--------------------------------------------------------------------------------
/ Load Menu Functions
/-------------------------------------------------------------------------------*/
LoadLabMenu(const client)
{
new Handle:menu = CreateMenu(Menu_Lab);
new String:menuitems[LAB_hook_size][MENUITEM_NAME_MAXLEN];
GetLabs(menuitems);
for(new i = 0; i < LAB_hook_size; i++){
new String:menu_i[MENUITEM_NAME_MAXLEN];
if(LAB_hook_enabled[i])
menu_i = "[X]";
else
menu_i = "[ ]";
StrCat(menu_i, MENUITEM_NAME_MAXLEN, menuitems[i]);
AddMenuItem(menu, "", menu_i);
}
SetMenuTitle(menu, "Labs");
SetMenuExitBackButton(menu, true);
SetMenuExitButton(menu, false);
DisplayMenu(menu, client, 0);
}
/*--------------------------------------------------------------------------------
/ Helper Functions
/-------------------------------------------------------------------------------*/
GetLabs(String:lab_out[LAB_hook_size][MENUITEM_NAME_MAXLEN])
{
static String:LABS[LAB_hook_size][MENUITEM_NAME_MAXLEN] = {"Start with Full Uber"};
for(new i = 0; i < LAB_hook_size; i++){
lab_out[i] = LABS[i];
}
}