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

[REQ] Countdown and freeze


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dejan
Senior Member
Join Date: Mar 2009
Location: Sweden
Old 11-21-2010 , 01:20   [REQ] Countdown and freeze
Reply With Quote #1

could anyone give me a 10 seconds countdown while counting down the player cant move and when the countdown ends make it start

PHP Code:
started(id
__________________
dejan is offline
Send a message via Skype™ to dejan
Ryokin
Senior Member
Join Date: Jan 2010
Old 11-21-2010 , 01:39   Re: [REQ] Countdown and freeze
Reply With Quote #2

look at hns mod
__________________
NH4CL + NaOH -> NH3 + H2O + NaCL
Ryokin is offline
shadow.hk
Senior Member
Join Date: Dec 2008
Location: WA, Australia
Old 11-21-2010 , 02:36   Re: [REQ] Countdown and freeze
Reply With Quote #3

  1. Iterate through players and set maxspeed to 0.1
  2. Set global variable countdown to true and counter to whatever time you want
  3. Start countdown task and set it each time after
  4. Hook event curweapon and set it to 0.1 every time they change weapon (as long as global variable countdown is true)
  5. Use global variable for the counter
  6. Start task and set it each time within the task until counter runs out
  7. Set maxspeed back to 250.0 and global variable countdown to false

If you don't want users to attack then you'd have to hook something like Ham_Weapon_Primary and Secondary attacks and supercede them. Hooking player spawn should be good as well, and set their maxspeed to 0.1 if the countdown is in progress.
shadow.hk is offline
Send a message via MSN to shadow.hk
bibu
Veteran Member
Join Date: Sep 2010
Old 11-21-2010 , 07:39   Re: [REQ] Countdown and freeze
Reply With Quote #4

This is a Suggestions / Requests section guys...
bibu is offline
shadow.hk
Senior Member
Join Date: Dec 2008
Location: WA, Australia
Old 11-22-2010 , 12:56   Re: [REQ] Countdown and freeze
Reply With Quote #5

Untested. I'll test sometime tomorrow if I get time.

PHP Code:
/**
 *         
 *         --------------
 *         Copyright 2010,
 *         shadow.hk
 *         --------------
 *         
 *         Starts a countdown every roundstart.
 *         
 *         
 *         Cvars
 *         ---------------
 *         
 *         // Enable countdown
 *         // Default: 1
 *         
 *         countdown_enabled
 *         
 *         // Fade player screen black during countdown
 *         // Default: 1
 *         
 *         countdown_screenfade
 *         
 *         // Countdown time
 *         // Default: 10
 *         
 *         countdown_time
 *         
 */



#pragma semicolon 1

#include <amxmodx>
#include <engine>
#include <hamsandwich>

#define FFADE_IN        0x0000 // just here so we don't pass 0 into the function
#define FFADE_OUT        0x0001 // fade out (not in)
#define FFADE_MODULATE    0x0002 // modulate (don't blend)
#define FFADE_STAYOUT    0x0004 // ignores the duration, stays faded out until new ScreenFade message received

#define MAX_PLAYERS 32

#define SECOND 4096.0

#define TASK_ID_COUNTDOWN 100

new bool:g_bAliveMAX_PLAYERS ];
new 
bool:g_bConnectedMAX_PLAYERS ];

new 
bool:g_bCountdown;

new const 
g_szWeaponName[ ][ ] = 
{
    
"weapon_usp"
    
"weapon_glock18"
    
"weapon_deagle"
    
"weapon_p228"
    
"weapon_elite"
    
"weapon_fiveseven"
    
"weapon_m3"
    
"weapon_xm1014"
    
"weapon_tmp"
    
"weapon_mac10"
    
"weapon_mp5navy"
    
"weapon_p90"
    
"weapon_ump45"
    
"weapon_famas"
    
"weapon_galil"
    
"weapon_ak47"
    
"weapon_m4a1"
    
"weapon_sg552"
    
"weapon_aug"
    
"weapon_scout"
    
"weapon_sg550"
    
"weapon_awp"
    
"weapon_g3sg1"
    
"weapon_m249"
    
"weapon_hegrenade"
    
"weapon_smokegrenade"
    
"weapon_flashbang"
    
"weapon_shield"
    
"weapon_c4"
    
"weapon_knife"
};

new 
g_iCountdown;
new 
g_iMaxPlayers;

new 
g_msgScreenFade;
new 
g_msgSyncHud;

new 
p_Countdown_Enabled;
new 
p_Countdown_Screenfade;
new 
p_Countdown_Time;

public 
plugin_init( )
{
    
register_plugin"Countdown""1.0""shadow.hk" );
    
    
register_event"CurWeapon",    "EventCurWeapon",    "be" );
    
register_event"DeathMsg",        "EventDeathMsg",    "a" );    
    
    
register_logevent"LogEventRoundStart",    2,    "1=Round_Start" );
    
