ModmeDTZxPorter: Goodbye

New Modme platform coming soon!
Detect damage on a model ( NO TRIGGERS )
Viewed 1056 time(s)
Topic created on 1515167290
Reply #15 on 1547319720
Modme User
43 wins

in grab_pyrotechnic change 

if( isdefined(player.pyrotechnic_active) )

 

to

if( isdefined(player.pyrotechnic_active) && player.pyrotechnic_active == 1 )

 

just incase.

 

 

The problem is that you set 

level.pyrotechnic_active = false;

 

immediately after setting it to true. Actually you did it before but im guessing since the cpu has to process a bunch of code it gets set after.

anyway

Move

level.pyrotechnic_active = false;

 

to the end of 

function wait_til_timeout

 

 


Don't PM me about stuff that should be on the forum.
My creations:
Debug (on/off)
Jukebox
Gum Anti-cheat
Kino box locator
Elemental Bows

Test search engine for this site via Google
Reply #16 on 1547343866
Modme User
1 wins

mathfag

in grab_pyrotechnic change  if( isdefined(player.pyrotechnic_active) )   to if( isdefined(player.pyrotechnic_active) && player.pyrotechnic_active == 1 )   just incase.     The problem is that you set  level.pyrotechnic_active = false;   immediately after setting it to true. Actually you did it before but im guessing since the cpu has to process a bunch of code it gets set after. anyway Move level.pyrotechnic_active = false;   to the end of  function wait_til_timeout    

 I dont have words to describe my gratitude with you, seriously, thanks.

 

When i spawn in the game the "Knife effect" is active, i grab the powerup for the first time, the "Knife effect" still active, when the powerup is over, the "Knife effect" is over. (Everything goes back to normal)

 

I grab the powerup for the second time, the powerup is working perfect all the time.

//POWERUP
function __init__()
{	
	zm_powerups::register_powerup( "pyrotechnic", &grab_pyrotechnic );
	if( ToLower( GetDvarString( "g_gametype" ) ) != "pyrotechnic" )
	{
		zm_powerups::add_zombie_powerup( "pyrotechnic", "pyrotechnic_powerup_model", "", &zm_powerups::func_should_always_drop, POWERUP_ONLY_AFFECTS_GRABBER, !POWERUP_ANY_TEAM, !POWERUP_ZOMBIE_GRABBABLE );
		zm_spawner::register_zombie_damage_callback( &knife_dmg );					
	} 
}

function grab_pyrotechnic( player )
{
	player PlayLocalSound("vox_pyrotechnic");
	skip = player add_powerup_hud( "pyrotechnic_material_hud", N_POWERUP_DEFAULT_TIME );    	

	if( skip )
		return; 
	
	if( isdefined(player.pyrotechnic_active) && player.pyrotechnic_active == 1 )
		return;		
	
	player thread do_pyrotechnic();

}

function do_pyrotechnic()
{
	level.pyrotechnic_active = true;

    self notify( "pyrotechnic_done" );
    self endon( "disconnect" );
    self endon( "death" );
    self endon( "pyrotechnic_done" );

       
}

function knife_dmg(str_mod, str_hit_location, v_hit_origin, e_player, n_amount, w_weapon, direction_vec, tagName, modelName, partName, dFlags, inflictor, chargeLevel) 
{		

	if(level.pyrotechnic_active == 0)
	return 0;

	if(str_mod == "MOD_MELEE")
	{
		self thread fire_works_summon( e_player, w_weapon );
	}

	WAIT_SERVER_FRAME;
}

//HUD
function wait_til_timeout( player, hud )//player = self;
{
	while( hud.time > 0 )
	{
		wait(1);
		hud.time--; 		
	}
	
	player notify( "pyrotechnic_done" );
	player remove_powerup_hud( "pyrotechnic_material_hud" );
	player.pyrotechnic_active = undefined;
	level.pyrotechnic_active = false;
	
	
}

