Raised This Month: $ Target: $400
 0% 

CountDown + Freeze by Shadow.hk


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bloody806
Member
Join Date: Jun 2012
Location: Czech Republic
Old 05-01-2013 , 09:35   CountDown + Freeze by Shadow.hk
Reply With Quote #1

Hi all i need help with this plugin:
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",            "5" );
    
    
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( );

But when I add on server and connect to any team server crashed..

Here is errors from concose.

L 05/01/2013 - 15:25:06: [AMXX] Displaying debug trace (plugin "shadowhk_countdown.amxx")
L 05/01/2013 - 15:25:06: [AMXX] Run time error 10: native error (native "get_pcvar_num")
L 05/01/2013 - 15:25:06: [AMXX] [0] shadowhk_countdown.sma::LogEventRoundStart (line 157)

Do not know why the server crashed? Please help
__________________

Last edited by bloody806; 05-01-2013 at 09:37.
bloody806 is offline
Send a message via Skype™ to bloody806
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 05-02-2013 , 04:20   Re: CountDown + Freeze by Shadow.hk
Reply With Quote #2

if( get_pcvar_num( !p_Countdown_Enabled ) || get_playersnum( ) <= 1 )
-->
if(!(get_pcvar_num( p_Countdown_Enabled )) || get_playersnum( ) <= 1 )
didoWEE is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 05-03-2013 , 06:49   Re: CountDown + Freeze by Shadow.hk
Reply With Quote #3

Quote:
Originally Posted by didoWEE View Post
if( get_pcvar_num( !p_Countdown_Enabled ) || get_playersnum( ) <= 1 )
-->
if(!(get_pcvar_num( p_Countdown_Enabled )) || get_playersnum( ) <= 1 )
+1
Also, use FL_FROZEN, it's better then setting the maxspeed of a client to 0.1.
__________________
simanovich is offline
myusername
Senior Member
Join Date: Aug 2012
Old 05-04-2013 , 11:28   Re: CountDown + Freeze by Shadow.hk
Reply With Quote #4

Quote:
Originally Posted by simanovich View Post
+1
Also, use FL_FROZEN, it's better then setting the maxspeed of a client to 0.1.
Can u show?
__________________
Rest in piece.
myusername is offline
bloody806
Member
Join Date: Jun 2012
Location: Czech Republic
Old 05-04-2013 , 16:54   Re: CountDown + Freeze by Shadow.hk
Reply With Quote #5

didoWEE thanks no show errors. But when someone joins the team server always crashed. Dont you know why?
__________________
bloody806 is offline
Send a message via Skype™ to bloody806
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:55.


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