View Single Post
yazeed98
Member
Join Date: Mar 2014
Old 04-01-2015 , 12:44   Re: execute command after 5sec of every round start
Reply With Quote #11

Quote:
Originally Posted by Miu View Post
Code:
#include <sourcemod> #include <sdktools> #define MAX_EDICTS    2048 new bool:g_toggle = true; new g_iSoundEnts[MAX_EDICTS]; new g_iNumSounds; public OnPluginStart(){     HookEvent("round_start", RoundStart);     RegAdminCmd("sm_runcommandeveryround", RunCommandEveryRound, ADMFLAG_ROOT, ""); } public Action:RunCommandEveryRound(client, args){     if(!g_toggle){         g_toggle = true;         PrintToChat(client, "[COMMAND] Toggle command after 5 seconds every round. \x04Turned ON");     }     else{         g_toggle=false;         PrintToChat(client, "[COMMAND] Toggle command after 5 seconds every round. \x04Turned OFF");     } } public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast){     // Ents are recreated every round.     g_iNumSounds = 0;         // Find all ambient sounds played by the map.     decl String:sSound[PLATFORM_MAX_PATH];     new entity = INVALID_ENT_REFERENCE;         while ((entity = FindEntityByClassname(entity, "ambient_generic")) != INVALID_ENT_REFERENCE)     {         GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, sizeof(sSound));                 new len = strlen(sSound);         if (len > 4 && (StrEqual(sSound[len-3], "mp3") || StrEqual(sSound[len-3], "wav")))         {             g_iSoundEnts[g_iNumSounds++] = EntIndexToEntRef(entity);         }     }         CreateTimer(5.0, AfterRoundStart); } Client_StopSound(client, entity, channel, const String:name[]) {     EmitSoundToClient(client, name, entity, channel, SNDLEVEL_NONE, SND_STOP, 0.0, SNDPITCH_NORMAL, _, _, _, true); } public Action:AfterRoundStart(Handle:timer){     for(new client = 1; client<=MaxClients; client++){         if(!IsClientInGame(client))         {             continue;         }                 if(g_toggle){             decl String:sSound[PLATFORM_MAX_PATH], entity;             for (new i = 0; i < g_iNumSounds; i++)             {                 entity = EntRefToEntIndex(g_iSoundEnts[i]);                                 if (entity != INVALID_ENT_REFERENCE)                 {                     GetEntPropString(entity, Prop_Data, "m_iszSound", sSound, sizeof(sSound));                     Client_StopSound(client, entity, SNDCHAN_STATIC, sSound);                 }             }         }     } }

Try this
Thanks but looks for whole server not only 1 player.
yazeed98 is offline