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

CSS c4timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
w4rkr4f7
Member
Join Date: Dec 2008
Old 07-11-2011 , 14:07   CSS c4timer
Reply With Quote #1

This plugin author has not been seen on this forum from 2008 .plugin is working but if is Bomb planted and T kill all CT ,the countdown is not Stop until start new round.Can somebody verify and find solution ?? Thanks

PHP Code:
/*
advancedc4timer.sp

Description:
    Advanced c4 countdown timer.  Based on the original sm c4 timer by sslice.

Versions:
    0.5
        * Initial Release
        
    0.6
        * Restructued most of the code
        * Added user configuration of sounds
        * Added optional announcement
        * Changed timer to go 30, 20, 10, 9.....1
        
    1.0
        * Minor code and naming standards changes
        * Added support for late loading
        
    1.1
        * Added an exit option to the settings menu
        * Changed command to sm_c4timer
        * Made the SoundNames array const
        * Added new hud text
        
    1.1.1
        * Fixed voice countdown bug
        
    1.2
        * Added translations
        * Added name to bomb exploded message
        * Added bomb defused hud message
        
    1.2.1
        * Updated translation files and script to match
        * Changed menu behavior
        
    1.3
        * Changed naming convention to be more in line with base sourcemod
        * Improved timer synchronization
        * Changed from panels to menus
        
    1.4
        * Removed duplicate menu exit
        * Added autoloading of config file
        * Added verbose, flexible bombtimer messages
        * Added the ability to have the voice or text messages start at 10 instead of 30
        
    1.4.1
        * Added individual sounds
        
*/
        
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.4.1"
#define NUM_SOUNDS 12
#define TIMER 30

#define TWENTY 0
#define ONE 1
#define TWO 2
#define THREE 3
#define FOUR 4
#define FIVE 5
#define SIX 6
#define SEVEN 7
#define EIGHT 8
#define NINE 9
#define TEN 10
#define THIRTY 11

#define NUM_PREFS 4
#define SOUND 0
#define CHAT 1
#define CENTER 2
#define HUD 3

#define SOUND_AT_TEN 1
#define TEXT_AT_TEN 2

public Plugin:myinfo 
{
    
name "Advanced c4 Countdown Timer",
    
author "dalto",
    
description "Plugin that gives a countdown for the C4 explosion in Counter-Strike Source.",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net"
};


// Global Variables
new String:g_soundsList[1][NUM_SOUNDS][PLATFORM_MAX_PATH];
new 
g_c4Preferences[MAXPLAYERS 1][NUM_PREFS];
new 
Handle:g_kvC4 INVALID_HANDLE;
new 
String:g_filenameC4[PLATFORM_MAX_PATH];
new 
Handle:g_CvarEnable INVALID_HANDLE;
new 
Handle:g_CvarMPc4Timer INVALID_HANDLE;
new 
Handle:g_CvarAnnounce INVALID_HANDLE;
new 
Handle:g_CvarChatDefault INVALID_HANDLE;
new 
Handle:g_CvarSoundDefault INVALID_HANDLE;
new 
Handle:g_CvarHUDDefault INVALID_HANDLE;
new 
Handle:g_CvarCenterDefault INVALID_HANDLE;
new 
Handle:g_CvarAltStart INVALID_HANDLE;
new 
Float:g_explosionTime;
new 
g_countdown;
new 
bool:g_lateLoaded;
new 
String:g_planter[40];
static const 
String:g_soundNames[NUM_SOUNDS][] = {"20""1""2""3""4""5""6""7""8""9""10""30"};
new 
Handle:hTimer INVALID_HANDLE;

// We need to capture if the plugin was late loaded so we can make sure initializations
// are handled properly
public bool:AskPluginLoad(Handle:myselfbool:lateString:error[], err_max)
{
    
g_lateLoaded late;
    return 
true;
}

public 
OnPluginStart()
{
    
CreateConVar("sm_c4_timer_version"PLUGIN_VERSION"Advanced c4 Timer Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
g_CvarEnable CreateConVar("sm_c4_timer_enable""1""Enables the c4 timer");
    
g_CvarAnnounce CreateConVar("sm_c4_timer_announce""1""Announcement preferences");
    
g_CvarChatDefault CreateConVar("sm_c4_timer_chat_default""0""Default setting for chat preference");
    
g_CvarCenterDefault CreateConVar("sm_c4_timer_center_default""0""Default setting for center preference");
    
g_CvarHUDDefault CreateConVar("sm_c4_timer_hud_default""1""Default setting for HUD preference");
    
g_CvarSoundDefault CreateConVar("sm_c4_timer_sound_default""1""Default setting for sound preference");
    
g_CvarAltStart CreateConVar("sm_c4_timer_start_at_ten""0""1 voice starts at 10, 2 text starts at 10, 3 both start at 10");

    
g_CvarMPc4Timer FindConVar("mp_c4timer");
    
    
LoadTranslations("plugin.advancedc4timer");

    
// Execute the config file
    
AutoExecConfig(true"advancedc4timer");
    
    
HookEvent("bomb_planted"EventBombPlantedEventHookMode_Pre);
    
HookEvent("round_start"EventRoundStartEventHookMode_PostNoCopy);
    
HookEvent("bomb_exploded"EventBombExplodedEventHookMode_PostNoCopy);
    
HookEvent("bomb_defused"EventBombDefusedEventHookMode_Post);
    
RegConsoleCmd("sm_c4timer"SettingsMenu);

    
LoadSounds();
    
    
g_kvC4=CreateKeyValues("c4UserSettings");
      
BuildPath(Path_SMg_filenameC4PLATFORM_MAX_PATH"data/c4usersettings.txt");
    if(!
FileToKeyValues(g_kvC4g_filenameC4))
        
KeyValuesToFile(g_kvC4g_filenameC4);
        
    
// if the plugin was loaded late we have a bunch of initialization that needs to be done
    
if(g_lateLoaded)
    {
        
// Next we need to whatever we would have done as each client authorized
        
for(new 1<= GetMaxClients(); i++)
        {
            if(
IsClientInGame(i))
            {
                
PrepareClient(i);
            }
        }
    }
}

public 
OnMapStart()
{
    for(new 
0NUM_SOUNDSi++)
    {
        
PrepareSound(i);
    }
}

// When a new client is authorized we create sound preferences
// for them if they do not have any already
public OnClientAuthorized(client, const String:auth[])
{
    
PrepareClient(client);
}

public 
Action:EventBombPlanted(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(!
GetConVarBool(g_CvarEnable))
    {
        return 
Plugin_Continue;
    }
    
    
g_explosionTime GetEngineTime() + GetConVarFloat(g_CvarMPc4Timer);
    
    
GetClientName(GetClientOfUserId(GetEventInt(event"userid")), g_plantersizeof(g_planter));
    
    
g_countdown GetConVarInt(g_CvarMPc4Timer) - 1;

    
hTimer CreateTimer((g_explosionTime float(g_countdown)) - GetEngineTime(), TimerCountdown);
    
    return 
Plugin_Continue;
}

public 
EventBombDefused(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(!
GetConVarBool(g_CvarEnable))
    {
        return;
    }
    
    if(
IsValidHandle(hTimer))
    {
        
CloseHandle(hTimer);
    }
    
decl String:defuser[40];
    
GetClientName(GetClientOfUserId(GetEventInt(event"userid")), defusersizeof(defuser));
    for(new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && g_c4Preferences[i][HUD])
        {
            
PrintHintText(i"%T""bomb defused"idefuser);
        }
    }
}

