ExtraCommands: add sm_precachesound
This commit is contained in:
		
							parent
							
								
									69e20df6d7
								
							
						
					
					
						commit
						26a0a5ea06
					
				| @ -5,6 +5,7 @@ | |||||||
| #include <sdkhooks> | #include <sdkhooks> | ||||||
| #include <cstrike> | #include <cstrike> | ||||||
| #include <outputinfo> | #include <outputinfo> | ||||||
|  | #include <halflife> | ||||||
| 
 | 
 | ||||||
| #pragma newdecls required | #pragma newdecls required | ||||||
| 
 | 
 | ||||||
| @ -63,6 +64,7 @@ public void OnPluginStart() | |||||||
| 	RegAdminCmd("sm_setclantag", Command_SetClanTag, ADMFLAG_CHEATS, "sm_setclantag <#userid|name> [text]"); | 	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_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_querycvar", Command_QueryCVar, ADMFLAG_GENERIC, "sm_querycvar <#userid|name> [cvar]"); | ||||||
|  | 	RegAdminCmd("sm_precachesound", Command_PrecacheSound, ADMFLAG_CHEATS, "sm_precachesound <soundpath>"); | ||||||
| 
 | 
 | ||||||
| 	HookEvent("bomb_planted", Event_BombPlanted, EventHookMode_Pre); | 	HookEvent("bomb_planted", Event_BombPlanted, EventHookMode_Pre); | ||||||
| 	HookEvent("bomb_defused", Event_BombDefused, EventHookMode_Pre); | 	HookEvent("bomb_defused", Event_BombDefused, EventHookMode_Pre); | ||||||
| @ -1408,6 +1410,41 @@ public Action Command_QueryCVar(int client, int argc) | |||||||
| 	return Plugin_Handled; | 	return Plugin_Handled; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | public Action Command_PrecacheSound(int client, int args) | ||||||
|  | { | ||||||
|  | 	if(args < 1) | ||||||
|  | 	{ | ||||||
|  | 		ReplyToCommand(client, "[SM] Usage: sm_precachesound <soundpath>"); | ||||||
|  | 		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) | public void ConVarQueryFinished_QueryCVar(QueryCookie hCookie, int client, ConVarQueryResult res, const char[] sCVarName, const char[] sCVarValue, int admin) | ||||||
| { | { | ||||||
| 	switch(res) | 	switch(res) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user