register_logevent"LogEventRoundEnd",        2,    "1=Round_End" );
    
    
RegisterHamHam_Spawn"player""HamSpawn_Post");
    
    for( new 
0sizeofg_szWeaponName ); i++ )
    {
        
RegisterHamHam_Weapon_PrimaryAttack,        g_szWeaponName],    "Ham_Weapon_Attack",    );
        
RegisterHamHam_Weapon_SecondaryAttack,    g_szWeaponName],    "Ham_Weapon_Attack",    );
    }
    
    
g_msgScreenFade get_user_msgid"ScreenFade" );
    
    
p_Countdown_Enabled        register_cvar"countdown_enabled",        "1" );
    
p_Countdown_Screenfade    register_cvar"countdown_screenfade",    "1" );
    
p_Countdown_Time        register_cvar"countdown_time",            "10" );
    
    
g_msgSyncHud CreateHudSyncObj( );
    
    
g_iMaxPlayers get_maxplayers( );
}

public 
client_putinserverid )
{
    
g_bConnectedid ] = true;
}

public 
client_disconnectid )
{
    
g_bAliveid ] = false;
    
g_bConnectedid ] = false;
}

public 
EventCurWeaponid )
{
    if( 
g_bCountdown )
    {
        
entity_set_floatidEV_FL_maxspeed0.1 );
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
EventDeathMsg( )
{
    
g_bAliveread_data) ] = false;
}

public 
LogEventRoundStart( )
{
    if( 
get_pcvar_num( !p_Countdown_Enabled ) || get_playersnum( ) <= )
    {
        return;
    }
    
    
g_bCountdown true;
    
g_iCountdown get_pcvar_nump_Countdown_Time );
    
    
// iterate through and set players maxspeed to null
    
for( new id 1id <= g_iMaxPlayersid++ )
    {
        if( !
g_bAliveid ] )
        {
            continue;
        }
        
        
// fade to black
        
if( get_pcvar_nump_Countdown_Screenfade ) )
        {
            
MsgScreenFadeid0.0FFADE_STAYOUT, { 00}, 255 );
        }
        
        
entity_set_floatidEV_FL_maxspeed0.1 );
    }
    
    
TaskCountdown( );
}

public 
LogEventRoundEnd( )
{
    if( 
g_bCountdown )
    {
        
MsgScreenFade00.0FFADE_IN, { 255255255 }, );
        
remove_taskTASK_ID_COUNTDOWN );
        
        
ClearSyncHud0g_msgSyncHud );
        
        
g_bCountdown false;
    }
}

public 
HamSpawn_Postid )
{
    if( !
is_user_aliveid ) )
    {
        return;
    }
    
    
g_bAliveid ] = true;
    
    if( 
g_bCountdown )
    {
        
entity_set_floatidEV_FL_maxspeed0.1 );
        
        
// set screen to black
        
if( get_pcvar_nump_Countdown_Screenfade ) )
        {
            
MsgScreenFadeid0.0FFADE_STAYOUT, { 00}, 255 );
        }
    }
}

public 
Ham_Weapon_AttackiWeaponID )
{
    if( 
g_bCountdown )
    {
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}

public 
TaskCountdown( )
{
    if( !
g_bCountdown )
    {
        
ClearSyncHud0g_msgSyncHud );
        return;
    }
    
    
set_hudmessage255255255, -1.00.3506.05.00.10.2);
    
    
// countdown is finished, remove everything
    
if( g_iCountdown-- <= )
    {
        for( new 
id 1id <= g_iMaxPlayersid++ )
        {
            if( !
g_bAliveid ] )
            {
                continue;
            }
            
            
// always do this in case screenfade was disabled during the countdown
            
MsgScreenFadeid0.0FFADE_IN, { 255255255 }, );
            
            
entity_set_floatidEV_FL_maxspeed250.0 );
        }
        
        
ShowSyncHudMsg0g_msgSyncHud"GO GO GO" );
        return;
    }
    
    
ShowSyncHudMsg0g_msgSyncHud"Countdown: %i"g_iCountdown );
    
    
set_task1.0"TaskCountdown"TASK_ID_COUNTDOWN );
}

/**
 * Sends a screenfade message to a client.
 * 
 * @param index            Player index.
 * @param duration        Duration of screenfade (seconds).
 * @param fadetype        Fade type.
 * @param colours        Screenfade colours.
 * @param brightness    Screenfade brightness.
 */
stock MsgScreenFadeindexFloat:durationfadetypecolours], brightness )
{
    
message_beginindex MSG_ONE_UNRELIABLE MSG_BROADCASTg_msgScreenFade, { 00}, index );
    
write_shortfloatroundduration SECOND ) );
    
write_shortfloatroundduration SECOND ) );
    
write_shortfadetype );
    
write_byteclampcolours], 0255 ) );
    
write_byteclampcolours], 0255 ) );
    
write_byteclampcolours], 0255 ) );
    
write_byteclampbrightness0255 ) );
    
message_end( );


Last edited by shadow.hk; 11-22-2010 at 13:50.
shadow.hk is offline
Send a message via MSN to shadow.hk
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 10:03.


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