public 
Action:TimerCountdown(Handle:timerany:data)
{
    
BombMessage(g_countdown);
    if(--
g_countdown)
    {
        
hTimer CreateTimer((g_explosionTime float(g_countdown)) - GetEngineTime(), TimerCountdown);
    }
}

// Loads the soundsList array with the c4 sounds
public LoadSounds()
{
    new 
Handle:kvQSL CreateKeyValues("c4SoundsList");
    new 
String:fileQSL[PLATFORM_MAX_PATH];

    
BuildPath(Path_SMfileQSLPLATFORM_MAX_PATH"configs/c4soundslist.cfg");
    
FileToKeyValues(kvQSLfileQSL);
    
    if (!
KvGotoFirstSubKey(kvQSL))
    {
        
SetFailState("configs/c4soundslist.cfg not found or not correctly structured");
        
CloseHandle(kvQSL);
        return;
    }

    for(new 
0NUM_SOUNDSi++)
    {
        
KvGetString(kvQSLg_soundNames[i], g_soundsList[0][i], PLATFORM_MAX_PATH);
    }
    
    
CloseHandle(kvQSL);
}

public 
PrepareSound(sound)
{
    new 
String:downloadFile[PLATFORM_MAX_PATH];

    if(!
StrEqual(g_soundsList[0][sound], ""))
    {
        
PrecacheSound(g_soundsList[0][sound], true);
        
Format(downloadFilePLATFORM_MAX_PATH"sound/%s"g_soundsList[0][sound]);
        
AddFileToDownloadsTable(downloadFile);
    }
}

// Sends the bomb message
public BombMessage(count)
{
    new 
soundKey;
    
decl String:buffer[200];
    
    switch(
count)
    {
        case 
12345678910:
            
soundKey count;
        case 
20:
            
soundKey TWENTY;
        case 
30:
            
soundKey THIRTY;
        default:
            return;
    }

    for (new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && !StrEqual(g_soundsList[0][soundKey], ""))
        {
            
Format(buffersizeof(buffer), "countdown %i"count);
            
Format(buffersizeof(buffer), "%T"buffericount);
            if(
g_c4Preferences[i][SOUND] && !(GetConVarInt(g_CvarAltStart) & SOUND_AT_TEN && (soundKey || soundKey 10)))
            {
                
EmitSoundToClient(ig_soundsList[0][soundKey]);
            }
            if(!(
GetConVarInt(g_CvarAltStart) & TEXT_AT_TEN && (soundKey || soundKey 10)))
            {
                if(
g_c4Preferences[i][CHAT])
                {
                    
PrintToChat(i"Bomb: %s"buffer);
                }
                if(
g_c4Preferences[i][center])
                {
                    
PrintCenterText(ibuffer);
                }
                if(
g_c4Preferences[i][HUD])
                {
                    
PrintHintText(ibuffer);
                }
            }
        }
    }
}

public 
Action:TimerAnnounce(Handle:timerany:client)
{
    if(
IsClientInGame(client))
    {
        
PrintToChat(client"%t""announce");
    }
}

//  This selects or disables the c4 settings
public SettingsMenuHandler(Handle:menuMenuAction:actionparam1param2)
{
    if(
action == MenuAction_Select)
    {
        
// Update both the soundPreference array and User Settings KV
        
switch(param2)
        {
            case 
0:
                
g_c4Preferences[param1][SOUND] = Flip(g_c4Preferences[param1][SOUND]);
            case 
1:
                
g_c4Preferences[param1][CHAT] = Flip(g_c4Preferences[param1][CHAT]);
            case 
2:
                
g_c4Preferences[param1][center] = Flip(g_c4Preferences[param1][center]);
            case 
3:
                
g_c4Preferences[param1][HUD] = Flip(g_c4Preferences[param1][HUD]);
        }
        new 
String:steamId[20];
        
GetClientAuthString(param1steamId20);
        
KvRewind(g_kvC4);
        
KvJumpToKey(g_kvC4steamId);
        
KvSetNum(g_kvC4"sound"g_c4Preferences[param1][SOUND]);
        
KvSetNum(g_kvC4"chat"g_c4Preferences[param1][CHAT]);
        
KvSetNum(g_kvC4"center"g_c4Preferences[param1][center]);
        
KvSetNum(g_kvC4"hud"g_c4Preferences[param1][HUD]);
        
KvSetNum(g_kvC4"timestamp"GetTime());
        
SettingsMenu(param10);
    } else if(
action == MenuAction_End)    {
        
CloseHandle(menu);
    }
}
 
//  This creates the settings panel
public Action:SettingsMenu(clientargs)
{
    
decl String:buffer[100];
    new 
Handle:menu CreateMenu(SettingsMenuHandler);
    
Format(buffersizeof(buffer), "%T""c4 menu"client);
    
SetMenuTitle(menubuffer);
    if(
g_c4Preferences[client][SOUND] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable sound"client);
    } else {
        
Format(buffersizeof(buffer), "%T""enable sound"client);
    }
    
AddMenuItem(menu"menu item"buffer);

    if(
g_c4Preferences[client][CHAT] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable chat"client);
    }
    else {
        
Format(buffersizeof(buffer), "%T""enable chat"client);
    }
    
AddMenuItem(menu"menu item"buffer);
    
    if(
g_c4Preferences[client][center] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable center"client);
    } else {
        
Format(buffersizeof(buffer), "%T""enable center"client);
    }
    
AddMenuItem(menu"menu item"buffer);
    
    if(
g_c4Preferences[client][HUD] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable hud"client);
    }
    else {
        
Format(buffersizeof(buffer), "%T""enable hud"client);
    }
    
AddMenuItem(menu"menu item"buffer);

    
DisplayMenu(menuclient15);
     
    return 
Plugin_Handled;
}

// Switches a non-zero number to a 0 and a 0 to a 1
public Flip(flipNum)
{
    if(
flipNum == 0)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}

// Initializations to be done at the beginning of the round
public EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
// Save user settings to a file
    