function add_powerup_hud( powerup, timer )
{
	if ( !isDefined( self.powerup_hud ) )
		self.powerup_hud = [];
	
	if( isDefined( self.powerup_hud[powerup] ) )
	{
		self.powerup_hud[powerup].time = timer; 
		return true; // tells to skip because powerup is already active
				
	}
	
	self endon( "disconnect" );
	hud = NewClientHudElem( self );
	hud.powerup = powerup;
	hud.foreground = true;
	hud.hidewheninmenu = true;
	hud.alignX = "center";
	hud.alignY = "bottom";
	hud.horzAlign = "center";
	hud.vertAlign = "bottom";
	hud.x = hud.x;
	hud.y = hud.y - 50;
	hud.alpha = 1;
	hud SetShader( powerup , 64, 64 );
	hud scaleOverTime( .5, 32, 32 );
	hud.time = timer;
	hud thread harrybo21_blink_powerup_hud();
	thread wait_til_timeout( self, hud ); 
	
	self.powerup_hud[ powerup ] = hud;
	
	a_keys = GetArrayKeys( self.powerup_hud );
	for ( i = 0; i < a_keys.size; i++ )
	 	self.powerup_hud[ a_keys[i] ] thread move_hud( .5, 0 - ( 24 * ( self.powerup_hud.size ) ) + ( i * 37.5 ) + 25, self.powerup_hud[ a_keys[i] ].y );
	
	return false;  // powerup is not already active
}




function move_hud( time, x, y )
{
	self moveOverTime( time );
	self.x = x;
	self.y = y;
}

function harrybo21_blink_powerup_hud()
{
	self endon( "delete" );
	self endon( "stop_fade" );
	while( isDefined( self ) )
	{
		if ( self.time >= 20 )
		{
			self.alpha = 1; 
			wait .1;
			continue;
		}
		fade_time = 1;
		if ( self.time < 10 )
			fade_time = .5;
		if ( self.time < 5 )
			fade_time = .25;
			
		self fadeOverTime( fade_time );
		self.alpha = !self.alpha;
		
		wait( fade_time );
	}
}

function remove_powerup_hud( powerup )
{
	self.powerup_hud[ powerup ] destroy();
	self.powerup_hud[ powerup ] notify( "stop_fade" );
	self.powerup_hud[ powerup ] fadeOverTime( .2 );
	self.alpha = 0;
	wait .2;
	self.powerup_hud[ powerup ] delete();
	self.powerup_hud[ powerup ] = undefined;
	self.powerup_hud = array::remove_index( self.powerup_hud, self.powerup_hud[ powerup ], true );
	
	a_keys = GetArrayKeys( self.powerup_hud );
	for ( i = 0; i < a_keys.size; i++ )
	 	self.powerup_hud[ a_keys[i] ] thread move_hud( .5, 0 - ( 24 * ( self.powerup_hud.size ) ) + ( i * 37.5 ) + 25, self.powerup_hud[ a_keys[i] ].y );
}
Reply #17 on 1547372790
Modme User
43 wins

eDeK

