Skip to content

Commit d8e2426

Browse files
Add files via upload
1 parent 26be1c5 commit d8e2426

File tree

3 files changed

+258
-0
lines changed

3 files changed

+258
-0
lines changed

plugins/TF2Sandbox-SearchProps.smx

6.61 KB
Binary file not shown.

scripting/TF2Sandbox-SearchProps.sp

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#pragma semicolon 1
2+
3+
#define DEBUG
4+
5+
#define PLUGIN_AUTHOR "Battlefield Duck"
6+
#define PLUGIN_VERSION "1.0"
7+
8+
#include <sourcemod>
9+
#include <sdktools>
10+
#include <sdkhooks>
11+
#include <morecolors>
12+
#include <build>
13+
14+
#pragma newdecls required
15+
16+
public Plugin myinfo =
17+
{
18+
name = "[TF2] SandBox - Search Props",
19+
author = PLUGIN_AUTHOR,
20+
description = "Search System for TF2SandBox",
21+
version = PLUGIN_VERSION,
22+
url = "http://steamcommunity.com/id/battlefieldduck/"
23+
};
24+
25+
Handle g_hPropMenu[MAXPLAYERS + 1];
26+
27+
public void OnPluginStart()
28+
{
29+
RegAdminCmd("sm_sbs", Command_Search, 0, "Open SearchProps menu");
30+
RegAdminCmd("sm_sbsearch", Command_Search, 0, "Open SearchProps menu");
31+
}
32+
33+
public Action Command_Search(int client, int args)
34+
{
35+
if(IsValidClient(client) && IsPlayerAlive(client))
36+
{
37+
if(args == 1)
38+
{
39+
char cTarget[64];
40+
GetCmdArg(1, cTarget, sizeof(cTarget));
41+
42+
g_hPropMenu[client] = CreateMenu(PropMenu);
43+
SetMenuTitle(g_hPropMenu[client], "TF2Sandbox - Search Props v%s\n \nSearch Result:", PLUGIN_VERSION);
44+
SetMenuExitButton(g_hPropMenu[client], true);
45+
SetMenuExitBackButton(g_hPropMenu[client], false);
46+
47+
SearchProps(client, cTarget);
48+
}
49+
else Build_PrintToChat(client, "Usage: !sm_sbs <\x04SEARCHWORD\x01>");
50+
}
51+
}
52+
53+
public int PropMenu(Handle menu, MenuAction action, int param1, int param2)
54+
{
55+
if (action == MenuAction_Select && IsValidClient(param1) && IsPlayerAlive(param1))
56+
{
57+
DisplayMenuAtItem(g_hPropMenu[param1], param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
58+
//DisplayMenu(g_hPropMenuPickup, param1, MENU_TIME_FOREVER);
59+
char info[255];
60+
GetMenuItem(menu, param2, info, sizeof(info));
61+
62+
FakeClientCommand(param1, "sm_prop %s", info);
63+
}
64+
else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack && IsValidClient(param1) && IsClientInGame(param1))
65+
{
66+
DisplayMenu(g_hPropMenu[param1], param1, MENU_TIME_FOREVER);
67+
}
68+
}
69+
70+
void SearchProps(int client, char [] cTarget)
71+
{
72+
char cCheckPath[128];
73+
BuildPath(Path_SM, cCheckPath, sizeof(cCheckPath), "configs/buildmod/props.ini");
74+
if (FileExists(cCheckPath))
75+
{
76+
Handle hOpenFile = OpenFile(cCheckPath, "r");
77+
if (hOpenFile != INVALID_HANDLE)
78+
{
79+
char szLoadString[255];
80+
char szBuffer[4][255];
81+
int iCount = 0;
82+
while (!IsEndOfFile(hOpenFile))
83+
{
84+
if (!ReadFileLine(hOpenFile, szLoadString, sizeof(szLoadString)))
85+
break;
86+
87+
if (StrContains(szLoadString, ";") == -1 && StrContains(szLoadString, cTarget) != -1)
88+
{
89+
ExplodeString(szLoadString, ", ", szBuffer, sizeof(szBuffer), sizeof(szBuffer[]));
90+
91+
for (int i = 0; i <= 2; i++)
92+
{
93+
StripQuotes(szBuffer[i]);
94+
}
95+
if(StrContains(szBuffer[0], cTarget) != -1 || StrContains(szBuffer[3], cTarget) != -1)
96+
{
97+
AddMenuItem(g_hPropMenu[client], szBuffer[0], szBuffer[3]);
98+
iCount++;
99+
}
100+
}
101+
}
102+
if(iCount == 0)
103+
{
104+
Build_PrintToChat(client, "No Result. Searched ( \x04%s\x01 )", cTarget);
105+
}
106+
else DisplayMenu(g_hPropMenu[client], client, MENU_TIME_FOREVER);
107+
CloseHandle(hOpenFile);
108+
}
109+
}
110+
}
111+
112+
stock bool IsValidClient(int client)
113+
{
114+
if (client <= 0) return false;
115+
if (client > MaxClients) return false;
116+
if (!IsClientConnected(client)) return false;
117+
return IsClientInGame(client);
118+
}