KvRewind(g_kvC4);
    
KeyValuesToFile(g_kvC4g_filenameC4);
    if(
IsValidHandle(hTimer))
    {
        
CloseHandle(hTimer);
    }
}

// When a user disconnects we need to update their timestamp in kvC4
public OnClientDisconnect(client)
{
    new 
String:steamId[20];
    if(
client && !IsFakeClient(client))
    {
        
GetClientAuthString(clientsteamId20);
        
KvRewind(g_kvC4);
        if(
KvJumpToKey(g_kvC4steamId))
        {
            
KvSetNum(g_kvC4"timestamp"GetTime());
        }
    }
}

public 
PrepareClient(client)
{
    new 
String:steamId[20];
    if(
client)
    {
        if(!
IsFakeClient(client))
        {
            
// Get the users saved setting or create them if they don't exist
            
GetClientAuthString(clientsteamId20);
            
KvRewind(g_kvC4);
            if(
KvJumpToKey(g_kvC4steamId))
            {
                
g_c4Preferences[client][SOUND] = KvGetNum(g_kvC4"sound"GetConVarInt(g_CvarSoundDefault));
                
g_c4Preferences[client][CHAT] = KvGetNum(g_kvC4"chat"GetConVarInt(g_CvarChatDefault));
                
g_c4Preferences[client][center] = KvGetNum(g_kvC4"center"GetConVarInt(g_CvarCenterDefault));
                
g_c4Preferences[client][HUD] = KvGetNum(g_kvC4"hud"GetConVarInt(g_CvarHUDDefault));
            } else {
                
KvRewind(g_kvC4);
                
KvJumpToKey(g_kvC4steamIdtrue);
                
KvSetNum(g_kvC4"sound"GetConVarInt(g_CvarSoundDefault));
                
KvSetNum(g_kvC4"chat"GetConVarInt(g_CvarChatDefault));
                
KvSetNum(g_kvC4"center"GetConVarInt(g_CvarCenterDefault));
                
KvSetNum(g_kvC4"hud"GetConVarInt(g_CvarHUDDefault));
                
g_c4Preferences[client][SOUND] = GetConVarInt(g_CvarSoundDefault);
                
g_c4Preferences[client][CHAT] = GetConVarInt(g_CvarChatDefault);
                
g_c4Preferences[client][center] = GetConVarInt(g_CvarCenterDefault);
                
g_c4Preferences[client][HUD] = GetConVarInt(g_CvarHUDDefault);
            }
            
KvRewind(g_kvC4);

            
// Make the announcement in 30 seconds unless announcements are turned off
            
if(GetConVarBool(g_CvarAnnounce))
            {
                
CreateTimer(30.0TimerAnnounceclient);
            }
        }
    }
}

public 
EventBombExploded(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
IsValidHandle(hTimer))
    {
        
CloseHandle(hTimer);
    }
    for(new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && g_c4Preferences[i][HUD])
        {
            
PrintHintText(i"%T""bomb exploded"ig_planter);
        }
    }

w4rkr4f7 is offline
ojmdk476oj
AlliedModders Donor
Join Date: Dec 2009
Old 07-11-2011 , 16:50   Re: CSS c4timer
Reply With Quote #2

Try this, don't know if it works.

PHP Code:
/*
advancedc4timer.sp

Description:
    Advanced c4 countdown timer.  Based on the original sm c4 timer by sslice.

Versions:
    0.5
        * Initial Release
        
    0.6
        * Restructued most of the code
        * Added user configuration of sounds
        * Added optional announcement
        * Changed timer to go 30, 20, 10, 9.....1
        
    1.0
        * Minor code and naming standards changes
        * Added support for late loading
        
    1.1
        * Added an exit option to the settings menu
        * Changed command to sm_c4timer
        * Made the SoundNames array const
        * Added new hud text
        
    1.1.1
        * Fixed voice countdown bug
        
    1.2
        * Added translations
        * Added name to bomb exploded message
        * Added bomb defused hud message
        
    1.2.1
        * Updated translation files and script to match
        * Changed menu behavior
        
    1.3
        * Changed naming convention to be more in line with base sourcemod
        * Improved timer synchronization
        * Changed from panels to menus
        
    1.4
        * Removed duplicate menu exit
        * Added autoloading of config file
        * Added verbose, flexible bombtimer messages
        * Added the ability to have the voice or text messages start at 10 instead of 30
        
    1.4.1
        * Added individual sounds
        
*/
        
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.4.1"
#define NUM_SOUNDS 12
#define TIMER 30

#define TWENTY 0
#define ONE 1
#define TWO 2
#define THREE 3
#define FOUR 4
#define FIVE 5
#define SIX 6
#define SEVEN 7
#define EIGHT 8
#define NINE 9
#define TEN 10
#define THIRTY 11

#define NUM_PREFS 4
#define SOUND 0
#define CHAT 1
#define CENTER 2
#define HUD 3

#define SOUND_AT_TEN 1
#define TEXT_AT_TEN 2

public Plugin:myinfo 
{
    
name "Advanced c4 Countdown Timer",
    
author "dalto",
    
description "Plugin that gives a countdown for the C4 explosion in Counter-Strike Source.",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net"
};


// Global Variables
new String:g_soundsList[1][NUM_SOUNDS][PLATFORM_MAX_PATH];
new 
g_c4Preferences[MAXPLAYERS 1][NUM_PREFS];
new 
Handle:g_kvC4 INVALID_HANDLE;
new 
String:g_filenameC4[PLATFORM_MAX_PATH];
new 
Handle:g_CvarEnable INVALID_HANDLE;
new 
Handle:g_CvarMPc4Timer INVALID_HANDLE;
new 
Handle:g_CvarAnnounce INVALID_HANDLE;
new 
Handle:g_CvarChatDefault INVALID_HANDLE;
new 
Handle:g_CvarSoundDefault INVALID_HANDLE;
new 
Handle:g_CvarHUDDefault INVALID_HANDLE;
new 
Handle:g_CvarCenterDefault INVALID_HANDLE;
new 
Handle:g_CvarAltStart INVALID_HANDLE;
new 
Float:g_explosionTime;
new 
g_countdown;
new 
bool:g_lateLoaded;
new 
String:g_planter[40];
static const 
String:g_soundNames[NUM_SOUNDS][] = {"20""1""2""3""4""5""6""7""8""9""10""30"};
new 
Handle:hTimer INVALID_HANDLE;

// We need to capture if the plugin was late loaded so we can make sure initializations
// are handled properly
public bool:AskPluginLoad(Handle:myselfbool:lateString:error[], err_max)
{
    
g_lateLoaded late;
    return 
true;
}

