WanekWest
Помешан на "Даунских названиях"
- Сообщения
- 442
- Реакции
- 143
Здравствуйте,хотел написать плагин,чтобы во время игрового дня воспроизводилась музыка,которая будет скачиваться у всех клиентов с сервера.Сам фридей был взят с оленей: [CS:GO] MyJailbreak (warden, days, menu & more) [Beta 12 / 15-04-17] - AlliedModders
C-подобный:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_sound>
#include <sdktools_stringtables>
new Handle:g_Array;
new g_Sounds_Count;
new g_CurrPos = -1;
public OnPluginStart()
{
new Handle:dir = OpenDirectory("sound/round_start_music");
if (dir == INVALID_HANDLE)
{
SetFailState("Не удалось открыть \"sound/round_start_music\"");
return;
}
g_Array = CreateArray(150);
decl String:SoundName[150], FileType:type;
while (ReadDirEntry(dir, SoundName, 150, type))
{
if (type == FileType_File && StrContains(SoundName, ".ztmp") == -1)
{
if (StrContains(SoundName, ".mp3") > 0 || StrContains(SoundName, ".wav") > 0)
{
Format(SoundName, 150, "round_start_music/%s", SoundName);
PushArrayString(g_Array, SoundName);
}
}
}
CloseHandle(dir);
if ((g_Sounds_Count = GetArraySize(g_Array)) < 1)
{
SetFailState("В \"sound/round_start_music\" нет звуков");
return;
}
HookEvent("round_freeze_end", round_freeze_end, EventHookMode_PostNoCopy);
// Translation//////////////////////////////////////////////
LoadTranslations("MyJailbreak.Warden.phrases");
LoadTranslations("MyJailbreak.FreeDay.phrases");
// Client Commands
RegConsoleCmd("sm_setfreeday", Command_SetFreeday, "Allows the Admin or Warden to set freeday as next round");
RegConsoleCmd("sm_freeday", Command_VoteFreeday, "Allows players to vote for a freeday");
// AutoExecConfig
AutoExecConfig_SetFile("Freeday", "MyJailbreak/EventDays");
AutoExecConfig_SetCreateFile(true);
AutoExecConfig_CreateConVar("sm_freeday_version", MYJB_VERSION, "The version of this MyJailbreak SourceMod plugin", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
gc_bPlugin = AutoExecConfig_CreateConVar("sm_freeday_enable", "1", "0 - disabled, 1 - enable this MyJailbreak SourceMod plugin", _, true, 0.0, true, 1.0);
gc_sCustomCommandVote = AutoExecConfig_CreateConVar("sm_freeday_cmds_vote", "fd, free", "Set your custom chat command for Event voting(!freeday (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
gc_sCustomCommandSet = AutoExecConfig_CreateConVar("sm_freeday_cmds_set", "sfreeday, sfd", "Set your custom chat command for set Event(!setfreeday (no 'sm_'/'!')(seperate with comma ', ')(max. 12 commands))");
gc_bSetW = AutoExecConfig_CreateConVar("sm_freeday_warden", "1", "0 - disabled, 1 - allow warden to set freeday round", _, true, 0.0, true, 1.0);
gc_bSetA = AutoExecConfig_CreateConVar("sm_freeday_admin", "1", "0 - disabled, 1 - allow admin/vip to set freeday round", _, true, 0.0, true, 1.0);
gc_sAdminFlag = AutoExecConfig_CreateConVar("sm_freeday_flag", "g", "Set flag for admin/vip to set this Event Day.");
gc_bVote = AutoExecConfig_CreateConVar("sm_freeday_vote", "1", "0 - disabled, 1 - allow player to vote for freeday", _, true, 0.0, true, 1.0);
gc_bAuto = AutoExecConfig_CreateConVar("sm_freeday_noct", "1", "0 - disabled, 1 - auto freeday when there is no CT", _, true, 0.0, true, 1.0);
gc_iRespawn = AutoExecConfig_CreateConVar("sm_freeday_respawn", "1", "1 - respawn on NoCT Freeday / 2 - respawn on firstround/vote/set Freeday / 3 - Both", _, true, 1.0, true, 3.0);
gc_iRespawnTime = AutoExecConfig_CreateConVar("sm_freeday_respawn_time", "120", "Time in seconds player will respawn after round begin", _, true, 1.0);
gc_bFirst = AutoExecConfig_CreateConVar("sm_freeday_firstround", "1", "0 - disabled, 1 - auto freeday first round after mapstart", _, true, 0.0, true, 1.0);
gc_bdamage = AutoExecConfig_CreateConVar("sm_freeday_damage", "1", "0 - disabled, 1 - enable damage on freedays", _, true, 0.0, true, 1.0);
gc_iRoundTime = AutoExecConfig_CreateConVar("sm_freeday_roundtime", "5", "Round time in minutes for a single freeday round", _, true, 1.0);
gc_iCooldownDay = AutoExecConfig_CreateConVar("sm_freeday_cooldown_day", "0", "Rounds until freeday can be started again.", _, true, 0.0);
gc_bSetABypassCooldown =
AutoExecConfig_CreateConVar("sm_freeday_cooldown_admin", "1", "0 - disabled, 1 - ignore the cooldown when admin/vip set freeday round", _, true, 0.0, true, 1.0);
AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();
// Hooks
HookEvent("round_start", Event_RoundStart);
HookEvent("round_end", Event_RoundEnd);
HookEvent("player_death", Event_PlayerDeath);
HookConVarChange(gc_sAdminFlag, OnSettingChanged);
// FindConVar
g_iMPRoundTime = FindConVar("mp_roundtime");
g_iCoolDown = gc_iCooldownDay.IntValue + 1;
gc_sAdminFlag.GetString(g_sAdminFlag, sizeof(g_sAdminFlag));
// Logs
SetLogFile(g_sEventsLogFile, "Events", "MyJailbreak");
}
public OnMapStart()
{
if (g_bIsFreeday == true)
{
decl String:SoundName[150];
for (new i = 0; i < g_Sounds_Count; i++)
{
GetArrayString(g_Array, i, SoundName, 150); PrecacheSound(SoundName, true);
Format(SoundName, 150, "sound/%s", SoundName); AddFileToDownloadsTable(SoundName);
}
}
}
public round_freeze_end(Handle:event, const String:name[], bool:silent)
{
if (++g_CurrPos >= g_Sounds_Count) g_CurrPos = 0;
decl String:SoundName[150]; GetArrayString(g_Array, g_CurrPos, SoundName, 150);
EmitSoundToAll(SoundName);
}