Re: sniper vs nemesis mode
try
PHP Code:
#include < amxmodx > #include < fun > #include < zombie_plague_advance >
new const g_chance = 15 new const g_access_flag[] = "a" new const g_play_sounds[][] = { "zombie_plague/sniper1.wav" , "zombie_plague/nemesis1.wav" }
#define AMBIENCE_SOUNDS #if defined AMBIENCE_SOUNDS
new const g_sound_ambience[][] = { "zombie_plague/ambience.wav" } new const Float:g_sound_ambience_duration[] = { 58.0 , 56.0 } #endif
new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_nemehp, g_msg_sync
// Ambience sounds task #define TASK_AMB 3256
public plugin_init( ) { register_plugin( "[ZPA] Game mode : Sniper vs Nemesis","1.0", "@bdul!" )
cvar_minplayers = register_cvar("zp_svsn_minplayers", "2") cvar_sniperhp = register_cvar("zp_svsn_sniper_hp", "1.5") cvar_nemehp = register_cvar("zp_svsn_nemesis_hp", "1.0") cvar_ratio = register_cvar("zp_svsn_inf_ratio", "0.5") g_maxplayers = get_maxplayers( ) g_msg_sync = CreateHudSyncObj() }
public plugin_precache( ) { new access_flag = read_flags( g_access_flag ) new i for (i = 0; i < sizeof g_play_sounds; i++) precache_sound( g_play_sounds[i] ) #if defined AMBIENCE_SOUNDS new sound[100] for (i = 0; i < sizeof g_sound_ambience; i++) { if (equal(g_sound_ambience[i][strlen(g_sound_ambience[i])-4], ".mp3")) { formatex(sound, sizeof sound - 1, "sound/%s", g_sound_ambience[i]) precache_generic( sound ) } else { precache_sound( g_sound_ambience[i] ) } } #endif g_gameid = zp_register_game_mode( "Sniper vs Nemesis", access_flag, g_chance, 0, ZP_DM_BALANCE ) }
public zp_player_spawn_post( id ) { if( zp_get_current_mode() == g_gameid ) { if( zp_get_user_zombie( id )) { zp_make_user_nemesis( id ) set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemehp)) ) } else { zp_make_user_sniper( id ) set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) ) } } }
public zp_round_started_pre( game ) { if( game == g_gameid ) { if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) ) { return ZP_PLUGIN_HANDLED } start_avs_mode( ) } return PLUGIN_CONTINUE }
public zp_round_started( game, id ) { if( game == g_gameid ) { set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1) ShowSyncHudMsg(0, g_msg_sync, "Sniper vs Nemesis Mode !!!") client_cmd(0, "spk ^"%s^"", g_play_sounds[ random_num(0, sizeof g_play_sounds -1) ] ) remove_task( TASK_AMB ) #if defined AMBIENCE_SOUNDS set_task( 2.0, "start_ambience_sounds", TASK_AMB ) #endif } }
public zp_game_mode_selected( gameid, id ) { if( gameid == g_gameid ) start_avs_mode( ) return PLUGIN_CONTINUE }
start_avs_mode( ) { static i_nemesis, i_max_nemesis, id, i_alive i_alive = fn_get_alive_players() id = 0 i_max_nemesis = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil ) i_nemesis = 0 while (i_nemesis < i_max_nemesis) { if ( (++id) > g_maxplayers) id = 1 if ( !is_user_alive(id) ) continue; if (random_num(1, 5) == 1) { zp_make_user_nemesis(id) set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemehp)) ) i_nemesis++ } } for (id = 1; id <= g_maxplayers; id++) { if ( !is_user_alive(id) || zp_get_user_nemesis(id) ) continue; zp_make_user_sniper(id) set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) ) } }
#if defined AMBIENCE_SOUNDS public start_ambience_sounds( ) { static amb_sound[64], sound, Float:duration
sound = random_num( 0, sizeof g_sound_ambience - 1 ) copy( amb_sound, sizeof amb_sound - 1 , g_sound_ambience[ sound ] ) duration = g_sound_ambience_duration[ sound ] if ( equal( amb_sound[ strlen( amb_sound ) - 4 ], ".mp3" ) ) client_cmd( 0, "mp3 play ^"sound/%s^"", amb_sound ) else client_cmd( 0, "spk ^"%s^"", sound ) set_task( duration, "start_ambience_sounds", TASK_AMB ) } public zp_round_ended( winteam ) { remove_task( TASK_AMB ) } #endif
fn_get_alive_players( ) { static i_alive, id i_alive = 0 for ( id = 1; id <= g_maxplayers; id++ ) { if( is_user_alive( id ) ) i_alive++ } return i_alive; }
|