public 
OnPluginStart()
{
    
CreateConVar("sm_c4_timer_version"PLUGIN_VERSION"Advanced c4 Timer Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
g_CvarEnable CreateConVar("sm_c4_timer_enable""1""Enables the c4 timer");
    
g_CvarAnnounce CreateConVar("sm_c4_timer_announce""1""Announcement preferences");
    
g_CvarChatDefault CreateConVar("sm_c4_timer_chat_default""0""Default setting for chat preference");
    
g_CvarCenterDefault CreateConVar("sm_c4_timer_center_default""0""Default setting for center preference");
    
g_CvarHUDDefault CreateConVar("sm_c4_timer_hud_default""1""Default setting for HUD preference");
    
g_CvarSoundDefault CreateConVar("sm_c4_timer_sound_default""1""Default setting for sound preference");
    
g_CvarAltStart CreateConVar("sm_c4_timer_start_at_ten""0""1 voice starts at 10, 2 text starts at 10, 3 both start at 10");

    
g_CvarMPc4Timer FindConVar("mp_c4timer");
    
    
LoadTranslations("plugin.advancedc4timer");

    
// Execute the config file
    
AutoExecConfig(true"advancedc4timer");
    
    
HookEvent("bomb_planted"EventBombPlantedEventHookMode_Pre);
    
HookEvent("round_start"EventRoundStartEventHookMode_PostNoCopy);
    
HookEvent("round_end"EventRoundEndEventHookMode_PostNoCopy);
    
HookEvent("bomb_exploded"EventBombExplodedEventHookMode_PostNoCopy);
    
HookEvent("bomb_defused"EventBombDefusedEventHookMode_Post);
    
RegConsoleCmd("sm_c4timer"SettingsMenu);

    
LoadSounds();
    
    
g_kvC4=CreateKeyValues("c4UserSettings");
      
BuildPath(Path_SMg_filenameC4PLATFORM_MAX_PATH"data/c4usersettings.txt");
    if(!
FileToKeyValues(g_kvC4g_filenameC4))
        
KeyValuesToFile(g_kvC4g_filenameC4);
        
    
// if the plugin was loaded late we have a bunch of initialization that needs to be done
    
if(g_lateLoaded)
    {
        
// Next we need to whatever we would have done as each client authorized
        
for(new 1<= GetMaxClients(); i++)
        {
            if(
IsClientInGame(i))
            {
                
PrepareClient(i);
            }
        }
    }
}

public 
OnMapStart()
{
    for(new 
0NUM_SOUNDSi++)
    {
        
PrepareSound(i);
    }
}

// When a new client is authorized we create sound preferences
// for them if they do not have any already
public OnClientAuthorized(client, const String:auth[])
{
    
PrepareClient(client);
}

public 
Action:EventBombPlanted(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(!
GetConVarBool(g_CvarEnable))
    {
        return 
Plugin_Continue;
    }
    
    
g_explosionTime GetEngineTime() + GetConVarFloat(g_CvarMPc4Timer);
    
    
GetClientName(GetClientOfUserId(GetEventInt(event"userid")), g_plantersizeof(g_planter));
    
    
g_countdown GetConVarInt(g_CvarMPc4Timer) - 1;

    
hTimer CreateTimer((g_explosionTime float(g_countdown)) - GetEngineTime(), TimerCountdown);
    
    return 
Plugin_Continue;
}

public 
EventBombDefused(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(!
GetConVarBool(g_CvarEnable))
    {
        return;
    }
    
    if(
IsValidHandle(hTimer))
    {
        
CloseHandle(hTimer);
    }
    
decl String:defuser[40];
    
GetClientName(GetClientOfUserId(GetEventInt(event"userid")), defusersizeof(defuser));
    for(new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && g_c4Preferences[i][HUD])
        {
            
PrintHintText(i"%T""bomb defused"idefuser);
        }
    }
}

public 
Action:TimerCountdown(Handle:timerany:data)
{
    
BombMessage(g_countdown);
    if(--
g_countdown)
    {
        
hTimer CreateTimer((g_explosionTime float(g_countdown)) - GetEngineTime(), TimerCountdown);
    }
}

// Loads the soundsList array with the c4 sounds
public LoadSounds()
{
    new 
Handle:kvQSL CreateKeyValues("c4SoundsList");
    new 
String:fileQSL[PLATFORM_MAX_PATH];

    
BuildPath(Path_SMfileQSLPLATFORM_MAX_PATH"configs/c4soundslist.cfg");
    
FileToKeyValues(kvQSLfileQSL);
    
    if (!
KvGotoFirstSubKey(kvQSL))
    {
        
SetFailState("configs/c4soundslist.cfg not found or not correctly structured");
        
CloseHandle(kvQSL);
        return;
    }

    for(new 
0NUM_SOUNDSi++)
    {
        
KvGetString(kvQSLg_soundNames[i], g_soundsList[0][i], PLATFORM_MAX_PATH);
    }
    
    
CloseHandle(kvQSL);
}

public 
PrepareSound(sound)
{
    new 
String:downloadFile[PLATFORM_MAX_PATH];

    if(!
StrEqual(g_soundsList[0][sound], ""))
    {
        
PrecacheSound(g_soundsList[0][sound], true);
        
Format(downloadFilePLATFORM_MAX_PATH"sound/%s"g_soundsList[0][sound]);
        
AddFileToDownloadsTable(downloadFile);
    }
}

// Sends the bomb message
public BombMessage(count)
{
    new 
soundKey;
    
decl String:buffer[200];
    
    switch(
count)
    {
        case 
12345678910:
            
soundKey count;
        case 
20:
            
soundKey TWENTY;
        case 
30:
            
soundKey THIRTY;
        default:
            return;
    }

    for (new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && !StrEqual(g_soundsList[0][soundKey], ""))
        {
            
Format(buffersizeof(buffer), "countdown %i"count);
            
Format(buffersizeof(buffer), "%T"buffericount);
            if(
g_c4Preferences[i][SOUND] && !(GetConVarInt(g_CvarAltStart) & SOUND_AT_TEN && (soundKey || soundKey 10)))
            {
                
EmitSoundToClient(ig_soundsList[0][soundKey]);
            }
            if(!(
GetConVarInt(g_CvarAltStart) & TEXT_AT_TEN && (soundKey || soundKey 10)))
            {
                if(
g_c4Preferences[i][CHAT])
                {
                    
PrintToChat(i"Bomb: %s"buffer);
                }
                if(
g_c4Preferences[i][CENTER])
                {
                    
PrintCenterText(ibuffer);
                }
                if(
g_c4Preferences[i][HUD])
                {
                    
PrintHintText(ibuffer);
                }
            }
        }
    }
}

public 
Action:TimerAnnounce(Handle:timerany:client)
{
    if(
IsClientInGame(client))
    {
        
PrintToChat(client"%t""announce");
    }
}

