Raised This Month: $51 Target: $400
 12% 

[Solved] Countdown Delay Timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eric0279
AlliedModders Donor
Join Date: May 2007
Old 09-07-2013 , 14:26   [Solved] Countdown Delay Timer
Reply With Quote #1

Hello,


original plugin from SirCoding (BasicFixes)

PHP Code:
/* Plugin Template generated by Pawn Studio */

#include <sourcemod>
#include <sdktools>
#include <l4d2util>
#include <sdkhooks>
#include <smlib>
#include <colors>

new Handle:g_hPubBlock               INVALID_HANDLE;

new 
boolbHandled false;
new 
HandlehTimer INVALID_HANDLE;
new 
Handleg_hReady INVALID_HANDLE;
new 
Handle:cvar_delay INVALID_HANDLE;
new 
Handle:readyCountdownTimer;
new 
readyDelay;
new 
Float:delay;

public 
OnPluginStart()
{
    
g_hPubBlock CreateConVar("GSTF_BlockPub""1""Only allow Competitive Games on Server?");
    
g_hReady FindConVar("l4d_ready_enabled");
    
cvar_delay CreateConVar("sm_timer_repeat_delay""50.0""Timer"0true50.0);
    
delay GetConVarFloat(cvar_delay);
    
HookConVarChange(cvar_delayCvarChanged);
    
bHandled false;
}

public 
OnClientPostAdminCheck(client)
{
    if (
bHandled && IsAdminHere() > 0Handled();
    
    if(!
GetConVarBool(g_hPubBlock) || bHandled || GetConVarBool(g_hReady) || IsAdminHere() > || !CheckMaps()) return;
    
    if(
IsValidClient(client) && !IsFakeClient(client))
    {
        
bHandled true;
        
CreateTimer(25.0NotifyPubs_TIMER_REPEAT);
        
hTimer CreateTimer(delayKickPubs);
        if (
readyCountdownTimer == INVALID_HANDLE)
        {
            
readyDelay = (delay-40);
            
readyCountdownTimer CreateTimer(40.0ReadyCountdownDelay_Timer_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
        }
    }
}
/*
public OnClientDisconnect_Post(client)
{
    if(GetRealClientCount() == 0) Handled();
    else
    {
        if(!GetConVarBool(g_hPubBlock) || bHandled || GetConVarBool(g_hReady) || IsAdminHere() > 0 || !CheckMaps()) return;
        
        if(IsValidClient(client) && !IsFakeClient(client))
        {
            bHandled = true;
            CreateTimer(25.0, NotifyPubs, _, TIMER_REPEAT);
            hTimer = CreateTimer(50.0, KickPubs);

        }
    }        
}
*/

public Action:ReadyCountdownDelay_Timer(Handle:timer)
{
    if (
readyDelay == 0)
    {
        return 
Plugin_Stop;
    }
    else
    {
        
// Counter start at 10 ?
        
CPrintToChatAll("{blue}Kick all players in {blue}%d {green}seconds"readyDelay);
        
readyDelay--;
    }
    return 
Plugin_Continue;
}

public 
Action:NotifyPubs(Handle:timer)
{
    if(!
bHandled) return Plugin_Stop;
    
    
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Only use this server for {default}Competitive Play.");
    
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Everyone will be kicked unless a {default}!match {blue}config is loaded.");
    
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Play on Pub {default}: {blue}mm_dedicated_force_servers 46.18.93.40:27015 {default}in your console.");
    return 
Plugin_Continue;
}

public 
Action:KickPubs(Handle:timer)
{
    
ServerCommand("sm_kick @all Only Competitive Play on this Server");
    
Handled();
}

bool:IsValidClient(client)
{
    if (
client <= || client MaxClients) return false;
    if (!
IsClientInGame(client)) return false;
    if (
IsClientSourceTV(client) || IsClientReplay(client)) return false;
    return 
true;
}

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

IsAdminHere()
{
    new 
clients 0;
    for (new 
1<= GetMaxClients(); i++) 
    {
        if(
IsClientInGame(i) && IsClientConnected(i) && Client_IsAdmin(i)) clients++;
    }
    return 
clients;
}

Handled()
{
    
bHandled false;
    if (
hTimer != INVALID_HANDLE)
    {
        
KillTimer(hTimer);
        
hTimer INVALID_HANDLE;
    }
}

// Check if Config has to be loaded - Makes exception for Custom Map play.
CheckMaps()
{
    
decl String:mapname[128];
    
GetCurrentMap(mapnamesizeof(mapname));
    
    if (
strncmp(mapname"c1"2) == 0
    
|| strncmp(mapname"c2"2) == 0
    
|| strncmp(mapname"c3"2) == 0
    
|| strncmp(mapname"c4"2) == 0
    
|| strncmp(mapname"c6"2) == 0
    
|| strncmp(mapname"c7"2) == 0
    
|| strncmp(mapname"c8"2) == 0
    
|| strncmp(mapname"c9"2) == 0
    
|| strncmp(mapname"c10"3) == 0
    
|| strncmp(mapname"c11"3) == 0
    
|| strncmp(mapname"c12"3) == 0
    
|| strncmp(mapname"c13"3) == 0) return true;
    else if (
strncmp(mapname"c5"2) == 0)
    {
        if (
strncmp(mapname"c5m1_dark"9) != 0
        
&& strncmp(mapname"c5m2_dark"9) != 0
        
&& strncmp(mapname"c5m3_dark"9) != 0
        
&& strncmp(mapname"c5m4_dark"9) != 0
        
&& strncmp(mapname"c5m5_dark"9) != 0) return true;
    }
    
    return 
false


I wanted to know if it was okay?

It sets the variable to 10 with subtraction (50-40), we create the timer and when the timer reaches 10, the countdown is displayed to players


PHP Code:
        if (readyCountdownTimer == INVALID_HANDLE)
        {
            
readyDelay = (delay-40);
            
readyCountdownTimer CreateTimer(40.0ReadyCountdownDelay_Timer_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
        } 
Sincerely,

edit: solved, used coultdown from plugin pause.

Last edited by eric0279; 08-19-2014 at 20:58.
eric0279 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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