scripting/include/build.inc

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#define BUILDMODAPI_VER 3
2+
#define BUILDMOD_VER "0.71"
3+
#define MAX_HOOK_ENTITIES 4096
4+
5+
/**
6+
* Register an entity owner.
7+
*
8+
* @param entity_index Entity index.
9+
* @param client_index Client index.
10+
* @param Doll Is prop_ragdoll?
11+
* @return Ture on success. False on failure.
12+
*/
13+
native bool:Build_RegisterEntityOwner(entity_index, client_index, bool:Doll = false);
14+
15+
/**
16+
* Get an entity owner.
17+
*
18+
* @param entity_index Entity index.
19+
* @return -1 on failure. Any other value indicates a Entity index owner.
20+
*/
21+
native Build_ReturnEntityOwner(entity_index);
22+
23+
/**
24+
* Set client props limit.
25+
*
26+
* @param client_index Client index.
27+
* @param amount Amount to increase or decrease. If amount = 0 then set limit to 0.
28+
* @param Doll Is prop_ragdoll?
29+
* @noreturn
30+
*/
31+
native Build_SetLimit(client_index, amount, bool:Doll = false);
32+
33+
/**
34+
* Check client can use BuildMod.
35+
*
36+
* @param client_index Client index.
37+
* @return True on success. False on failure.
38+
*/
39+
native bool:Build_AllowToUse(client_index);
40+
41+
/**
42+
* Check client can use Fly.
43+
*
44+
* @param client_index Client index.
45+
* @return True on success. False on failure.
46+
*/
47+
native bool:Build_AllowFly(client_index);
48+
49+
/**
50+
* Get client admin.
51+
*
52+
* @param client_index Client index.
53+
* @param Level2 Level 2 access.
54+
* @return True on admin. False on not.
55+
*/
56+
native bool:Build_IsAdmin(client_index, bool:Level2 = false);
57+
58+
/**
59+
* Get client aim entity.
60+
*
61+
* @param client_index Client index.
62+
* @param show_message Show a message when entity invalid?
63+
* @param included_clients Allow native to getting clients?
64+
* @return -1 on failure. Any other value indicates a Entity index.
65+
*/
66+
native Build_ClientAimEntity(client_index, bool:show_message = true, bool:included_clients = false);
67+
68+
/**
69+
* Get an entity of owner is equal client.
70+
*
71+
* @param client_index Client index.
72+
* @param entity_index Entity index.
73+
* @param bIngoreCvar Ingore 'bm_nonowner' cvar?
74+
* @return True on owner. False on not.
75+
*/
76+
native bool:Build_IsEntityOwner(client_index, entity_index, bool:bIngoreCvar = false);
77+
78+
/**
79+
* Logging commands and args.
80+
*
81+
* @param client_index Client index.
82+
* @param command Command to log.
83+
* @param args Args to log.
84+
* @noreturn
85+
*/
86+
native Build_Logging(client_index, const String:command[], const String:args[]);
87+
88+
/**
89+
* Prints a message with the BuildMod tag.
90+
*
91+
* @param client_index Client index.
92+
* @param format Formatting rules.
93+
* @param ... Variable number of format parameters.
94+
* @noreturn
95+
*/
96+
native Build_PrintToChat(client_index, const String:format[], any:...);
97+
98+
/**
99+
* Prints a message to all clients with the BuildMod tag.
100+
*
101+
* @param format Formatting rules.
102+
* @param ... Variable number of format parameters.
103+
* @noreturn
104+
*/
105+
native Build_PrintToAll(const String:format[], any:...);
106+
107+
/**
108+
* Add client to blacklist.
109+
*
110+
* @param client_index Client index.
111+
* @return True on success. False on failure.
112+
*/
113+
native Build_AddBlacklist(client_index);
114+
115+
/**
116+
* Remove client from blacklist.
117+
*
118+
* @param client_index Client index.
119+
* @return True on success. False on failure.
120+
*/
121+
native Build_RemoveBlacklist(client_index);
122+
123+
/**
124+
* Get client is blacklisted.
125+
*
126+
* @param client_index Client index.
127+
* @return True on blacklisted. False on not.
128+
*/
129+
native bool:Build_IsBlacklisted(client_index);
130+
131+
/**
132+
* Check is target client valid.
133+
*
134+
* @param client_index Client index.
135+
* @param target_index Target index.
136+
* @param Alive Check is target alive.
137+
* @param ReplyTarget Alive result reply target client or self.
138+
* @return True if target valid. Otherwise false.
139+
*/
140+
native bool:Build_IsClientValid(client_index, target_index, bool:Alive = false, bool:ReplyTarget = false);

0 commit comments

Comments
 (0)