//  This selects or disables the c4 settings
public SettingsMenuHandler(Handle:menuMenuAction:actionparam1param2)
{
    if(
action == MenuAction_Select)
    {
        
// Update both the soundPreference array and User Settings KV
        
switch(param2)
        {
            case 
0:
                
g_c4Preferences[param1][SOUND] = Flip(g_c4Preferences[param1][SOUND]);
            case 
1:
                
g_c4Preferences[param1][CHAT] = Flip(g_c4Preferences[param1][CHAT]);
            case 
2:
                
g_c4Preferences[param1][CENTER] = Flip(g_c4Preferences[param1][CENTER]);
            case 
3:
                
g_c4Preferences[param1][HUD] = Flip(g_c4Preferences[param1][HUD]);
        }
        new 
String:steamId[20];
        
GetClientAuthString(param1steamId20);
        
KvRewind(g_kvC4);
        
KvJumpToKey(g_kvC4steamId);
        
KvSetNum(g_kvC4"sound"g_c4Preferences[param1][SOUND]);
        
KvSetNum(g_kvC4"chat"g_c4Preferences[param1][CHAT]);
        
KvSetNum(g_kvC4"center"g_c4Preferences[param1][CENTER]);
        
KvSetNum(g_kvC4"hud"g_c4Preferences[param1][HUD]);
        
KvSetNum(g_kvC4"timestamp"GetTime());
        
SettingsMenu(param10);
    } else if(
action == MenuAction_End)    {
        
CloseHandle(menu);
    }
}
 
//  This creates the settings panel
public Action:SettingsMenu(clientargs)
{
    
decl String:buffer[100];
    new 
Handle:menu CreateMenu(SettingsMenuHandler);
    
Format(buffersizeof(buffer), "%T""c4 menu"client);
    
SetMenuTitle(menubuffer);
    if(
g_c4Preferences[client][SOUND] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable sound"client);
    } else {
        
Format(buffersizeof(buffer), "%T""enable sound"client);
    }
    
AddMenuItem(menu"menu item"buffer);

    if(
g_c4Preferences[client][CHAT] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable chat"client);
    }
    else {
        
Format(buffersizeof(buffer), "%T""enable chat"client);
    }
    
AddMenuItem(menu"menu item"buffer);
    
    if(
g_c4Preferences[client][CENTER] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable center"client);
    } else {
        
Format(buffersizeof(buffer), "%T""enable center"client);
    }
    
AddMenuItem(menu"menu item"buffer);
    
    if(
g_c4Preferences[client][HUD] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable hud"client);
    }
    else {
        
Format(buffersizeof(buffer), "%T""enable hud"client);
    }
    
AddMenuItem(menu"menu item"buffer);

    
DisplayMenu(menuclient15);
     
    return 
Plugin_Handled;
}

// Switches a non-zero number to a 0 and a 0 to a 1
public Flip(flipNum)
{
    if(
flipNum == 0)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}

// Initializations to be done at the beginning of the round
public EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
// Save user settings to a file
    
KvRewind(g_kvC4);
    
KeyValuesToFile(g_kvC4g_filenameC4);
}

// Stops timer
public EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
IsValidHandle(hTimer))
        
CloseHandle(hTimer);
}

// When a user disconnects we need to update their timestamp in kvC4
public OnClientDisconnect(client)
{
    new 
String:steamId[20];
    if(
client && !IsFakeClient(client))
    {
        
GetClientAuthString(clientsteamId20);
        
KvRewind(g_kvC4);
        if(
KvJumpToKey(g_kvC4steamId))
        {
            
KvSetNum(g_kvC4"timestamp"GetTime());
        }
    }
}

public 
PrepareClient(client)
{
    new 
String:steamId[20];
    if(
client)
    {
        if(!
IsFakeClient(client))
        {
            
// Get the users saved setting or create them if they don't exist
            
GetClientAuthString(clientsteamId20);
            
KvRewind(g_kvC4);
            if(
KvJumpToKey(g_kvC4steamId))
            {
                
g_c4Preferences[client][SOUND] = KvGetNum(g_kvC4"sound"GetConVarInt(g_CvarSoundDefault));
                
g_c4Preferences[client][CHAT] = KvGetNum(g_kvC4"chat"GetConVarInt(g_CvarChatDefault));
                
g_c4Preferences[client][CENTER] = KvGetNum(g_kvC4"center"GetConVarInt(g_CvarCenterDefault));
                
g_c4Preferences[client][HUD] = KvGetNum(g_kvC4"hud"GetConVarInt(g_CvarHUDDefault));
            } else {
                
KvRewind(g_kvC4);
                
KvJumpToKey(g_kvC4steamIdtrue);
                
KvSetNum(g_kvC4"sound"GetConVarInt(g_CvarSoundDefault));
                
KvSetNum(g_kvC4"chat"GetConVarInt(g_CvarChatDefault));
                
KvSetNum(g_kvC4"center"GetConVarInt(g_CvarCenterDefault));
                
KvSetNum(g_kvC4"hud"GetConVarInt(g_CvarHUDDefault));
                
g_c4Preferences[client][SOUND] = GetConVarInt(g_CvarSoundDefault);
                
g_c4Preferences[client][CHAT] = GetConVarInt(g_CvarChatDefault);
                
g_c4Preferences[client][CENTER] = GetConVarInt(g_CvarCenterDefault);
                
g_c4Preferences[client][HUD] = GetConVarInt(g_CvarHUDDefault);
            }
            
KvRewind(g_kvC4);

            
// Make the announcement in 30 seconds unless announcements are turned off
            
if(GetConVarBool(g_CvarAnnounce))
            {
                
CreateTimer(30.0TimerAnnounceclient);
            }
        }
    }
}

public 
EventBombExploded(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
IsValidHandle(hTimer))
    {
        
CloseHandle(hTimer);
    }
    for(new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && g_c4Preferences[i][HUD])
        {
            
PrintHintText(i"%T""bomb exploded"ig_planter);
        }
    }


Last edited by ojmdk476oj; 07-11-2011 at 16:51. Reason: Wrong code
ojmdk476oj is offline
w4rkr4f7
Member
Join Date: Dec 2008
Old 07-12-2011 , 13:07   Re: CSS c4timer
Reply With Quote #3

error 017 undefined symbol center ,can't compile
IsValidHandle - deprecated
AskPluginLoad - deprecated


this is not give me errors but is not stooping countdown after all CT is killed

