| bloody806 |
05-01-2013 09:35 |
CountDown + Freeze by Shadow.hk
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_bAlive[ MAX_PLAYERS + 1 ]; new bool:g_bConnected[ MAX_PLAYERS + 1 ];
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" ); RegisterHam( Ham_Spawn, "player", "HamSpawn_Post", 1 ); for( new i = 0; i < sizeof( g_szWeaponName ); i++ ) { RegisterHam( Ham_Weapon_PrimaryAttack, g_szWeaponName[ i ], "Ham_Weapon_Attack", 0 ); RegisterHam( Ham_Weapon_SecondaryAttack, g_szWeaponName[ i ], "Ham_Weapon_Attack", 0 ); } 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_putinserver( id ) { g_bConnected[ id ] = true; }
public client_disconnect( id ) { g_bAlive[ id ] = false; g_bConnected[ id ] = false; }
public EventCurWeapon( id ) { if( g_bCountdown ) { entity_set_float( id, EV_FL_maxspeed, 0.1 ); return PLUGIN_HANDLED; } return PLUGIN_CONTINUE; }
public EventDeathMsg( ) { g_bAlive[ read_data( 2 ) ] = false; }
public LogEventRoundStart( ) { if( get_pcvar_num( !p_Countdown_Enabled ) || get_playersnum( ) <= 1 ) { return; } g_bCountdown = true; g_iCountdown = get_pcvar_num( p_Countdown_Time ); // iterate through and set players maxspeed to null for( new id = 1; id <= g_iMaxPlayers; id++ ) { if( !g_bAlive[ id ] ) { continue; } // fade to black if( get_pcvar_num( p_Countdown_Screenfade ) ) { MsgScreenFade( id, 0.0, FFADE_STAYOUT, { 0, 0, 0 }, 255 ); } entity_set_float( id, EV_FL_maxspeed, 0.1 ); } TaskCountdown( ); }
public LogEventRoundEnd( ) { if( g_bCountdown ) { MsgScreenFade( 0, 0.0, FFADE_IN, { 255, 255, 255 }, 0 ); remove_task( TASK_ID_COUNTDOWN ); ClearSyncHud( 0, g_msgSyncHud ); g_bCountdown = false; } }
public HamSpawn_Post( id ) { if( !is_user_alive( id ) ) { return; } g_bAlive[ id ] = true; if( g_bCountdown ) { entity_set_float( id, EV_FL_maxspeed, 0.1 ); // set screen to black if( get_pcvar_num( p_Countdown_Screenfade ) ) { MsgScreenFade( id, 0.0, FFADE_STAYOUT, { 0, 0, 0 }, 255 ); } } }
public Ham_Weapon_Attack( iWeaponID ) { if( g_bCountdown ) { return HAM_SUPERCEDE; } return HAM_IGNORED; }
public TaskCountdown( ) { if( !g_bCountdown ) { ClearSyncHud( 0, g_msgSyncHud ); return; } set_hudmessage( 255, 255, 255, -1.0, 0.35, 0, 6.0, 5.0, 0.1, 0.2, 4 ); // countdown is finished, remove everything if( g_iCountdown-- <= 1 ) { for( new id = 1; id <= g_iMaxPlayers; id++ ) { if( !g_bAlive[ id ] ) { continue; } // always do this in case screenfade was disabled during the countdown MsgScreenFade( id, 0.0, FFADE_IN, { 255, 255, 255 }, 0 ); entity_set_float( id, EV_FL_maxspeed, 250.0 ); } ShowSyncHudMsg( 0, g_msgSyncHud, "GO GO GO" ); return; } ShowSyncHudMsg( 0, g_msgSyncHud, "Countdown: %i", g_iCountdown ); set_task( 1.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 MsgScreenFade( index, Float:duration, fadetype, colours[ 3 ], brightness ) { message_begin( index ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_msgScreenFade, { 0, 0, 0 }, index ); write_short( floatround( duration * SECOND ) ); write_short( floatround( duration * SECOND ) ); write_short( fadetype ); write_byte( clamp( colours[ 0 ], 0, 255 ) ); write_byte( clamp( colours[ 1 ], 0, 255 ) ); write_byte( clamp( colours[ 2 ], 0, 255 ) ); write_byte( clamp( brightness, 0, 255 ) ); 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
|