View Single Post
Author Message
JUSTINR
Member
Join Date: May 2022
Old 07-23-2022 , 10:31   Respawn in game mode
Reply With Quote #1

How can i add respawn in this mode SNIPER VS NEMESIS ?
Code:
#include < amxmodx >

#include < fun >

#include < zombie_plague_advance >



new const g_chance = 120

new const g_access_flag[] = "a"



new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_nemhp, g_msg_sync



public plugin_init( )

{

	register_plugin( "[ZP] Snipers VS Nemesis Mode","1.0", "zmd94" )

	

	cvar_minplayers = register_cvar("zp_minplayers", "2")

	cvar_sniperhp =	  register_cvar("zp_sniper_hp", "1.5")

	cvar_nemhp =	  register_cvar("zp_nem_hp", "1.0")

	cvar_ratio = 	  register_cvar("zp_svn_inf_ratio", "0.5")

	

	g_maxplayers = get_maxplayers()

	g_msg_sync = CreateHudSyncObj()

}



public plugin_natives()

{

    register_native("zp_is_svn_round", "native_is_svn_round", 1)

}



public plugin_precache( )

{

	new access_flag = read_flags( g_access_flag )

	

	g_gameid = zp_register_game_mode( "Sniper vs Nemesis Mode", 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_nemhp)) )

		}

		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_svn_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, "Snipers vs Nemesis Mode!")

	}

}



public zp_game_mode_selected( gameid, id )

{

	if( gameid == g_gameid )

		start_svn_mode( )



	return PLUGIN_CONTINUE

}



start_svn_mode( )

{

	static i_nemesiss, i_max_nemesiss, id, i_alive

	i_alive = fn_get_alive_players()

	id = 0

	

	i_max_nemesiss = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil )

	i_nemesiss = 0

	

	while (i_nemesiss < i_max_nemesiss)

	{

		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_nemhp)) )

			

			i_nemesiss++

		}

	}

	

	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)) )

	}

}



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;

}



public native_is_svn_round()

{

    return zp_get_current_mode() == g_gameid ? true : false

}

Last edited by JUSTINR; 07-23-2022 at 10:31.
JUSTINR is offline