PHP Code:
/*
advancedc4timer.sp

Description:
    Advanced c4 countdown timer.  Based on the original sm c4 timer by sslice.

Versions:
    0.5
        * Initial Release
        
    0.6
        * Restructued most of the code
        * Added user configuration of sounds
        * Added optional announcement
        * Changed timer to go 30, 20, 10, 9.....1
        
    1.0
        * Minor code and naming standards changes
        * Added support for late loading
        
    1.1
        * Added an exit option to the settings menu
        * Changed command to sm_c4timer
        * Made the SoundNames array const
        * Added new hud text
        
    1.1.1
        * Fixed voice countdown bug
        
    1.2
        * Added translations
        * Added name to bomb exploded message
        * Added bomb defused hud message
        
    1.2.1
        * Updated translation files and script to match
        * Changed menu behavior
        
    1.3
        * Changed naming convention to be more in line with base sourcemod
        * Improved timer synchronization
        * Changed from panels to menus
        
    1.4
        * Removed duplicate menu exit
        * Added autoloading of config file
        * Added verbose, flexible bombtimer messages
        * Added the ability to have the voice or text messages start at 10 instead of 30
        
    1.4.1
        * Added individual sounds
        
*/
        
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.4.1"
#define NUM_SOUNDS 12
#define TIMER 30

#define TWENTY 0
#define ONE 1
#define TWO 2
#define THREE 3
#define FOUR 4
#define FIVE 5
#define SIX 6
#define SEVEN 7
#define EIGHT 8
#define NINE 9
#define TEN 10
#define THIRTY 11

#define NUM_PREFS 4
#define SOUND 0
#define CHAT 1
#define CENTER 2
#define HUD 3

#define SOUND_AT_TEN 1
#define TEXT_AT_TEN 2

public Plugin:myinfo 
{
    
name "Advanced c4 Countdown Timer",
    
author "dalto",
    
description "Plugin that gives a countdown for the C4 explosion in Counter-Strike Source.",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net"
};


// Global Variables
new String:g_soundsList[1][NUM_SOUNDS][PLATFORM_MAX_PATH];
new 
g_c4Preferences[MAXPLAYERS 1][NUM_PREFS];
new 
Handle:g_kvC4 INVALID_HANDLE;
new 
String:g_filenameC4[PLATFORM_MAX_PATH];
new 
Handle:g_CvarEnable INVALID_HANDLE;
new 
Handle:g_CvarMPc4Timer INVALID_HANDLE;
new 
Handle:g_CvarAnnounce INVALID_HANDLE;
new 
Handle:g_CvarChatDefault INVALID_HANDLE;
new 
Handle:g_CvarSoundDefault INVALID_HANDLE;
new 
Handle:g_CvarHUDDefault INVALID_HANDLE;
new 
Handle:g_CvarCenterDefault INVALID_HANDLE;
new 
Handle:g_CvarAltStart INVALID_HANDLE;
new 
Float:g_explosionTime;
new 
g_countdown;
new 
bool:g_lateLoaded;
new 
String:g_planter[40];
static const 
String:g_soundNames[NUM_SOUNDS][] = {"20""1""2""3""4""5""6""7""8""9""10""30"};
new 
Handle:hTimer INVALID_HANDLE;

// We need to capture if the plugin was late loaded so we can make sure initializations
// are handled properly
public APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
g_lateLoaded late;
    return 
APLRes_Success;
}

public 
OnPluginStart()
{
    
CreateConVar("sm_c4_timer_version"PLUGIN_VERSION"Advanced c4 Timer Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
g_CvarEnable CreateConVar("sm_c4_timer_enable""1""Enables the c4 timer");
    
g_CvarAnnounce CreateConVar("sm_c4_timer_announce""1""Announcement preferences");
    
g_CvarChatDefault CreateConVar("sm_c4_timer_chat_default""0""Default setting for chat preference");
    
g_CvarCenterDefault CreateConVar("sm_c4_timer_center_default""0""Default setting for center preference");
    
g_CvarHUDDefault CreateConVar("sm_c4_timer_hud_default""1""Default setting for HUD preference");
    
g_CvarSoundDefault CreateConVar("sm_c4_timer_sound_default""1""Default setting for sound preference");
    
g_CvarAltStart CreateConVar("sm_c4_timer_start_at_ten""0""1 voice starts at 10, 2 text starts at 10, 3 both start at 10");

    
g_CvarMPc4Timer FindConVar("mp_c4timer");
    
    
LoadTranslations("plugin.advancedc4timer");

    
// Execute the config file
    
AutoExecConfig(true"advancedc4timer");
    
    
HookEvent("bomb_planted"EventBombPlantedEventHookMode_Pre);
    
HookEvent("round_start"EventRoundStartEventHookMode_PostNoCopy);
    
HookEvent("bomb_exploded"EventBombExplodedEventHookMode_PostNoCopy);
    
HookEvent("bomb_defused"EventBombDefusedEventHookMode_Post);
    
RegConsoleCmd("sm_c4timer"SettingsMenu);

    
LoadSounds();
    
    
g_kvC4=CreateKeyValues("c4UserSettings");
      
BuildPath(Path_SMg_filenameC4PLATFORM_MAX_PATH"data/c4usersettings.txt");
    if(!
FileToKeyValues(g_kvC4g_filenameC4))
        
KeyValuesToFile(g_kvC4g_filenameC4);
        
    
// if the plugin was loaded late we have a bunch of initialization that needs to be done
    
if(g_lateLoaded)
    {
        
// Next we need to whatever we would have done as each client authorized
        
for(new 1<= GetMaxClients(); i++)
        {
            if(
IsClientInGame(i))
            {
                
PrepareClient(i);
            }
        }
    }
}

public 
OnMapStart()
{
    for(new 
0NUM_SOUNDSi++)
    {
        
PrepareSound(i);
    }
}

// When a new client is authorized we create sound preferences
// for them if they do not have any already
public OnClientAuthorized(client, const String:auth[])
{
    
PrepareClient(client);
}

public 
Action:EventBombPlanted(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(!
GetConVarBool(g_CvarEnable))
    {
        return 
Plugin_Continue;
    }
    
    
g_explosionTime GetEngineTime() + GetConVarFloat(g_CvarMPc4Timer);
    
    
GetClientName(GetClientOfUserId(GetEventInt(event"userid")), g_plantersizeof(g_planter));
    
    
g_countdown GetConVarInt(g_CvarMPc4Timer) - 1;

    
hTimer CreateTimer((g_explosionTime float(g_countdown)) - GetEngineTime(), TimerCountdown);
    
    return 
Plugin_Continue;
}

public 
EventBombDefused(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(!
GetConVarBool(g_CvarEnable))
    {
        return;
    }
    
    if(
hTimer != INVALID_HANDLE)
    {
        
KillTimer(hTimer);
    }
    
decl String:defuser[40];
    
GetClientName(GetClientOfUserId(GetEventInt(event"userid")), defusersizeof(defuser));
    for(new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && g_c4Preferences[i][HUD])
        {
            
PrintHintText(i"%T""bomb defused"idefuser);
        }
    }
}

