forked from bklol/Misc-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decal-2 wrong.sp
235 lines (192 loc) · 6.27 KB
/
decal-2 wrong.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#include <sourcemod>
#include <sdktools>
bool cooldown[MAXPLAYERS+1];
int g_idecals = 0;
Handle adt_decal_position = INVALID_HANDLE;
enum decalSettings
{
decalName = 0,
decalModel,
decalFlag,
decalOnwer,
}
public Plugin myinfo =
{
name = "decal",
author = "neko",
description = "decal plugin",
version = "0.1"
};
char szMap[128];
char g_szSkins[137][decalSettings][PLATFORM_MAX_PATH + 1];
char DecalInUse[MAXPLAYERS+1][PLATFORM_MAX_PATH];
public OnPluginStart()
{
adt_decal_position = CreateArray(3);
RegConsoleCmd("sm_decal", Command_Decal);
}
public Action Command_Decal(int client,int args)
{
if(cooldown[client])
{
PrintToChat(client,"请在喷漆结束之后等待3分钟冷却");
return Plugin_Handled;
}
Menus_SkinsMain(client);
return Plugin_Handled;
}
public void OnMapStart()
{
ClearArray(adt_decal_position);
GetCurrentMap(szMap, 128);
LoadDecal();
}
LoadDecal()
{
g_idecals = 0;
char Buffer[PLATFORM_MAX_PATH];
char szPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, szPath,PLATFORM_MAX_PATH, "configs/decal.cfg");
if (!FileExists(szPath))
SetFailState("Couldn't find file: %s", szPath);
KeyValues kConfig = new KeyValues("");
kConfig.ImportFromFile(szPath);
kConfig.JumpToKey("decal");
kConfig.GotoFirstSubKey();
do {
kConfig.GetString("name", g_szSkins[g_idecals][decalName], 64);
kConfig.GetString("index", g_szSkins[g_idecals][decalModel], PLATFORM_MAX_PATH);
kConfig.GetString("flag", g_szSkins[g_idecals][decalFlag], 64);
kConfig.GetString("steamid", g_szSkins[g_idecals][decalOnwer], 64);
Format(Buffer,sizeof(Buffer),"materials/%s.vmt",g_szSkins[g_idecals][decalModel]);
AddFileToDownloadsTable(Buffer);
Format(Buffer,sizeof(Buffer),"materials/%s.vtf",g_szSkins[g_idecals][decalModel]);
AddFileToDownloadsTable(Buffer);
g_idecals++;
} while (kConfig.GotoNextKey())
}
public OnMapEnd() {
ClearArray(adt_decal_position);
}
public Action CoolDown(Handle timer,int client)
{
cooldown[client] = false;
}
void Menus_SkinsMain(int client)
{
Menu menu = new Menu(Handler_SkinsSelection);
menu.SetTitle("选择一个自定义贴图\n");
char szBuffer[128];
for (int i = 0; i < g_idecals; i++)
{
Format(szBuffer, sizeof(szBuffer), g_szSkins[i][decalName]);
menu.AddItem(g_szSkins[i][decalModel], szBuffer,CheckAcess(client,g_szSkins[i][decalFlag],g_szSkins[i][decalOnwer])?ITEMDRAW_DEFAULT:ITEMDRAW_DISABLED);
}
menu.ExitBackButton = true;
menu.Display(client, MENU_TIME_FOREVER);
}
public int Handler_SkinsSelection(Menu menu, MenuAction action, int client, int itemNum)
{
if (action == MenuAction_Select) {
char szInfo[PLATFORM_MAX_PATH], szName[64];
menu.GetItem(itemNum, szInfo, PLATFORM_MAX_PATH, _, szName, sizeof(szName));
DecalInUse[client] = szInfo;
PrintToChat(client,"对墙壁按E喷涂");
Menus_SkinsMain(client);
}
}
public Action OnPlayerRunCmd(int client, int &iButtons, int &iImpulse, float fVelocity[3], float fAngles[3], int &iWeapon)
{
if (iButtons & IN_USE && !cooldown[client])
{
MakeSpray(client,DecalInUse[client]);
}
}
void MakeSpray(int client, char[] Decalpath)
{
float fClientEyePosition[3];
GetClientEyePosition(client, fClientEyePosition);
float fClientEyeViewPoint[3];
GetPlayerEyeViewPoint(client, fClientEyeViewPoint);
float fVector[3];
MakeVectorFromPoints(fClientEyeViewPoint, fClientEyePosition, fVector);
float vecAng[3];
GetClientAbsAngles(client, vecAng);
Format(Decalpath,256,"%s.vmt",Decalpath);
CreateSprite(client, Decalpath , fClientEyeViewPoint, vecAng, 0.5, "0", 150.0);
}
stock GetPlayerEyeViewPoint(int iClient, float fPosition[3])
{
float fAngles[3];
GetClientEyeAngles(iClient, fAngles);
float fOrigin[3];
GetClientEyePosition(iClient, fOrigin);
Handle hTrace = TR_TraceRayFilterEx(fOrigin, fAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
if(TR_DidHit(hTrace))
{
TR_GetEndPosition(fPosition, hTrace);
CloseHandle(hTrace);
return true;
}
CloseHandle(hTrace);
return false;
}
public bool TraceEntityFilterPlayer(iEntity, iContentsMask)
{
return iEntity > MaxClients;
}
stock CreateSprite(iClient, char[] sprite, float vOrigin[3], float fAng[3], float Scale, char[] fps, float fLifetime)
{
new String:szTemp[64];
Format(szTemp, sizeof(szTemp), "client%i", iClient);
DispatchKeyValue(iClient, "targetname", szTemp);
new ent = CreateEntityByName("env_sprite_oriented");
if (IsValidEdict(ent))
{
new String:StrEntityName[64]; Format(StrEntityName, sizeof(StrEntityName), "ent_sprite_oriented_%i", ent);
DispatchKeyValue(ent, "model", sprite);
DispatchKeyValue(ent, "classname", "env_sprite_oriented");
DispatchKeyValue(ent, "spawnflags", "1");
DispatchKeyValueFloat(ent, "scale", Scale);
DispatchKeyValue(ent, "rendermode", "1");
DispatchKeyValue(ent, "rendercolor", "255 255 255");
DispatchKeyValue(ent, "framerate", fps);
DispatchKeyValueVector(ent, "Angles", fAng);
DispatchSpawn(ent);
TeleportEntity(ent, vOrigin, fAng, NULL_VECTOR);
CreateTimer(fLifetime, RemoveParticle, ent);
}
}
public Action RemoveParticle(Handle timer, any particle)
{
if(IsValidEdict(particle))
{
AcceptEntityInput(particle, "Deactivate");
AcceptEntityInput(particle, "Kill");
}
}
public OnClientPostAdminCheck(client) {
cooldown[client] = false;
}
bool CheckAcess(int client,char[] Flag,char[] steamid)
{
char g_szAuth[32];
GetClientAuthId(client, AuthId_Steam2, g_szAuth, sizeof(g_szAuth));
if(StrEqual("",steamid) && StrEqual("",Flag)) return true;
if(StrEqual(g_szAuth,steamid)) return true;
if(!StrEqual("",Flag))
{
bool bFlags[AdminFlags_TOTAL];
bool bPlayerFlags[AdminFlags_TOTAL];
int iFlags = ReadFlagString(Flag);
int iPlayerFlags = GetUserFlagBits(client);
FlagBitsToBitArray(iFlags, bFlags, AdminFlags_TOTAL);
FlagBitsToBitArray(iPlayerFlags, bPlayerFlags, AdminFlags_TOTAL);
for (int i = 0; i < AdminFlags_TOTAL; i++)
{
if (bPlayerFlags[i] && bFlags[i])
return true;
}
}
return false;
}