mathfag in grab_pyrotechnic change  if( isdefined(player.pyrotechnic_active) )   to if( isdefined(player.pyrotechnic_active) && player.pyrotechnic_active == 1 )   just incase.     The problem is that you set  level.pyrotechnic_active = false;   immediately after setting it to true. Actually you did it before but im guessing since the cpu has to process a bunch of code it gets set after. anyway Move level.pyrotechnic_active = false;   to the end of  function wait_til_timeout      I dont have words to describe my gratitude with you, seriously, thanks.   When i spawn in the game the "Knife effect" is active, i grab the powerup for the first time, the "Knife effect" still active, when the powerup is over, the "Knife effect" is over. (Everything goes back to normal)   I grab the powerup for the second time, the powerup is working perfect all the time. //POWERUP function __init__() { zm_powerups::register_powerup( "pyrotechnic", &grab_pyrotechnic ); if( ToLower( GetDvarString( "g_gametype" ) ) != "pyrotechnic" ) { zm_powerups::add_zombie_powerup( "pyrotechnic", "pyrotechnic_powerup_model", "", &zm_powerups::func_should_always_drop, POWERUP_ONLY_AFFECTS_GRABBER, !POWERUP_ANY_TEAM, !POWERUP_ZOMBIE_GRABBABLE ); zm_spawner::register_zombie_damage_callback( &knife_dmg ); } } function grab_pyrotechnic( player ) { player PlayLocalSound("vox_pyrotechnic"); skip = player add_powerup_hud( "pyrotechnic_material_hud", N_POWERUP_DEFAULT_TIME ); if( skip ) return; if( isdefined(player.pyrotechnic_active) && player.pyrotechnic_active == 1 ) return; player thread do_pyrotechnic(); } function do_pyrotechnic() { level.pyrotechnic_active = true; self notify( "pyrotechnic_done" ); self endon( "disconnect" ); self endon( "death" ); self endon( "pyrotechnic_done" ); } function knife_dmg(str_mod, str_hit_location, v_hit_origin, e_player, n_amount, w_weapon, direction_vec, tagName, modelName, partName, dFlags, inflictor, chargeLevel) { if(level.pyrotechnic_active == 0) return 0; if(str_mod == "MOD_MELEE") { self thread fire_works_summon( e_player, w_weapon ); } WAIT_SERVER_FRAME; } //HUD function wait_til_timeout( player, hud )//player = self; { while( hud.time > 0 ) { wait(1); hud.time--; } player notify( "pyrotechnic_done" ); player remove_powerup_hud( "pyrotechnic_material_hud" ); player.pyrotechnic_active = undefined; level.pyrotechnic_active = false; } function add_powerup_hud( powerup, timer ) { if ( !isDefined( self.powerup_hud ) ) self.powerup_hud = []; if( isDefined( self.powerup_hud[powerup] ) ) { self.powerup_hud[powerup].time = timer; return true; // tells to skip because powerup is already active } self endon( "disconnect" ); hud = NewClientHudElem( self ); hud.powerup = powerup; hud.foreground = true; hud.hidewheninmenu = true; hud.alignX = "center"; hud.alignY = "bottom"; hud.horzAlign = "center"; hud.vertAlign = "bottom"; hud.x = hud.x; hud.y = hud.y - 50; hud.alpha = 1; hud SetShader( powerup , 64, 64 ); hud scaleOverTime( .5, 32, 32 ); hud.time = timer; hud thread harrybo21_blink_powerup_hud(); thread wait_til_timeout( self, hud ); self.powerup_hud[ powerup ] = hud; a_keys = GetArrayKeys( self.powerup_hud ); for ( i = 0; i < a_keys.size; i++ ) self.powerup_hud[ a_keys[i] ] thread move_hud( .5, 0 - ( 24 * ( self.powerup_hud.size ) ) + ( i * 37.5 ) + 25, self.powerup_hud[ a_keys[i] ].y ); return false; // powerup is not already active } function move_hud( time, x, y ) { self moveOverTime( time ); self.x = x; self.y = y; } function harrybo21_blink_powerup_hud() { self endon( "delete" ); self endon( "stop_fade" ); while( isDefined( self ) ) { if ( self.time >= 20 ) { self.alpha = 1; wait .1; continue; } fade_time = 1; if ( self.time < 10 ) fade_time = .5; if ( self.time < 5 ) fade_time = .25; self fadeOverTime( fade_time ); self.alpha = !self.alpha; wait( fade_time ); } } function remove_powerup_hud( powerup ) { self.powerup_hud[ powerup ] destroy(); self.powerup_hud[ powerup ] notify( "stop_fade" ); self.powerup_hud[ powerup ] fadeOverTime( .2 ); self.alpha = 0; wait .2; self.powerup_hud[ powerup ] delete(); self.powerup_hud[ powerup ] = undefined; self.powerup_hud = array::remove_index( self.powerup_hud, self.powerup_hud[ powerup ], true ); a_keys = GetArrayKeys( self.powerup_hud ); for ( i = 0; i < a_keys.size; i++ ) self.powerup_hud[ a_keys[i] ] thread move_hud( .5, 0 - ( 24 * ( self.powerup_hud.size ) ) + ( i * 37.5 ) + 25, self.powerup_hud[ a_keys[i] ].y ); }

 

in function __init__ add 

level.pyrotechnic_active = 0;

 

because if you do

if(level.pyrotechnic_active == 0)

 

when it's undefined it screws up

 

also the line

if( ToLower( GetDvarString( "g_gametype" ) ) != "pyrotechnic" )

is pointless

 


Don't PM me about stuff that should be on the forum.
My creations:
Debug (on/off)
Jukebox
Gum Anti-cheat
Kino box locator
Elemental Bows

Test search engine for this site via Google
Reply #18 on 1547405851
Modme User
1 wins

Yeah, the line is:

if( ToLower( GetDvarString( "g_gametype" ) ) != "zcleansed" )

My fault writing, work perfect now, thanks again, the unique thing i need buff is the score "i cant do points, shooting or knifing, with the powerup active" i dont know why, i need to do a callback to the player/zombie?