public 
Action:TimerCountdown(Handle:timerany:data)
{
    
BombMessage(g_countdown);
    if(--
g_countdown)
    {
        
hTimer CreateTimer((g_explosionTime float(g_countdown)) - GetEngineTime(), TimerCountdown);
    }
}

// Loads the soundsList array with the c4 sounds
public LoadSounds()
{
    new 
Handle:kvQSL CreateKeyValues("c4SoundsList");
    new 
String:fileQSL[PLATFORM_MAX_PATH];

    
BuildPath(Path_SMfileQSLPLATFORM_MAX_PATH"configs/c4soundslist.cfg");
    
FileToKeyValues(kvQSLfileQSL);
    
    if (!
KvGotoFirstSubKey(kvQSL))
    {
        
SetFailState("configs/c4soundslist.cfg not found or not correctly structured");
        
CloseHandle(kvQSL);
        return;
    }

    for(new 
0NUM_SOUNDSi++)
    {
        
KvGetString(kvQSLg_soundNames[i], g_soundsList[0][i], PLATFORM_MAX_PATH);
    }
    
    
CloseHandle(kvQSL);
}

public 
PrepareSound(sound)
{
    new 
String:downloadFile[PLATFORM_MAX_PATH];

    if(!
StrEqual(g_soundsList[0][sound], ""))
    {
        
PrecacheSound(g_soundsList[0][sound], true);
        
Format(downloadFilePLATFORM_MAX_PATH"sound/%s"g_soundsList[0][sound]);
        
AddFileToDownloadsTable(downloadFile);
    }
}

// Sends the bomb message
public BombMessage(count)
{
    new 
soundKey;
    
decl String:buffer[200];
    
    switch(
count)
    {
        case 
12345678910:
            
soundKey count;
        case 
20:
            
soundKey TWENTY;
        case 
30:
            
soundKey THIRTY;
        default:
            return;
    }

    for (new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && !StrEqual(g_soundsList[0][soundKey], ""))
        {
            
Format(buffersizeof(buffer), "countdown %i"count);
            
Format(buffersizeof(buffer), "%T"buffericount);
            if(
g_c4Preferences[i][SOUND] && !(GetConVarInt(g_CvarAltStart) & SOUND_AT_TEN && (soundKey || soundKey 10)))
            {
                
EmitSoundToClient(ig_soundsList[0][soundKey]);
            }
            if(!(
GetConVarInt(g_CvarAltStart) & TEXT_AT_TEN && (soundKey || soundKey 10)))
            {
                if(
g_c4Preferences[i][CHAT])
                {
                    
PrintToChat(i"Bomb: %s"buffer);
                }
                if(
g_c4Preferences[i][CENTER])
                {
                    
PrintCenterText(ibuffer);
                }
                if(
g_c4Preferences[i][HUD])
                {
                    
PrintHintText(ibuffer);
                }
            }
        }
    }
}

public 
Action:TimerAnnounce(Handle:timerany:client)
{
    if(
IsClientInGame(client))
    {
        
PrintToChat(client"%t""announce");
    }
}

//  This selects or disables the c4 settings
public SettingsMenuHandler(Handle:menuMenuAction:actionparam1param2)
{
    if(
action == MenuAction_Select)
    {
        
// Update both the soundPreference array and User Settings KV
        
switch(param2)
        {
            case 
0:
                
g_c4Preferences[param1][SOUND] = Flip(g_c4Preferences[param1][SOUND]);
            case 
1:
                
g_c4Preferences[param1][CHAT] = Flip(g_c4Preferences[param1][CHAT]);
            case 
2:
                
g_c4Preferences[param1][CENTER] = Flip(g_c4Preferences[param1][CENTER]);
            case 
3:
                
g_c4Preferences[param1][HUD] = Flip(g_c4Preferences[param1][HUD]);
        }
        new 
String:steamId[20];
        
GetClientAuthString(param1steamId20);
        
KvRewind(g_kvC4);
        
KvJumpToKey(g_kvC4steamId);
        
KvSetNum(g_kvC4"sound"g_c4Preferences[param1][SOUND]);
        
KvSetNum(g_kvC4"chat"g_c4Preferences[param1][CHAT]);
        
KvSetNum(g_kvC4"center"g_c4Preferences[param1][CENTER]);
        
KvSetNum(g_kvC4"hud"g_c4Preferences[param1][HUD]);
        
KvSetNum(g_kvC4"timestamp"GetTime());
        
SettingsMenu(param10);
    } else if(
action == MenuAction_End)    {
        
CloseHandle(menu);
    }
}
 
//  This creates the settings panel
public Action:SettingsMenu(clientargs)
{
    
decl String:buffer[100];
    new 
Handle:menu CreateMenu(SettingsMenuHandler);
    
Format(buffersizeof(buffer), "%T""c4 menu"client);
    
SetMenuTitle(menubuffer);
    if(
g_c4Preferences[client][SOUND] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable sound"client);
    } else {
        
Format(buffersizeof(buffer), "%T""enable sound"client);
    }
    
AddMenuItem(menu"menu item"buffer);

    if(
g_c4Preferences[client][CHAT] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable chat"client);
    }
    else {
        
Format(buffersizeof(buffer), "%T""enable chat"client);
    }
    
AddMenuItem(menu"menu item"buffer);
    
    if(
g_c4Preferences[client][CENTER] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable center"client);
    } else {
        
Format(buffersizeof(buffer), "%T""enable center"client);
    }
    
AddMenuItem(menu"menu item"buffer);
    
    if(
g_c4Preferences[client][HUD] == 1)
    {
        
Format(buffersizeof(buffer), "%T""disable hud"client);
    }
    else {
        
Format(buffersizeof(buffer), "%T""enable hud"client);
    }
    
AddMenuItem(menu"menu item"buffer);

    
DisplayMenu(menuclient15);
     
    return 
Plugin_Handled;
}

// Switches a non-zero number to a 0 and a 0 to a 1
public Flip(flipNum)
{
    if(
flipNum == 0)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}

// Initializations to be done at the beginning of the round
public EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
// Save user settings to a file
    
KvRewind(g_kvC4);
    
KeyValuesToFile(g_kvC4g_filenameC4);
    if(
hTimer != INVALID_HANDLE)
    {
        
KillTimer(hTimer);
    }
}

// When a user disconnects we need to update their timestamp in kvC4
public OnClientDisconnect(client)
{
    new 
String:steamId[20];
    if(
client && !IsFakeClient(client))
    {
        
GetClientAuthString(clientsteamId20);
        
KvRewind(g_kvC4);
        if(
KvJumpToKey(g_kvC4steamId))
        {
            
KvSetNum(g_kvC4"timestamp"GetTime());
        }
    }
}

