/*
1.0.1
- Fixed: Abschalten der Sounds, schaltet gleichzeitig die Chatanzeige mit ab.
*/
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#define MAX_PLAYERS 28
new g_soundtime = 1;
new g_download_index = 0;
new g_soundcount = 0;
new g_Soundoption[29] = { 0, ... };
new String:g_Soundtrigger[300][15];
new String:g_Soundtext[300][95];
new String:g_Soundlocation[300][30];
public Plugin:myinfo =
{
name = "]FUSION[ Sounds",
author = "]FUSION[ Gray Death",
description = "Admin sounds and configuration",
version = "1.0.1b",
url = "http://www.fusion-clan.de/plugins"
};
public OnPluginStart()
{
RegConsoleCmd("say", Command_Say);
HookEvent("round_start", HookRoundStart, EventHookMode_Pre);
HookEvent("round_end", HookRoundEnd, EventHookMode_Pre);
}
public Action:HookRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
g_soundtime = 1;
}
public Action:HookRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
CreateTimer(10.0, End_Startphase);
}
public Action:End_Startphase(Handle:timer)
{
g_soundtime = 0;
}
public OnMapStart()
{
CreateTimer(0.1, Load_Sounds);
}
public Action:Load_Sounds(Handle:timer)
{
new i = 0;
new String:soundlistfile[PLATFORM_MAX_PATH];
BuildPath(Path_SM,soundlistfile,sizeof(soundlistfile),"configs/saysounds.cfg");
if(!FileExists(soundlistfile))
{
LogMessage("saysounds.cfg not parsed...file doesnt exist!");
}
else
{
new Handle:listfile = CreateKeyValues("soundlist");
FileToKeyValues(listfile,soundlistfile);
KvRewind(listfile);
KvGotoFirstSubKey(listfile);
new add_until = g_download_index + 30;
do
{
new String:buffer[15];
new String:soundtext[95];
new String:filelocation[30];
KvGetSectionName(listfile, buffer, sizeof(buffer));
KvGetString(listfile, "file", filelocation, sizeof(filelocation));
KvGetString(listfile, "text", soundtext, sizeof(soundtext));
if(FileExists(filelocation))
{
g_Soundtrigger
= buffer;
g_Soundtext[i] = soundtext;
g_Soundlocation[i] = filelocation;
if(i >= g_download_index && i < add_until)
{
AddFileToDownloadsTable(filelocation);
PrecacheSound(filelocation, true);
}
i++;
}
}
while (KvGotoNextKey(listfile));
CloseHandle(listfile);
g_download_index = add_until;
}
g_soundcount = i;
if(g_download_index > g_soundcount)
{
g_download_index = 0;
}
}
public OnClientAuthorized(client, const String:auth[])
{
if(!IsFakeClient(client))
{
if(client != 0)
{
decl String:temp[3];
GetClientInfo(client, "fsound", temp, 3);
g_Soundoption[client] = StringToInt(temp);
}
}
}
public Action:Command_Say(client,args)
{
if(client != 0)
{
decl String:speech[128];
decl String:clientName[64];
GetClientName(client,clientName,64);
GetCmdArgString(speech,sizeof(speech));
new startidx = 0;
if (speech[0] == '"')
{
startidx = 1;
/* Strip the ending quote, if there is one */
new len = strlen(speech);
if (speech[len-1] == '"')
{
speech[len-1] = '\0';
}
}
if(strcmp(speech[startidx],"/sounds",false) == 0)
{
switch(g_Soundoption[client])
{
case 0:
{
g_Soundoption[client] = 1;
PrintToChat(client,"%c[Sound:] %cWährend Du am Leben bist, werden keine Sounds mehr abgespielt.", 0x03, 0x01);
}
case 1:
{
g_Soundoption[client] = 2;
PrintToChat(client,"%c[Sound:] %cSounds sind jetzt abgeschaltet.", 0x03, 0x01);
}
case 2:
{
g_Soundoption[client] = 3;
PrintToChat(client,"%c[Sound:] %cSounds nur in den Rundenpausen und beim Zuschauen.", 0x03, 0x01);
}
case 3:
{
g_Soundoption[client] = 0;
PrintToChat(client,"%c[Sound:] %cSounds werden immer abgespielt.", 0x03, 0x01);
}
}
return Plugin_Handled;
}
if (speech[startidx] == 'y' || speech[startidx] == '!' || speech[startidx] == 'z')
{
startidx += 1;
}
else
{
return Plugin_Continue;
}
new AdminId:aid = GetUserAdmin(client);
if (aid == INVALID_ADMIN_ID)
{
return Plugin_Continue;
}
new soundfound = -1;
for (new i=0; i < 300; i++)
{
if (strcmp(speech[startidx],g_Soundtrigger[i],false) == 0)
{
soundfound = i;
break;
}
}
new Stringptions[255] = "";
new a = 0;
new matchcheck = 1;
if(strlen(speech[startidx]) < 4)
{
matchcheck = 0;
}
if(soundfound == -1 && matchcheck == 1)
{
for (new i=0; i < 300; i++)
{
if (StrContains(g_Soundtext[i], speech[startidx], false) > -1)
{
if(a > 5)
{
StrCat(options, 255, "(Weitere Moeglichkeiten vorhanden)");
break;
}
StrCat(options, 255, g_Soundtrigger[i]);
StrCat(options, 255, " ");
a++;
soundfound = i;
}
}
}
if(a > 1)
{
PrintToChat(client, "Meintest Du vielleicht: %s", options);
return Plugin_Handled;
}
else if(a == 1 || soundfound > 0)
{
decl String:filelocation[30];
decl String:soundtext[95];
soundtext = g_Soundtext[soundfound];
filelocation = g_Soundlocation[soundfound];
new playersconnected;
playersconnected = GetMaxClients();
for (new ii = 1; ii <= playersconnected; ii++)
{
if(IsClientInGame(ii))
{
switch(g_Soundoption[ii])
{
case 0: // Def: Play sound and text always
{
ClientCommand(ii, "playgamesound \"%s\"", filelocation[6]);
}
case 1:
{
if(!IsPlayerAlive(ii))
{
ClientCommand(ii, "playgamesound \"%s\"", filelocation[6]);
}
}
case 3:
{
{
if(!IsPlayerAlive(ii) || g_soundtime == 1)
{
ClientCommand(ii, "playgamesound \"%s\"", filelocation[6]);
}
}
}
}
PrintToChat(ii,"%s: %s (sound)", clientName, soundtext);
}
}
return Plugin_Handled;
}
}
return Plugin_Continue;
}