Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck authored Apr 13, 2019
1 parent 26be1c5 commit d8e2426
Show file tree
Hide file tree
Showing 3 changed files with 258 additions and 0 deletions.
Binary file added plugins/TF2Sandbox-SearchProps.smx
Binary file not shown.
118 changes: 118 additions & 0 deletions scripting/TF2Sandbox-SearchProps.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "Battlefield Duck"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <morecolors>
#include <build>

#pragma newdecls required

public Plugin myinfo =
{
name = "[TF2] SandBox - Search Props",
author = PLUGIN_AUTHOR,
description = "Search System for TF2SandBox",
version = PLUGIN_VERSION,
url = "http://steamcommunity.com/id/battlefieldduck/"
};

Handle g_hPropMenu[MAXPLAYERS + 1];

public void OnPluginStart()
{
RegAdminCmd("sm_sbs", Command_Search, 0, "Open SearchProps menu");
RegAdminCmd("sm_sbsearch", Command_Search, 0, "Open SearchProps menu");
}

public Action Command_Search(int client, int args)
{
if(IsValidClient(client) && IsPlayerAlive(client))
{
if(args == 1)
{
char cTarget[64];
GetCmdArg(1, cTarget, sizeof(cTarget));

g_hPropMenu[client] = CreateMenu(PropMenu);
SetMenuTitle(g_hPropMenu[client], "TF2Sandbox - Search Props v%s\n \nSearch Result:", PLUGIN_VERSION);
SetMenuExitButton(g_hPropMenu[client], true);
SetMenuExitBackButton(g_hPropMenu[client], false);

SearchProps(client, cTarget);
}
else Build_PrintToChat(client, "Usage: !sm_sbs <\x04SEARCHWORD\x01>");
}
}

public int PropMenu(Handle menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_Select && IsValidClient(param1) && IsPlayerAlive(param1))
{
DisplayMenuAtItem(g_hPropMenu[param1], param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
//DisplayMenu(g_hPropMenuPickup, param1, MENU_TIME_FOREVER);
char info[255];
GetMenuItem(menu, param2, info, sizeof(info));

FakeClientCommand(param1, "sm_prop %s", info);
}
else if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack && IsValidClient(param1) && IsClientInGame(param1))
{
DisplayMenu(g_hPropMenu[param1], param1, MENU_TIME_FOREVER);
}
}

void SearchProps(int client, char [] cTarget)
{
char cCheckPath[128];
BuildPath(Path_SM, cCheckPath, sizeof(cCheckPath), "configs/buildmod/props.ini");
if (FileExists(cCheckPath))
{
Handle hOpenFile = OpenFile(cCheckPath, "r");
if (hOpenFile != INVALID_HANDLE)
{
char szLoadString[255];
char szBuffer[4][255];
int iCount = 0;
while (!IsEndOfFile(hOpenFile))
{
if (!ReadFileLine(hOpenFile, szLoadString, sizeof(szLoadString)))
break;

if (StrContains(szLoadString, ";") == -1 && StrContains(szLoadString, cTarget) != -1)
{
ExplodeString(szLoadString, ", ", szBuffer, sizeof(szBuffer), sizeof(szBuffer[]));

for (int i = 0; i <= 2; i++)
{
StripQuotes(szBuffer[i]);
}
if(StrContains(szBuffer[0], cTarget) != -1 || StrContains(szBuffer[3], cTarget) != -1)
{
AddMenuItem(g_hPropMenu[client], szBuffer[0], szBuffer[3]);
iCount++;
}
}
}
if(iCount == 0)
{
Build_PrintToChat(client, "No Result. Searched ( \x04%s\x01 )", cTarget);
}
else DisplayMenu(g_hPropMenu[client], client, MENU_TIME_FOREVER);
CloseHandle(hOpenFile);
}
}
}

stock bool IsValidClient(int client)
{
if (client <= 0) return false;
if (client > MaxClients) return false;
if (!IsClientConnected(client)) return false;
return IsClientInGame(client);
}
140 changes: 140 additions & 0 deletions scripting/include/build.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#define BUILDMODAPI_VER 3
#define BUILDMOD_VER "0.71"
#define MAX_HOOK_ENTITIES 4096

/**
* Register an entity owner.
*
* @param entity_index Entity index.
* @param client_index Client index.
* @param Doll Is prop_ragdoll?
* @return Ture on success. False on failure.
*/
native bool:Build_RegisterEntityOwner(entity_index, client_index, bool:Doll = false);

/**
* Get an entity owner.
*
* @param entity_index Entity index.
* @return -1 on failure. Any other value indicates a Entity index owner.
*/
native Build_ReturnEntityOwner(entity_index);

/**
* Set client props limit.
*
* @param client_index Client index.
* @param amount Amount to increase or decrease. If amount = 0 then set limit to 0.
* @param Doll Is prop_ragdoll?
* @noreturn
*/
native Build_SetLimit(client_index, amount, bool:Doll = false);

/**
* Check client can use BuildMod.
*
* @param client_index Client index.
* @return True on success. False on failure.
*/
native bool:Build_AllowToUse(client_index);

/**
* Check client can use Fly.
*
* @param client_index Client index.
* @return True on success. False on failure.
*/
native bool:Build_AllowFly(client_index);

/**
* Get client admin.
*
* @param client_index Client index.
* @param Level2 Level 2 access.
* @return True on admin. False on not.
*/
native bool:Build_IsAdmin(client_index, bool:Level2 = false);

/**
* Get client aim entity.
*
* @param client_index Client index.
* @param show_message Show a message when entity invalid?
* @param included_clients Allow native to getting clients?
* @return -1 on failure. Any other value indicates a Entity index.
*/
native Build_ClientAimEntity(client_index, bool:show_message = true, bool:included_clients = false);

/**
* Get an entity of owner is equal client.
*
* @param client_index Client index.
* @param entity_index Entity index.
* @param bIngoreCvar Ingore 'bm_nonowner' cvar?
* @return True on owner. False on not.
*/
native bool:Build_IsEntityOwner(client_index, entity_index, bool:bIngoreCvar = false);

/**
* Logging commands and args.
*
* @param client_index Client index.
* @param command Command to log.
* @param args Args to log.
* @noreturn
*/
native Build_Logging(client_index, const String:command[], const String:args[]);

/**
* Prints a message with the BuildMod tag.
*
* @param client_index Client index.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @noreturn
*/
native Build_PrintToChat(client_index, const String:format[], any:...);

/**
* Prints a message to all clients with the BuildMod tag.
*
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @noreturn
*/
native Build_PrintToAll(const String:format[], any:...);

/**
* Add client to blacklist.
*
* @param client_index Client index.
* @return True on success. False on failure.
*/
native Build_AddBlacklist(client_index);

/**
* Remove client from blacklist.
*
* @param client_index Client index.
* @return True on success. False on failure.
*/
native Build_RemoveBlacklist(client_index);

/**
* Get client is blacklisted.
*
* @param client_index Client index.
* @return True on blacklisted. False on not.
*/
native bool:Build_IsBlacklisted(client_index);

/**
* Check is target client valid.
*
* @param client_index Client index.
* @param target_index Target index.
* @param Alive Check is target alive.
* @param ReplyTarget Alive result reply target client or self.
* @return True if target valid. Otherwise false.
*/
native bool:Build_IsClientValid(client_index, target_index, bool:Alive = false, bool:ReplyTarget = false);

0 comments on commit d8e2426

Please sign in to comment.