diff --git a/ExtraCommands/scripting/ExtraCommands.sp b/ExtraCommands/scripting/ExtraCommands.sp index bdb12ee5..bd1c26b6 100644 --- a/ExtraCommands/scripting/ExtraCommands.sp +++ b/ExtraCommands/scripting/ExtraCommands.sp @@ -5,6 +5,7 @@ #include #include #include +#include #pragma newdecls required @@ -63,6 +64,7 @@ public void OnPluginStart() RegAdminCmd("sm_setclantag", Command_SetClanTag, ADMFLAG_CHEATS, "sm_setclantag <#userid|name> [text]"); RegAdminCmd("sm_fakecommand", Command_FakeCommand, ADMFLAG_CHEATS, "sm_fakecommand <#userid|name> [command] [args]"); RegAdminCmd("sm_querycvar", Command_QueryCVar, ADMFLAG_GENERIC, "sm_querycvar <#userid|name> [cvar]"); + RegAdminCmd("sm_precachesound", Command_PrecacheSound, ADMFLAG_CHEATS, "sm_precachesound "); HookEvent("bomb_planted", Event_BombPlanted, EventHookMode_Pre); HookEvent("bomb_defused", Event_BombDefused, EventHookMode_Pre); @@ -1408,6 +1410,41 @@ public Action Command_QueryCVar(int client, int argc) return Plugin_Handled; } +public Action Command_PrecacheSound(int client, int args) +{ + if(args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_precachesound "); + return Plugin_Handled; + } + + char sArgs[PLATFORM_MAX_PATH]; + char sArgs2[PLATFORM_MAX_PATH]; + GetCmdArg(1, sArgs, sizeof(sArgs)); + Format(sArgs2, sizeof(sArgs2), "sound/%s", sArgs); + + if(!FileExists(sArgs2, true)) + { + ReplyToCommand(client, "[SM] File \"%s\" does not exist.", sArgs2); + return Plugin_Handled; + } + + /*if(IsSoundPrecached(sArgs2)) + { + ReplyToCommand(client, "[SM] File \"%s\" is already precached.", sArgs2); + return Plugin_Handled; + }*/ + + bool bPrechache = PrecacheSound(sArgs, false); + + if(bPrechache) + ReplyToCommand(client, "[SM] File \"%s\" successfully precached.", sArgs2); + else + ReplyToCommand(client, "[SM] File \"%s\" cannot be precached.", sArgs2); + + return Plugin_Handled; +} + public void ConVarQueryFinished_QueryCVar(QueryCookie hCookie, int client, ConVarQueryResult res, const char[] sCVarName, const char[] sCVarValue, int admin) { switch(res)