public 
PrepareClient(client)
{
    new 
String:steamId[20];
    if(
client)
    {
        if(!
IsFakeClient(client))
        {
            
// Get the users saved setting or create them if they don't exist
            
GetClientAuthString(clientsteamId20);
            
KvRewind(g_kvC4);
            if(
KvJumpToKey(g_kvC4steamId))
            {
                
g_c4Preferences[client][SOUND] = KvGetNum(g_kvC4"sound"GetConVarInt(g_CvarSoundDefault));
                
g_c4Preferences[client][CHAT] = KvGetNum(g_kvC4"chat"GetConVarInt(g_CvarChatDefault));
                
g_c4Preferences[client][CENTER] = KvGetNum(g_kvC4"center"GetConVarInt(g_CvarCenterDefault));
                
g_c4Preferences[client][HUD] = KvGetNum(g_kvC4"hud"GetConVarInt(g_CvarHUDDefault));
            } else {
                
KvRewind(g_kvC4);
                
KvJumpToKey(g_kvC4steamIdtrue);
                
KvSetNum(g_kvC4"sound"GetConVarInt(g_CvarSoundDefault));
                
KvSetNum(g_kvC4"chat"GetConVarInt(g_CvarChatDefault));
                
KvSetNum(g_kvC4"center"GetConVarInt(g_CvarCenterDefault));
                
KvSetNum(g_kvC4"hud"GetConVarInt(g_CvarHUDDefault));
                
g_c4Preferences[client][SOUND] = GetConVarInt(g_CvarSoundDefault);
                
g_c4Preferences[client][CHAT] = GetConVarInt(g_CvarChatDefault);
                
g_c4Preferences[client][CENTER] = GetConVarInt(g_CvarCenterDefault);
                
g_c4Preferences[client][HUD] = GetConVarInt(g_CvarHUDDefault);
            }
            
KvRewind(g_kvC4);

            
// Make the announcement in 30 seconds unless announcements are turned off
            
if(GetConVarBool(g_CvarAnnounce))
            {
                
CreateTimer(30.0TimerAnnounceclient);
            }
        }
    }
}

public 
EventBombExploded(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
hTimer != INVALID_HANDLE)
    {
        
KillTimer(hTimer);
    }
    for(new 
1<= GetMaxClients(); i++)
    {
        if(
IsClientInGame(i) && !IsFakeClient(i) && g_c4Preferences[i][HUD])
        {
            
PrintHintText(i"%T""bomb exploded"ig_planter);
        }
    }


Last edited by w4rkr4f7; 07-12-2011 at 13:12.
w4rkr4f7 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-12-2011 , 13:43   Re: CSS c4timer
Reply With Quote #4

The easiest way to do this would be, I think, to hook the round_end event and kill the timer there. I've added an attachment that does just that (and fixes the "center" error, as it should be "CENTER").

btw, using KillTimer without setting hTimer = INVALID_HANDLE is just asking for trouble.

I don't really understand how often the timer itself is supposed to tick, or I'd replace the current timer code with one that uses TIMER_REPEAT instead of continually replacing the timer with a new one.

Note: I'm at work and can't test this to see if it actually works.
Attached Files
File Type: sp Get Plugin or Get Source (advancedc4timer.sp - 549 views - 15.5 KB)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-12-2011 at 14:43.
Powerlord is offline
w4rkr4f7
Member
Join Date: Dec 2008
Old 07-13-2011 , 11:58   Re: CSS c4timer
Reply With Quote #5

L 07/13/2011 - 19:07:13: [SM] Native "KillTimer" reported: Invalid timer handle 1cdb021e (error 3)
L 07/13/2011 - 19:07:13: [SM] Displaying call stack trace for plugin "advancedc4timer.smx":
L 07/13/2011 - 19:07:13: [SM] [0] Line 433, /home/groups/alliedmodders/forums/files/3/8/9/9/6/88904.attach::EventRoundEnd()
L 07/13/2011 - 19:07:20: [SM] Native "KillTimer" reported: Invalid timer handle 1cdb021e (error 1)
L 07/13/2011 - 19:07:20: [SM] Displaying call stack trace for plugin "advancedc4timer.smx":
L 07/13/2011 - 19:07:20: [SM] [0] Line 424, /home/groups/alliedmodders/forums/files/3/8/9/9/6/88904.attach::EventRoundStart()
L 07/13/2011 - 19:09:19: Error log file session closed.

Last edited by w4rkr4f7; 07-13-2011 at 12:13.
w4rkr4f7 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-13-2011 , 12:25   Re: CSS c4timer
Reply With Quote #6

Quote:
Originally Posted by w4rkr4f7 View Post
L 07/13/2011 - 19:07:13: [SM] Native "KillTimer" reported: Invalid timer handle 1cdb021e (error 3)
L 07/13/2011 - 19:07:13: [SM] Displaying call stack trace for plugin "advancedc4timer.smx":
L 07/13/2011 - 19:07:13: [SM] [0] Line 433, /home/groups/alliedmodders/forums/files/3/8/9/9/6/88904.attach::EventRoundEnd()
L 07/13/2011 - 19:07:20: [SM] Native "KillTimer" reported: Invalid timer handle 1cdb021e (error 1)
L 07/13/2011 - 19:07:20: [SM] Displaying call stack trace for plugin "advancedc4timer.smx":
L 07/13/2011 - 19:07:20: [SM] [0] Line 424, /home/groups/alliedmodders/forums/files/3/8/9/9/6/88904.attach::EventRoundStart()
L 07/13/2011 - 19:09:19: Error log file session closed.
OK, I've attached a new version that should set the timer's handle to INVALID_HANDLE in two other spots (one of which violated my own note earlier about calling KillTimer without setting the handle to INVALID_HANDLE). Hopefully that'll address this issue.
Attached Files
File Type: sp Get Plugin or Get Source (advancedc4timer.sp - 2044 views - 15.6 KB)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-13-2011 at 12:29.
Powerlord is offline
w4rkr4f7
Member
Join Date: Dec 2008
Old 07-13-2011 , 13:16   Re: CSS c4timer
Reply With Quote #7

Quote:
Originally Posted by Powerlord View Post
OK, I've attached a new version that should set the timer's handle to INVALID_HANDLE in two other spots (one of which violated my own note earlier about calling KillTimer without setting the handle to INVALID_HANDLE). Hopefully that'll address this issue.

THANKS ,now is working perfect.
w4rkr4f7 is offline
sinblaster
Grim Reaper
Join Date: Feb 2010
Location: Australia
Old 07-13-2011 , 16:47   Re: CSS c4timer
Reply With Quote #8

Thanks powerlord.

You know seta remade one of these not very long ago that does the same thing with a pretty neat cfg w4.
[CS:S] Improved Bomb Events
__________________
Happy Happy Joy Joy

sinblaster 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 02:51.


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