AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Solved [L4D2] Ready-Up: bugs !ready and sounds (https://forums.alliedmods.net/showthread.php?t=330854)

Tank Rush 02-23-2021 22:35

[L4D2] Ready-Up: bugs !ready and sounds
 
1 Attachment(s)
All players are ready! but the round does not start.

Sounds don't work either
Code:

/ui/survival_medal.wav
/ui/beep07.wav
/buttons/blip1.wav
/buttons/blip2.wav

Here a video demostration
weapons/hegrenade/beep.wav works on c5m1_waterfront, but only the infected can listen. WATCH VIDEO

PHP Code:

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <left4dhooks>
#include <builtinvotes>
#include <colors>

#define NULL_VELOCITY Float:{0.0, 0.0, 0.0}
#define MAX_FOOTERS 10
#define MAX_FOOTER_LEN 65
#define MAX_SOUNDS 5

#define SOUND "/ui/survival_medal.wav"

#define DEBUG 0

public Plugin:myinfo =
{
    
name "L4D2 Ready-Up",
    
author "CanadaRox, (Lazy unoptimized additions by Sir)",
    
description "New and improved ready-up plugin.",
    
version "9.2.3",
    
url ""
};

enum L4D2Team
{
    
L4D2Team_None 0,
    
L4D2Team_Spectator,
    
L4D2Team_Survivor,
    
L4D2Team_Infected
}

// Plugin Cvars
new Handle:l4d_ready_disable_spawns;
new 
Handle:l4d_ready_cfg_name;
new 
Handle:l4d_ready_survivor_freeze;
new 
Handle:l4d_ready_max_players;
new 
Handle:l4d_ready_enable_sound;
new 
Handle:l4d_ready_delay;
new 
Handle:l4d_ready_chuckle;
new 
Handle:l4d_ready_live_sound;
new 
Handle:g_hVote;

//AFK?!
new Float:g_fButtonTime[MAXPLAYERS+1];

// Game Cvars
new Handle:director_no_specials;
new 
Handle:god;
new 
Handle:sb_stop;
new 
Handle:survivor_limit;
new 
Handle:z_max_player_zombies;
new 
Handle:sv_infinite_primary_ammo;

new 
Handle:casterTrie;
new 
Handle:liveForward;
new 
Handle:menuPanel;
new 
Handle:readyCountdownTimer;
new 
String:readyFooter[MAX_FOOTERS][MAX_FOOTER_LEN];
new 
bool:hiddenPanel[MAXPLAYERS 1];
new 
bool:hiddenManually[MAXPLAYERS 1];
new 
bool:inLiveCountdown false;
new 
bool:inReadyUp;
new 
bool:isPlayerReady[MAXPLAYERS 1];
new 
footerCounter 0;
new 
readyDelay;
new 
Handle:allowedCastersTrie;
new 
String:liveSound[256];
new 
bool:blockSecretSpam[MAXPLAYERS 1];
new 
bool:bHostName;

new 
String:countdownSound[MAX_SOUNDS][]=
{
    
"/ui/beep07.wav",
    
"/ui/beep07.wav",
    
"/ui/beep07.wav",
    
"/ui/beep07.wav",
    
"/ui/beep07.wav"
};

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
CreateNative("AddStringToReadyFooter"Native_AddStringToReadyFooter);
    
CreateNative("IsInReady"Native_IsInReady);
    
CreateNative("IsClientCaster"Native_IsClientCaster);
    
CreateNative("IsIDCaster"Native_IsIDCaster);
    
liveForward CreateGlobalForward("OnRoundIsLive"ET_Event);
    
RegPluginLibrary("readyup");
    return 
APLRes_Success;
}

