forked from jeremyvillanuevar/scripting
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstHint.sp
More file actions
156 lines (127 loc) · 4.17 KB
/
InstHint.sp
File metadata and controls
156 lines (127 loc) · 4.17 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#define DeathTime 6.5
public Plugin myinfo =
{
name = "[L4D2] Skills Core",
author = "BHaType",
description = "Main Plugin",
version = "0.0",
url = "SDKCall"
};
Menu g_hMain;
ConVar cCooldown;
float g_flTime[MAXPLAYERS + 1];
static const char g_szText[][] =
{
"Go here",
"Be carefull",
"Here items",
"Dangerous",
"No",
"Button"
};
public void OnPluginStart()
{
g_hMain = new Menu(VMainHandler);
g_hMain.AddItem("icon_arrow_up", "Go here");
g_hMain.AddItem("icon_alert_red", "Be carefull");
g_hMain.AddItem("icon_info", "Here items");
g_hMain.AddItem("icon_skull", "Dangerous");
g_hMain.AddItem("icon_no", "No");
g_hMain.AddItem("icon_button", "Button");
g_hMain.SetTitle("Hints: Main Menu");
cCooldown = CreateConVar("sm_hint_cooldown", "5.0", "Cooldown", 0);
AutoExecConfig(true, "l4d2_hint");
RegConsoleCmd("sm_hint", cHint);
}
public void OnMapStart()
{
for (int i = 1; i <= MaxClients; i++)
g_flTime[i] = 0.0;
}
public Action cHint (int client, int args)
{
if (!client)
return Plugin_Handled;
g_hMain.Display(client, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public int VMainHandler(Menu menu, MenuAction action, int client, int index)
{
if( action == MenuAction_Select )
{
g_hMain.Display(client, MENU_TIME_FOREVER);
if (GetGameTime() - g_flTime[client] < cCooldown.FloatValue)
{
PrintToChat(client, "\x04Cooldown \x03%.2f", cCooldown.FloatValue - (GetGameTime() - g_flTime[client]));
return;
}
static int iFixaw;
iFixaw++;
g_flTime[client] = GetGameTime();
char szMenuItem[24], szTemp[64], szParent[36];
menu.GetItem(index, szMenuItem, sizeof szMenuItem);
float vOrigin[3], vAngles[3];
GetClientEyeAngles(client, vAngles);
GetClientEyePosition(client, vOrigin);
Handle TraceRay = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceFilter, client);
if (TR_DidHit(TraceRay))
TR_GetEndPosition(vOrigin, TraceRay);
vOrigin[2] += 25.0;
delete TraceRay;
Format(szTemp, sizeof szTemp, "%i_name", client * iFixaw);
CreateTarget(vOrigin, szTemp, szParent);
CreateInstructorHint(vOrigin, szTemp, szMenuItem, g_szText[index]);
PrintToChatAll("\x03[\x04%N\x03] - \x05%s", client, g_szText[index]);
}
}
public bool TraceFilter (int entity, int mask, int client)
{
if (entity == client)
return false;
return true;
}
int CreateTarget(float vOrigin[3], const char[] name, const char[] parent)
{
int entity = CreateEntityByName("info_target_instructor_hint");
DispatchKeyValue(entity, "parentname", parent);
DispatchKeyValue(entity, "targetname", name);
DispatchSpawn(entity);
TeleportEntity(entity, vOrigin, NULL_VECTOR, NULL_VECTOR);
char szBuffer[36];
Format(szBuffer, sizeof szBuffer, "OnUser1 !self:Kill::%f:-1", DeathTime);
SetVariantString(szBuffer);
AcceptEntityInput(entity, "AddOutput");
AcceptEntityInput(entity, "FireUser1");
return entity;
}
int CreateInstructorHint(float vOrigin[3], const char[] target, const char[] icon_name, const char[] text)
{
int entity = CreateEntityByName("env_instructor_hint");
DispatchKeyValue(entity, "hint_timeout", "12");
DispatchKeyValue(entity, "hint_allow_nodraw_target", "1");
DispatchKeyValue(entity, "hint_target", target);
DispatchKeyValue(entity, "hint_auto_start", "1");
DispatchKeyValue(entity, "hint_color", "255 20 147");
DispatchKeyValue(entity, "hint_icon_offscreen", icon_name);
DispatchKeyValue(entity, "hint_instance_type", "0");
DispatchKeyValue(entity, "hint_icon_onscreen", icon_name);
DispatchKeyValue(entity, "hint_caption", text);
DispatchKeyValue(entity, "hint_static", "0");
DispatchKeyValue(entity, "hint_nooffscreen", "0");
DispatchKeyValue(entity, "hint_icon_offset", "15");
DispatchKeyValue(entity, "hint_range", "0");
DispatchKeyValue(entity, "hint_forcecaption", "1");
DispatchSpawn(entity);
TeleportEntity(entity, vOrigin, NULL_VECTOR, NULL_VECTOR);
AcceptEntityInput(entity, "ShowHint");
char szBuffer[36];
Format(szBuffer, sizeof szBuffer, "OnUser1 !self:Kill::%f:-1", DeathTime);
SetVariantString(szBuffer);
AcceptEntityInput(entity, "AddOutput");
AcceptEntityInput(entity, "FireUser1");
}