-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuffViewer.sp
162 lines (137 loc) · 4.05 KB
/
buffViewer.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
#include <sourcemod>
#include <PTaH>
#include <ripext>
#include <sdktools>
#include <eItems>
public Plugin myinfo = {
name = "buff viewer|大致框架",
author = "neko aka bklol",
description = "呐呐 喜欢二次元的 一定不是坏人吧?",
version = "0.1",
url = "https://github.com/bklol"
};
public void OnPluginStart()
{
RegConsoleCmd("sm_buff",test);
PTaH(PTaH_GiveNamedItemPre, Hook, OnGiveNamedItemPre);
PTaH(PTaH_GiveNamedItemPost, Hook, OnGiveNamedItemPost);
PTaH(PTaH_WeaponCanUsePre, Hook, PTaH_OnWeaponCanUsePre);
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
OnClientPostAdminCheck(i);
}
}
public Action PTaH_OnWeaponCanUsePre(int client, int iEnt, bool& CanUse)
{
//强制装备刀具
if(!IsValidClient(client) && !IsFakeClient(client))
return Plugin_Continue;
int iDefIndex = eItems_GetWeaponDefIndexByWeapon(iEnt);
if(eItems_IsDefIndexKnife(iDefIndex))
{
CanUse = true;
return Plugin_Changed;
}
return Plugin_Continue;
}
public Action test(int client,int a)
{
char Buffer[1280];
GetCmdArgString(Buffer, sizeof(Buffer));
//发送http 请求
HTTPClient httpClient = new HTTPClient("http://buffapi.ncyxx.cn/"); //试用的API
Format(Buffer,1280,"https://buff.163.com/market/m/item_detail?%s",Buffer);
JSONObject hJSONObject = new JSONObject();
hJSONObject.SetString("ip",Buffer);
httpClient.Post("index.php", hJSONObject, ItemCheckCallBack, client);
delete hJSONObject;
return Plugin_Handled;
}
public void OnClientPostAdminCheck(int client)
{
//玩家判断。。。。
}
public void ItemCheckCallBack(HTTPResponse response, any client)
{
if (response.Status != HTTPStatus_OK)
{
LogError("Http Get error error, %d", response.Status);
PrintToChat(client, "API 访问失败");
return;
}
if (response.Data == null)
{
LogError("Http Get No response");
PrintToChat(client, "物品 解析失败");
return;
}
//接收json 开始解析。。。
//重构武器皮肤。。。。
//判断是否是手套。。。否:
int weapon = eItems_GetActiveWeapon(client);
eItems_RespawnWeapon(client, weapon, true);
//是:重构手套
}
public Action OnGiveNamedItemPre(int client, char classname[64], CEconItemView &item, bool &ignoredCEconItemView, bool &isOriginNULL, float origin[3])
{
//这里移除武器原有皮肤
}
public void OnGiveNamedItemPost(int client, const char[] classname, const CEconItemView item, int entity, bool isOriginNULL, const float origin[3])
{
//再这里重构武器皮肤|Attach 贴纸等等
PTaH_ForceFullUpdate(client);
//如果有贴纸 打开贴纸修改菜单。。。。
OPP(client);
}
void OPP(int client)
{
Menu menu = new Menu(Handler_MainMenu);
menu.SetTitle("贴纸矫正[槽位选择]");
int weapon = eItems_GetActiveWeapon(client);
int slots = eItems_GetWeaponStickersSlotsByWeapon(weapon);
char buffer[1024];
for (int i = 0; i < slots; i++)
{
//这里添加槽位
menu.AddItem("0", buffer);
}
menu.Display(client, MENU_TIME_FOREVER);
}
public int Handler_MainMenu(Menu menu, MenuAction action, int client, int itemNum)
{
if (action == MenuAction_Select)
{
//这里打开贴纸下级菜单
StickerMenu(client);
}
}
void StickerMenu(int client)
{
Menu menu = new Menu(Handler_SMenu);
//显示槽位和应用的贴纸。
menu.ExitBackButton = true;
menu.Display(client, MENU_TIME_FOREVER);
}
public int Handler_SMenu(Menu menu, MenuAction action, int client, int itemNum)
{
if (action == MenuAction_Select)
{
//替换贴纸,重新打开菜单
OPP(client);
int weapon = eItems_GetActiveWeapon(client);
eItems_RespawnWeapon(client, weapon, true);
}
if (action == MenuAction_Cancel)
{
OPP(client);
}
}
stock bool IsValidClient( int client )
{
if ( client < 1 || client > MaxClients ) return false;
if ( !IsClientConnected( client )) return false;
if ( !IsClientInGame( client )) return false;
//if ( IsFakeClient(client)) return false;
return true;
}