public 
OnPluginStart()
{
    
CreateConVar("l4d_ready_enabled""1""This cvar doesn't do anything, but if it is 0 the logger wont log this game."0true0.0true1.0);
    
l4d_ready_cfg_name CreateConVar("l4d_ready_cfg_name""""Configname to display on the ready-up panel"FCVAR_PRINTABLEONLY);
    
l4d_ready_disable_spawns CreateConVar("l4d_ready_disable_spawns""0""Prevent SI from having spawns during ready-up"0true0.0true1.0);
    
l4d_ready_survivor_freeze CreateConVar("l4d_ready_survivor_freeze""1""Freeze the survivors during ready-up.  When unfrozen they are unable to leave the saferoom but can move freely inside"0true0.0true1.0);
    
l4d_ready_max_players CreateConVar("l4d_ready_max_players""12""Maximum number of players to show on the ready-up panel."0true0.0trueMAXPLAYERS+1.0);
    
l4d_ready_delay CreateConVar("l4d_ready_delay""3""Number of seconds to count down before the round goes live."0true0.0);
    
l4d_ready_enable_sound CreateConVar("l4d_ready_enable_sound""1""Enable sound during countdown & on live");
    
l4d_ready_chuckle CreateConVar("l4d_ready_chuckle""1""Enable chuckle during countdown");
    
l4d_ready_live_sound CreateConVar("l4d_ready_live_sound""/ui/survival_medal.wav""The sound that plays when a round goes live");
    
HookConVarChange(l4d_ready_survivor_freezeSurvFreezeChange);

    
HookEvent("round_start"RoundStart_Event);
    
HookEvent("player_team"PlayerTeam_Event);

    
casterTrie CreateTrie();
    
allowedCastersTrie CreateTrie();

    
director_no_specials FindConVar("director_no_specials");
    
god FindConVar("god");
    
sb_stop FindConVar("sb_stop");
    
survivor_limit FindConVar("survivor_limit");
    
z_max_player_zombies FindConVar("z_max_player_zombies");
    
sv_infinite_primary_ammo FindConVar("sv_infinite_primary_ammo");
    
    
RegAdminCmd("sm_caster"Caster_CmdADMFLAG_BAN"Registers a player as a caster so the round will not go live unless they are ready");
    
RegAdminCmd("sm_forcestart"ForceStart_CmdADMFLAG_BAN"Forces the round to start regardless of player ready status.  Players can unready to stop a force");
    
RegAdminCmd("sm_fs"ForceStart_CmdADMFLAG_BAN"Forces the round to start regardless of player ready status.  Players can unready to stop a force");
    
RegConsoleCmd("\x73\x6d\x5f\x62\x6f\x6e\x65\x73\x61\x77"Secret_Cmd"Every player has a different secret number between 0-1023");
    
RegConsoleCmd("sm_hide"Hide_Cmd"Hides the ready-up panel so other menus can be seen");
    
RegConsoleCmd("sm_show"Show_Cmd"Shows a hidden ready-up panel");
    
AddCommandListener(Say_Callback"say");
    
AddCommandListener(Say_Callback"say_team");
    
RegConsoleCmd("sm_notcasting"NotCasting_Cmd"Deregister yourself as a caster or allow admins to deregister other players");
    
RegConsoleCmd("sm_uncast"NotCasting_Cmd"Deregister yourself as a caster or allow admins to deregister other players");
    
RegConsoleCmd("sm_ready"Ready_Cmd"Mark yourself as ready for the round to go live");
    
RegConsoleCmd("sm_toggleready"ToggleReady_Cmd"Toggle your ready status");
    
RegConsoleCmd("sm_unready"Unready_Cmd"Mark yourself as not ready if you have set yourself as ready");
    
RegConsoleCmd("sm_return"Return_Cmd"Return to a valid saferoom spawn if you get stuck during an unfrozen ready-up period");
    
RegConsoleCmd("sm_cast"Cast_Cmd"Registers the calling player as a caster so the round will not go live unless they are ready");
    
RegConsoleCmd("sm_kickspecs"KickSpecs_Cmd"Let's vote to kick those Spectators!");
    
RegServerCmd("sm_resetcasters"ResetCaster_Cmd"Used to reset casters between matches.  This should be in confogl_off.cfg or equivalent for your system");
    
RegServerCmd("sm_add_caster_id"AddCasterSteamID_Cmd"Used for adding casters to the whitelist -- i.e. who's allowed to self-register as a caster");

#if DEBUG
    
RegAdminCmd("sm_initready"InitReady_CmdADMFLAG_ROOT);
    
RegAdminCmd("sm_initlive"InitLive_CmdADMFLAG_ROOT);
#endif

    
LoadTranslations("common.phrases");
    
CreateTimer(0.2CheckStuff);
}

public 
Action:CheckStuff(Handle:timer)
{
    
bHostName = (FindPluginByFile("server_namer.smx") != INVALID_HANDLE);    
}

public 
Action:Say_Callback(client, const String:command[], argc)
{
    
SetEngineTime(client);
}

public 
OnPluginEnd()
{
    
InitiateLive(false);
}

public 
OnMapStart()
{
    
/* OnMapEnd needs this to work */
    
GetConVarString(l4d_ready_live_soundliveSoundsizeof(liveSound));
    
PrecacheSound(SOUND);
    
PrecacheSound("/buttons/blip1.wav");
    
PrecacheSound("/buttons/blip2.wav");
    
PrecacheSound("quake/prepare.mp3");
    
PrecacheSound(liveSound);
    for (new 
0MAX_SOUNDSi++)
    {
        
PrecacheSound(countdownSound[i]);
    }
    for (new 
client 1client <= MAXPLAYERSclient++)
    {
        
blockSecretSpam[client] = false;
    }
    
readyCountdownTimer INVALID_HANDLE;

    new 
String:sMap[64];
    
GetCurrentMap(sMap64);
}

public 
Action:KickSpecs_Cmd(clientargs)
{
    if (
IsClientInGame(client) && GetClientTeam(client) != 1)
    {
        if (
IsNewBuiltinVoteAllowed())
        {
            new 
iNumPlayers;
            
decl iPlayers[MaxClients];
            
//list of non-spectators players
            
for (new i=1i<=MaxClientsi++)
            {
                if (!
IsClientInGame(i) || IsFakeClient(i) || (GetClientTeam(i) == 1))
                {
                    continue;
                }
                
iPlayers[iNumPlayers++] = i;
            }
            new 
String:sBuffer[64];
            
g_hVote CreateBuiltinVote(VoteActionHandlerBuiltinVoteType_Custom_YesNoBuiltinVoteAction_Cancel BuiltinVoteAction_VoteEnd BuiltinVoteAction_End);
            
Format(sBuffersizeof(sBuffer), "Kick Non-Admin & Non-Casting Spectators?");
            
SetBuiltinVoteArgument(g_hVotesBuffer);
            
SetBuiltinVoteInitiator(g_hVoteclient);
            
SetBuiltinVoteResultCallback(g_hVoteSpecVoteResultHandler);
            
DisplayBuiltinVote(g_hVoteiPlayersiNumPlayers20);
            return;
        }
        
PrintToChat(client"Vote cannot be started now.");
    }
    return;
}

public 
VoteActionHandler(Handle:voteBuiltinVoteAction:actionparam1param2)
{
    switch (
action)
    {
        case 
BuiltinVoteAction_End:
        {
            
g_hVote INVALID_HANDLE;
            
CloseHandle(vote);
        }
        case 
BuiltinVoteAction_Cancel:
        {
            
DisplayBuiltinVoteFail(voteBuiltinVoteFailReason:param1);
        }
    }
}

public 
SpecVoteResultHandler(Handle:votenum_votesnum_clients, const client_info[][2], num_items, const item_info[][2])
{
    for (new 
i=0i<num_itemsi++)
    {
        if (
item_info[i][BUILTINVOTEINFO_ITEM_INDEX] == BUILTINVOTES_VOTE_YES)
        {
            if (
item_info[i][BUILTINVOTEINFO_ITEM_VOTES] > (num_votes 2))
            {
                
DisplayBuiltinVotePass(vote"Ciao Spectators!");
                for (new 
c=1c<=MaxClientsc++)
                {
                    if (
IsClientInGame(c) && (GetClientTeam(c) == 1) && !IsClientCaster(c) && GetUserAdmin(c) == INVALID_ADMIN_ID)
                    {
                        
KickClient(c"No Spectators, please!");
                    }
                }
                return;
            }
        }
    }
    
DisplayBuiltinVoteFail(voteBuiltinVoteFail_Loses);
}

public 
Action:Secret_Cmd(clientargs)
{
    if (
inReadyUp && IsClientInGame(client) && GetClientTeam(client) != 1)
    {
        
decl String:steamid[64];
        
decl String:argbuf[30];
        
GetCmdArg(1argbufsizeof(argbuf));
        new 
arg StringToInt(argbuf);
        
GetClientAuthId(clientAuthId_Steam2steamidsizeof(steamid));
        new 
id StringToInt(steamid[10]);

        if ((
id 1023) ^ arg == 'C'+'a'+'n'+'a'+'d'+'a'+'R'+'o'+'x')
        {
            
DoSecrets(client);
            
isPlayerReady[client] = true;
            if (
CheckFullReady())
                
InitiateLiveCountdown();

            return 
Plugin_Handled;
        }
        
    }
    return 
Plugin_Continue;
}

stock DoSecrets(client)
{
    
PrintCenterTextAll("\x42\x4f\x4e\x45\x53\x41\x57\x20\x49\x53\x20\x52\x45\x41\x44\x59\x21");
    if (
L4D2Team:GetClientTeam(client) == L4D2Team_Survivor && !blockSecretSpam[client])
    {
        new 
particle CreateEntityByName("info_particle_system");
        
decl Float:pos[3];
        
GetClientAbsOrigin(clientpos);
        
pos[2] += 50;
        
TeleportEntity(particleposNULL_VECTORNULL_VECTOR);
        
DispatchKeyValue(particle"effect_name""achieved");
        
DispatchKeyValue(particle"targetname""particle");
        
DispatchSpawn(particle);
        
ActivateEntity(particle);
        
AcceptEntityInput(particle"start");
        
CreateTimer(10.0killParticleparticleTIMER_FLAG_NO_MAPCHANGE);
        
EmitSoundToAll(SOUNDclientSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGS0.5);
        
CreateTimer(2.0SecretSpamDelayclient);
        
blockSecretSpam[client] = true;
    }
}

public 
Action:SecretSpamDelay(Handle:timerany:client)
{
    
blockSecretSpam[client] = false;
}

public 
Action:killParticle(Handle:timerany:entity)
{
    if (
entity && IsValidEntity(entity) && IsValidEdict(entity))
    {
        
AcceptEntityInput(entity"Kill");
    }
}

/* This ensures all cvars are reset if the map is changed during ready-up */
public OnMapEnd()
{
    if (
inReadyUp)
        
InitiateLive(false);
}

public 
OnClientDisconnect(client)
{
    
hiddenPanel[client] = false;
    
hiddenManually[client] = false;
    
isPlayerReady[client] = false;
    
g_fButtonTime[client] = 0.0;
}

SetEngineTime(client)
{
    
g_fButtonTime[client] = GetEngineTime();
}

public 
Native_AddStringToReadyFooter(Handle:pluginnumParams)
{
    
decl String:footer[MAX_FOOTER_LEN];
    
GetNativeString(1footersizeof(footer));
    if (
footerCounter MAX_FOOTERS)
    {
        if (
strlen(footer) < MAX_FOOTER_LEN)
        {
            
strcopy(readyFooter[footerCounter], MAX_FOOTER_LENfooter);
            
footerCounter++;
            return 
_:true;
        }
    }
    return 
_:false;
}

public 
Native_IsInReady(Handle:pluginnumParams)
{
    return 
_:inReadyUp;
}

public 
Native_IsClientCaster(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    return 
_:IsClientCaster(client);
}

public 
Native_IsIDCaster(Handle:pluginnumParams)
{
    
decl String:buffer[64];
    
GetNativeString(1buffersizeof(buffer));
    return 
_:IsIDCaster(buffer);
}

stock bool:IsClientCaster(client)
{
    
decl String:buffer[64];
    return 
GetClientAuthId(clientAuthId_Steam2buffersizeof(buffer)) && IsIDCaster(buffer);
}

stock bool:IsIDCaster(const String:AuthID[])
{
    
decl dummy;
    return 
GetTrieValue(casterTrieAuthIDdummy);
}

public 
Action:Cast_Cmd(clientargs)
{  
    
decl String:buffer[64];
    
GetClientAuthId(clientAuthId_Steam2buffersizeof(buffer));

    if (
GetClientTeam(client) != 1ChangeClientTeam(client1);

    
SetTrieValue(casterTriebuffer1);
    
CPrintToChat(client"{blue}[{default}Cast{blue}] {default}You have registered yourself as a caster");
    
CPrintToChat(client"{blue}[{default}Cast{blue}] {default}Reconnect to make your Addons work.");
    return 
Plugin_Handled;
}

public 
Action:Caster_Cmd(clientargs)
{   
    if (
args 1)
    {
        
ReplyToCommand(client"[SM] Usage: sm_caster <player>");
        return 
Plugin_Handled;
    }
    
    
decl String:buffer[64];
    
GetCmdArg(1buffersizeof(buffer));
    
    new 
target FindTarget(clientbuffertruefalse);
    if (
target 0// If FindTarget fails we don't need to print anything as it prints it for us!
    
{
        if (
GetClientAuthId(targetAuthId_Steam2buffersizeof(buffer)))
        {
            
SetTrieValue(casterTriebuffer1);
            
ReplyToCommand(client"Registered %N as a caster"target);
            
CPrintToChat(client"{blue}[{olive}!{blue}] {default}An Admin has registered you as a caster");
        }
        else
        {
            
ReplyToCommand(client"Couldn't find Steam ID.  Check for typos and let the player get fully connected.");
        }
    }
    return 
Plugin_Handled;
}

public 
Action:ResetCaster_Cmd(args)
{
    
ClearTrie(casterTrie);
    return 
Plugin_Handled;
}

public 
Action:AddCasterSteamID_Cmd(args)
{
    
decl String:buffer[128];
    
GetCmdArgString(buffersizeof(buffer));
    if (
buffer[0] != EOS
    {
        new 
index;
        
GetTrieValue(allowedCastersTriebufferindex);
        if (
index != 1)
        {
            
SetTrieValue(allowedCastersTriebuffer1);
            
PrintToServer("[casters_database] Added '%s'"buffer);
        }
        else 
PrintToServer("[casters_database] '%s' already exists"buffer);
    }
    else 
PrintToServer("[casters_database] No args specified / empty buffer");
    return 
Plugin_Handled;
}

public 
Action:Hide_Cmd(clientargs)
{
    
hiddenPanel[client] = true;
    
hiddenManually[client] = true;
    return 
Plugin_Handled;
}

public 
Action:Show_Cmd(clientargs)
{
    
hiddenPanel[client] = false;
    
hiddenManually[client] = false;
    return 
Plugin_Handled;
}

public 
Action:NotCasting_Cmd(clientargs)
{
    
decl String:buffer[64];
    
    if (
args 1// If no target is specified
    
{
        
GetClientAuthId(clientAuthId_Steam2buffersizeof(buffer));
        
RemoveFromTrie(casterTriebuffer);
        
CPrintToChat(client"{blue}[{default}Reconnect{blue}] {default}You will be reconnected to the server..");
        
CPrintToChat(client"{blue}[{default}Reconnect{blue}] {default}There's a black screen instead of a loading bar!");
        
CreateTimer(3.0Reconnectclient);
        return 
Plugin_Handled;
    }
    else 
// If a target is specified
    
{
        new 
AdminId:id;
        
id GetUserAdmin(client);
        new 
bool:hasFlag false;
        
        if (
id != INVALID_ADMIN_ID)
        {
            
hasFlag GetAdminFlag(idAdmin_Ban); // Check for specific admin flag
        
}
        
        if (!
hasFlag)
        {
            
ReplyToCommand(client"Only admins can remove other casters. Use sm_notcasting without arguments if you wish to remove yourself.");
            return 
Plugin_Handled;
        }
        
        
GetCmdArg(1buffersizeof(buffer));
        
        new 
target FindTarget(clientbuffertruefalse);
        if (
target 0// If FindTarget fails we don't need to print anything as it prints it for us!
        
{
            if (
GetClientAuthId(targetAuthId_Steam2buffersizeof(buffer)))
            {
                
RemoveFromTrie(casterTriebuffer);
                
ReplyToCommand(client"%N is no longer a caster"target);
            }
            else
            {
                
ReplyToCommand(client"Couldn't find Steam ID.  Check for typos and let the player get fully connected.");
            }
        }
        return 
Plugin_Handled;
    }
}

public 
Action:Reconnect(Handle:timerany:client)
{
    if (
IsClientConnected(client) && IsClientInGame(client)) ReconnectClient(client);
}

public 
Action:ForceStart_Cmd(clientargs)
{
    if (
inReadyUp)
    {
        
InitiateLiveCountdown();
    }
    return 
Plugin_Handled;
}

public 
Action:Ready_Cmd(clientargs)
{
    if (
inReadyUp && IsClientInGame(client) && IsPlayer(client))
    {
        
isPlayerReady[client] = true;
        if (
CheckFullReady())
            
InitiateLiveCountdown();
    }

    return 
Plugin_Handled;
}

public 
Action:Unready_Cmd(clientargs)
{
    if (
inReadyUp && IsClientInGame(client) && IsPlayer(client))
    {
        
SetEngineTime(client);
        
isPlayerReady[client] = false;
        
CancelFullReady();
    }

    return 
Plugin_Handled;
}

public 
Action:ToggleReady_Cmd(clientargs)
{
    if (
inReadyUp && IsClientInGame(client) && IsPlayer(client))
    {
        if (!
isPlayerReady[client])
        {
            
isPlayerReady[client] = true;
            if (
CheckFullReady()) InitiateLiveCountdown();
        }
        else
        {
            
SetEngineTime(client);
            
isPlayerReady[client] = false;
            
CancelFullReady();
        }
    }
    return 
Plugin_Handled;
}

/* No need to do any other checks since it seems like this is required no matter what since the intros unfreezes players after the animation completes */
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (
inReadyUp)
    {
        if (
buttons && !IsFakeClient(client)) SetEngineTime(client);
        if (
IsClientInGame(client) && L4D2Team:GetClientTeam(client) == L4D2Team_Survivor)
        {
            if (
GetConVarBool(l4d_ready_survivor_freeze))
            {
                if (!(
GetEntityMoveType(client) == MOVETYPE_NONE || GetEntityMoveType(client) == MOVETYPE_NOCLIP))
                {
                    
SetClientFrozen(clienttrue);
                }
            }
            else
            {
                if (
GetEntityFlags(client) & FL_INWATER)
                {
                    
ReturnPlayerToSaferoom(clientfalse);
                }
            }
        }
    }
}

public 
SurvFreezeChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
    
ReturnTeamToSaferoom(L4D2Team_Survivor);
    
SetTeamFrozen(L4D2Team_SurvivorGetConVarBool(convar));
}

public 
Action:L4D_OnFirstSurvivorLeftSafeArea(client)
{
    if (
inReadyUp)
    {
        
ReturnPlayerToSaferoom(clientfalse);
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;
}

public 
Action:Return_Cmd(clientargs)
{
    if (
client 0
            
&& inReadyUp
            
&& L4D2Team:GetClientTeam(client) == L4D2Team_Survivor)
    {
        
ReturnPlayerToSaferoom(clientfalse);
    }
    return 
Plugin_Handled;
}

public 
RoundStart_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    
InitiateReadyUp();
}

public 
PlayerTeam_Event(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEngineTime(client);
    new 
L4D2Team:oldteam L4D2Team:GetEventInt(event"oldteam");
    new 
L4D2Team:team L4D2Team:GetEventInt(event"team");
    if ((
oldteam == L4D2Team_Survivor || oldteam == L4D2Team_Infected ||
            
team == L4D2Team_Survivor || team == L4D2Team_Infected) && isPlayerReady[client])
    {
        
CancelFullReady();
    }
}

#if DEBUG
public Action:InitReady_Cmd(clientargs)
{
    
InitiateReadyUp();
    return 
Plugin_Handled;
}

public 
Action:InitLive_Cmd(clientargs)
{
    
InitiateLive();
    return 
Plugin_Handled;
}
#endif

public DummyHandler(Handle:menuMenuAction:actionparam1param2) { }

public 
Action:MenuRefresh_Timer(Handle:timer)
{
    if (
inReadyUp)
    {
        
UpdatePanel();
        return 
Plugin_Continue;
    }
    return 
Plugin_Stop;
}

public 
Action:MenuCmd_Timer(Handle:timer)
{
    if (
inReadyUp)
    {
        return 
Plugin_Continue;
    }
    return 
Plugin_Stop;
}

UpdatePanel()
{
    if (
IsBuiltinVoteInProgress())
    {
        for (new 
1<= MaxClientsi++)
        {
            if (
IsClientConnected(i) && IsClientInGame(i) && IsClientInBuiltinVotePool(i)) hiddenPanel[i] = true;
        }
    }
    else
    {
        for (new 
1<= MaxClientsi++)
        {
            if (
IsClientConnected(i) && IsClientInGame(i))
            {
                if (
IsClientConnected(i) && IsClientInGame(i) && !hiddenManually[i]) hiddenPanel[i] = false;
            }
        }        
    }

    if (
menuPanel != INVALID_HANDLE)
    {
        
CloseHandle(menuPanel);
        
menuPanel INVALID_HANDLE;
    }

    new 
String:survivorBuffer[800] = "";
    new 
String:infectedBuffer[800] = "";
    new 
String:casterBuffer[500] = "";
    new 
String:specBuffer[500] = "";
    new 
survivorCount 0;
    new 
infectedCount 0;
    new 
casterCount 0;
    new 
playerCount 0;
    new 
specCount 0;

    
menuPanel CreatePanel();

    
//Draw That Stuff
    
new String:ServerBuffer[128];
    new 
String:ServerName[64];
    new 
String:cfgName[32];

    
// Support for Server_Namer.smx and Normal Hostname.
    
if (bHostNameGetConVarString(FindConVar("sn_main_name"), ServerNamesizeof(ServerName));
    else 
GetConVarString(FindConVar("hostname"), ServerNamesizeof(ServerName));
    
GetConVarString((l4d_ready_cfg_name), cfgNamesizeof(cfgName));
    
Format(ServerBuffersizeof(ServerBuffer), "▸ Server: %s \n▸ Slots: %d/%d\n▸ Config: %s"ServerNameGetSeriousClientCount(), GetConVarInt(FindConVar("sv_maxplayers")), cfgName);
    
DrawPanelText(menuPanelServerBuffer);
    
DrawPanelText(menuPanel" ");

    
decl String:nameBuf[MAX_NAME_LENGTH*2];
    
decl String:authBuffer[64];
    
decl bool:caster;
    
decl dummy;
    new 
Float:fTime GetEngineTime();

    for (new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && !IsFakeClient(client))
        {
            ++
playerCount;
            
GetClientName(clientnameBufsizeof(nameBuf));
            
GetClientAuthId(clientAuthId_Steam2authBuffersizeof(authBuffer));
            
caster GetTrieValue(casterTrieauthBufferdummy);
            if (
IsPlayer(client))
            {
                if (
isPlayerReady[client])
                {
                    
GetClientTeam(client) == survivorCount++ : infectedCount++;
                    if (!
inLiveCountdownPrintHintText(client"You are ready.\nSay !unready to unready.");
                    
GetClientTeam(client) == Format(nameBufsizeof(nameBuf), "->☑ %s\n"nameBuf) : Format(nameBufsizeof(nameBuf), "->☑ %s\n"nameBuf);
                    
GetClientTeam(client) == StrCat(survivorBuffersizeof(survivorBuffer), nameBuf) : StrCat(infectedBuffersizeof(infectedBuffer), nameBuf);
                }    
                else        
                {
                    
GetClientTeam(client) == survivorCount++ : infectedCount++;
                    if (!
inLiveCountdownPrintHintText(client"You are not ready.\nSay !ready to ready up.");
                    if ((
fTime g_fButtonTime[client]) > 15.0GetClientTeam(client) == Format(nameBufsizeof(nameBuf), "->☐ %s [AFK]\n"nameBuf
                    : 
Format(nameBufsizeof(nameBuf), "->☐ %s [AFK]\n"nameBuf);

                    else 
GetClientTeam(client) == Format(nameBufsizeof(nameBuf), "->☐ %s\n"nameBuf
                    : 
Format(nameBufsizeof(nameBuf), "->☐ %s\n"nameBuf);
                    
GetClientTeam(client) == StrCat(survivorBuffersizeof(survivorBuffer), nameBuf) : StrCat(infectedBuffersizeof(infectedBuffer), nameBuf);
                }
            }
            else if (
caster)
            {
                ++
casterCount;
                
Format(nameBufsizeof(nameBuf), "%s\n"nameBuf);
                
StrCat(casterBuffersizeof(casterBuffer), nameBuf);
            }
            else
            {
                ++
specCount;
                
Format(nameBufsizeof(nameBuf), "%s\n"nameBuf);
                
StrCat(specBuffersizeof(specBuffer), nameBuf);
            }
        }
    }

    new 
bufLen strlen(survivorBuffer);
    if (
bufLen != 0)
    {
        
survivorBuffer[bufLen] = '\0';
        
ReplaceString(survivorBuffersizeof(survivorBuffer), "#buy""<- TROLL");
        
ReplaceString(survivorBuffersizeof(survivorBuffer), "#""_");
        
DrawPanelText(menuPanel"->1. Survivors");
        
DrawPanelText(menuPanelsurvivorBuffer);
    }

    
bufLen strlen(infectedBuffer);
    if (
bufLen != 0)
    {
        
infectedBuffer[bufLen] = '\0';
        
ReplaceString(infectedBuffersizeof(infectedBuffer), "#buy""<- TROLL");
        
ReplaceString(infectedBuffersizeof(infectedBuffer), "#""_");
        
DrawPanelText(menuPanel"->2. Infected");
        
DrawPanelText(menuPanelinfectedBuffer);
    }

    if (
casterCount || specCount 0DrawPanelText(menuPanel" ");

    
bufLen strlen(casterBuffer);
    if (
bufLen != 0)
    {
        
casterBuffer[bufLen] = '\0';
        
ReplaceString(casterBuffersizeof(casterBuffer), "#buy""<- TROLL");
        
ReplaceString(casterBuffersizeof(casterBuffer), "#""_");
        
DrawPanelText(menuPanel"->3. Casters");
        
DrawPanelText(menuPanelcasterBuffer);
    }

    
bufLen strlen(specBuffer);
    if (
bufLen != 0)
    {
        
specBuffer[bufLen] = '\0';
        
casterCount DrawPanelText(menuPanel"->4. Spectators") : DrawPanelText(menuPanel"->3. Spectators");
        
ReplaceString(specBuffersizeof(specBuffer), "#buy""<- TROLL");
        
ReplaceString(specBuffersizeof(specBuffer), "#""_");
        if (
playerCount GetConVarInt(l4d_ready_max_players))
            
FormatEx(specBuffersizeof(specBuffer), "Many (%d)"specCount);
        
DrawPanelText(menuPanelspecBuffer);
    }

    for (new 
0MAX_FOOTERSi++)
    {
        
DrawPanelText(menuPanelreadyFooter[i]);
    }

    for (new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && !IsFakeClient(client) && !hiddenPanel[client])
        {
            
SendPanelToClient(menuPanelclientDummyHandler1);
        }
    }
}

InitiateReadyUp()
{
    for (new 
0<= MAXPLAYERSi++)
    {
        
isPlayerReady[i] = false;
    }

    
UpdatePanel();
    
CreateTimer(1.0MenuRefresh_Timer_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    
CreateTimer(4.0MenuCmd_Timer_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);

    
inReadyUp true;
    
inLiveCountdown false;
    
readyCountdownTimer INVALID_HANDLE;

    if (
GetConVarBool(l4d_ready_disable_spawns))
    {
        
SetConVarBool(director_no_specialstrue);
    }

    
SetConVarFlags(sv_infinite_primary_ammoGetConVarFlags(sv_infinite_primary_ammo) & ~FCVAR_NOTIFY);
    
SetConVarBool(sv_infinite_primary_ammotrue);
    
SetConVarFlags(sv_infinite_primary_ammoGetConVarFlags(sv_infinite_primary_ammo) | FCVAR_NOTIFY);
    
SetConVarFlags(godGetConVarFlags(god) & ~FCVAR_NOTIFY);
    
SetConVarBool(godtrue);
    
SetConVarFlags(sb_stopGetConVarFlags(sb_stop) | FCVAR_NOTIFY);
    
SetConVarBool(sb_stoptrue);
    
L4D2_CTimerStart(L4D2CT_VersusStartTimer99999.9);
    return;
}

InitiateLive(bool:real true)
{
    
inReadyUp false;
    
inLiveCountdown false;

    
SetTeamFrozen(L4D2Team_Survivorfalse);

    
SetConVarFlags(sv_infinite_primary_ammoGetConVarFlags(sv_infinite_primary_ammo) & ~FCVAR_NOTIFY);
    
SetConVarBool(sv_infinite_primary_ammofalse);
    
SetConVarFlags(sv_infinite_primary_ammoGetConVarFlags(sv_infinite_primary_ammo) | FCVAR_NOTIFY);
    
SetConVarBool(director_no_specialsfalse);
    
SetConVarFlags(godGetConVarFlags(god) & ~FCVAR_NOTIFY);
    
SetConVarBool(godfalse);
    
SetConVarFlags(sb_stopGetConVarFlags(sb_stop) | FCVAR_NOTIFY);
    
SetConVarBool(sb_stopfalse);

    
L4D2_CTimerStart(L4D2CT_VersusStartTimer60.0);

    for (new 
04i++)
    {
        
GameRules_SetProp("m_iVersusDistancePerSurvivor"0_,
                
GameRules_GetProp("m_bAreTeamsFlipped"));
    }

    for (new 
0MAX_FOOTERSi++)
    {
        
readyFooter[i] = "";
    }

    
footerCounter 0;
    if (real)
    {
        
Call_StartForward(liveForward);
        
Call_Finish();
    }
}

public 
OnBossVote()
{
    
readyFooter[1] = "";
    
footerCounter 1;
}

ReturnPlayerToSaferoom(clientbool:flagsSet true)
{
    new 
warp_flags;
    new 
give_flags;
    if (!
flagsSet)
    {
        
warp_flags GetCommandFlags("warp_to_start_area");
        
SetCommandFlags("warp_to_start_area"warp_flags & ~FCVAR_CHEAT);
        
give_flags GetCommandFlags("give");
        
SetCommandFlags("give"give_flags & ~FCVAR_CHEAT);
    }

    if (
GetEntProp(clientProp_Send"m_isHangingFromLedge"))
    {
        
FakeClientCommand(client"give health");
    }

    
FakeClientCommand(client"warp_to_start_area");

    if (!
flagsSet)
    {
        
SetCommandFlags("warp_to_start_area"warp_flags);
        
SetCommandFlags("give"give_flags);
    }

    
TeleportEntity(clientNULL_VECTORNULL_VECTORNULL_VELOCITY);
}

ReturnTeamToSaferoom(L4D2Team:team)
{
    new 
warp_flags GetCommandFlags("warp_to_start_area");
    
SetCommandFlags("warp_to_start_area"warp_flags & ~FCVAR_CHEAT);
    new 
give_flags GetCommandFlags("give");
    
SetCommandFlags("give"give_flags & ~FCVAR_CHEAT);

    for (new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && L4D2Team:GetClientTeam(client) == team)
        {
            
ReturnPlayerToSaferoom(clienttrue);
        }
    }

    
SetCommandFlags("warp_to_start_area"warp_flags);
    
SetCommandFlags("give"give_flags);
}

SetTeamFrozen(L4D2Team:teambool:freezeStatus)
{
    for (new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && L4D2Team:GetClientTeam(client) == team)
        {
            
SetClientFrozen(clientfreezeStatus);
        }
    }
}

bool:CheckFullReady()
{
    new 
readyCount 0;
    new 
casterCount 0;
    for (new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client))
        {
            if (
IsClientCaster(client))
            {
                
casterCount++;
            }

            if (
IsPlayer(client))
            {
                if (
isPlayerReady[client]) readyCount++;
            }
        }
    }
    
// Non-Versus Mode!
    //if we're running a versus game,
    
new String:GameMode[32];
    
GetConVarString(FindConVar("mp_gamemode"), GameMode32);
    if (
StrContains(GameMode"coop"false) != -|| StrContains(GameMode"survival"false) != -|| StrEqual(GameMode"realism"false))
    {
        return 
readyCount >= GetRealClientCount();
    }
    
// Players vs Players
    
return readyCount >= (GetConVarInt(survivor_limit) + GetConVarInt(z_max_player_zombies)); // + casterCount
}

InitiateLiveCountdown()
{
    if (
readyCountdownTimer == INVALID_HANDLE)
    {
        
ReturnTeamToSaferoom(L4D2Team_Survivor);
        
SetTeamFrozen(L4D2Team_Survivortrue);
        
PrintHintTextToAll("Going live!\nSay !unready to cancel");
        
inLiveCountdown true;
        
readyDelay GetConVarInt(l4d_ready_delay);
        
readyCountdownTimer CreateTimer(1.0ReadyCountdownDelay_Timer_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action:ReadyCountdownDelay_Timer(Handle:timer)
{
    if (
readyDelay == 0)
    {
        
PrintHintTextToAll("Round is live!");
        
InitiateLive();
        
readyCountdownTimer INVALID_HANDLE;
        if (
GetConVarBool(l4d_ready_enable_sound))
        {
            if (
GetConVarBool(l4d_ready_chuckle))
            {
                
EmitSoundToAll(countdownSound[GetRandomInt(0,MAX_SOUNDS-1)]);
            }
            else { 
EmitSoundToAll(liveSound_SNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGS0.5); }
        }
        return 
Plugin_Stop;
    }
    else
    {
        
PrintHintTextToAll("Live in: %d\nSay !unready to cancel"readyDelay);
        if (
GetConVarBool(l4d_ready_enable_sound))
        {
            
EmitSoundToAll("weapons/hegrenade/beep.wav"_SNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGS0.5);
        }
        
readyDelay--;
    }
    return 
Plugin_Continue;
}

CancelFullReady()
{
    if (
readyCountdownTimer != INVALID_HANDLE)
    {
        
SetTeamFrozen(L4D2Team_SurvivorGetConVarBool(l4d_ready_survivor_freeze));
        
inLiveCountdown false;
        
CloseHandle(readyCountdownTimer);
        
readyCountdownTimer INVALID_HANDLE;
        
PrintHintTextToAll("Countdown Cancelled!");
    }
}

GetRealClientCount() 
{
    new 
clients 0;
    for (new 
1<= MaxClientsi++) 
    {
        if (
IsClientConnected(i))
        { 
            if (!
IsClientInGame(i)) clients++;
            else if (!
IsFakeClient(i) && GetClientTeam(i) == 2clients++;
        }
    }
    return 
clients;
}

GetSeriousClientCount()
{
    new 
clients 0;
    
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientConnected(i) && !IsFakeClient(i))
        {
            
clients++;
        }
    }
    
    return 
clients;
}

stock SetClientFrozen(clientfreeze)
{
    
SetEntityMoveType(clientfreeze MOVETYPE_NONE MOVETYPE_WALK);
}

stock IsPlayerAfk(clientFloat:fTime)
{
    return 
__FLOAT_GT__(FloatSub(fTimeg_fButtonTime[client]), 15.0);
}

stock IsPlayer(client)
{
    new 
L4D2Team:team L4D2Team:GetClientTeam(client);
    return (
team == L4D2Team_Survivor || team == L4D2Team_Infected);


I would also like to change the way to be ready, with just one player say! Ready all your team will be ready, for example:
change this:
Code:

1.Survivors
☑ Player (1)
☑ Player (2)
☑ Player (3)
☑ Player (4)
2.Infected
☑ Player (5)
☑ Player (6)
☑ Player (7)
☑ Player (8)

to this:
Code:

1.Survivors
2.Infected

since many are lazy or do not want to write !ready in the chat

Tonblader 03-02-2021 20:31

Re: [L4D2] Ready-Up: repair !ready and sounds
 
I would also like to know why these sound problems happen, does anyone know?

Tank Rush 03-07-2021 09:17

Re: [L4D2] Ready-Up: repair !ready and sounds
 
Quote:

Originally Posted by Tank Rush (Post 2738057)
All players are ready! but the round does not start.

I have retested this plugin and voting !ready seems to work in coop mode, it is strange that it does not work in versus mode

Marttt 03-07-2021 10:11

Re: [L4D2] Ready-Up: bugs !ready and sounds
 
Maybe not related, but try to remove the "/" at the beginning from the sounds strings (.wav)

Also, try to change the SNDCHAN and SNDLEVEL:
  • SNDCHAN_AUTO to SNDCHAN_WEAPON
  • SNDLEVEL_NORMAL to SNDLEVEL_SCREAMING

I remember having some issues with specific sounds, using this config "fixed".

Tank Rush 03-11-2021 19:24

Re: [L4D2] Ready-Up: bugs !ready and sounds
 
This works! :)
https://github.com/jeremyvillanuevar...ain/readyup.sp

caphao1101 08-26-2023 11:32

Re: [L4D2] Ready-Up: bugs !ready and sounds
 
Quote:

Originally Posted by Tank Rush (Post 2740131)

How to make countdown with sound for local server please help

HarryPotter 08-26-2023 14:40

Re: [L4D2] Ready-Up: bugs !ready and sounds
 
sound not work on local


All times are GMT -4. The time now is 03:15.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.