Raised This Month: $ Target: $400
 0% 

set_task on Entity? (Tripmine)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 11-03-2015 , 01:59   set_task on Entity? (Tripmine)
Reply With Quote #1

Is it fine for me to use a set_task on Entity?
For now it works fine, but I just want to make sure it doesnt crash server or whatever: (Highlighted red)

Code:
public Func_Plant( iPlayer ) {
	iPlayer -= TASK_CREATE;
	
	g_iPlanting[ iPlayer ] = false;
	
	static Float: flOrigin[ 3 ];
	entity_get_vector( iPlayer, EV_VEC_origin, flOrigin );
	
	static Float: flTraceDirection[ 3 ], Float: flTraceEnd[ 3 ], Float: flTraceResult[ 3 ], Float: flNormal[ 3 ];
	velocity_by_aim( iPlayer, 128, flTraceDirection );
	flTraceEnd[ 0 ] = flTraceDirection[ 0 ] + flOrigin[ 0 ];
	flTraceEnd[ 1 ] = flTraceDirection[ 1 ] + flOrigin[ 1 ];
	flTraceEnd[ 2 ] = flTraceDirection[ 2 ] + flOrigin[ 2 ];
	
	static Float: flFraction, iTr;
	iTr = 0;
	engfunc( EngFunc_TraceLine, flOrigin, flTraceEnd, 0, iPlayer, iTr );
	get_tr2( iTr, TR_vecEndPos, flTraceResult );
	get_tr2( iTr, TR_vecPlaneNormal, flNormal );
	get_tr2( iTr, TR_flFraction, flFraction );
	
	static iEntity;
	iEntity = create_entity( "info_target" );
	
	if( !iEntity )
		return;
	
	entity_set_string( iEntity, EV_SZ_classname, MINE_CLASSNAME );
	entity_set_model( iEntity, MINE_MODEL_VIEW );
	entity_set_size( iEntity, Float: { -4.0, -4.0, -4.0 }, Float: { 4.0, 4.0, 4.0 } );
	
	entity_set_int( iEntity, EV_INT_iuser2, iPlayer );
	
	g_iPlantedMines[ iPlayer ]++;
	if (g_iMineIds[iPlayer][0]==0)
            g_iMineIds[iPlayer][0] = iEntity;
    	else
            g_iMineIds[iPlayer][1] = iEntity;
	
	entity_set_float( iEntity, EV_FL_frame, 0.0 );
	entity_set_float( iEntity, EV_FL_framerate, 0.0 );
	entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_FLY );
	entity_set_int( iEntity, EV_INT_solid, SOLID_NOT );
	entity_set_int( iEntity, EV_INT_body, 3 );
	entity_set_int( iEntity, EV_INT_sequence, 7 );
	entity_set_float( iEntity, EV_FL_takedamage, DAMAGE_NO );
	entity_set_int( iEntity, EV_INT_iuser1, MINE_OFF );
	
	static Float: flNewOrigin[ 3 ], Float: flEntAngles[ 3 ];
	flNewOrigin[ 0 ] = flTraceResult[ 0 ] + ( flNormal[ 0 ] * 8.0 );
	flNewOrigin[ 1 ] = flTraceResult[ 1 ] + ( flNormal[ 1 ] * 8.0 );
	flNewOrigin[ 2 ] = flTraceResult[ 2 ] + ( flNormal[ 2 ] * 8.0 );
	
	entity_set_origin( iEntity, flNewOrigin );
	
	vector_to_angle( flNormal, flEntAngles );
	entity_set_vector( iEntity, EV_VEC_angles, flEntAngles );
	flEntAngles[ 0 ] *= -1.0;
	flEntAngles[ 1 ] *= -1.0;
	flEntAngles[ 2 ] *= -1.0;
	entity_set_vector( iEntity, EV_VEC_v_angle, flEntAngles );
	
	g_iTripMines[ iPlayer ]--;
	
	emit_sound( iEntity, CHAN_WEAPON, MINE_SOUND_DEPLOY, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
	emit_sound( iEntity, CHAN_VOICE, MINE_SOUND_CHARGE, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
	set_task(2.5 , "MINE_ACTIVATED", iEntity);
	client_print_color(iPlayer, Grey, "^x04[ZP]^x01 Tripmine has been planted! You have^x04 %i tripmines^x01 left.", g_iTripMines[ iPlayer ])
	
	entity_set_float( iEntity, EV_FL_nextthink, get_gametime( ) + 0.6 );
}
Code:
public MINE_ACTIVATED(iEntity)
{
	if( !is_valid_ent( iEntity ) )
		return;

	entity_set_int( iEntity, EV_INT_iuser1, MINE_ON );
	entity_set_float( iEntity, EV_FL_takedamage, DAMAGE_YES );
	entity_set_int( iEntity, EV_INT_solid, SOLID_BBOX );
	entity_set_float( iEntity, EV_FL_health, MINE_HEALTH + 1000.0 );
			
	emit_sound( iEntity, CHAN_VOICE, MINE_SOUND_ACTIVATE, VOL_NORM, ATTN_NORM, 0, 75 );

	return;
}
Full code:
Spoiler

Last edited by Chihuahuax; 11-03-2015 at 02:00.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 11-03-2015 , 04:59   Re: set_task on Entity? (Tripmine)
Reply With Quote #2

Boleh. Tiada masalah. ;)

Yes. It is fine.

Last edited by zmd94; 11-03-2015 at 04:59.
zmd94 is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-03-2015 , 07:07   Re: set_task on Entity? (Tripmine)
Reply With Quote #3

remember to remove the task in case the mine is destroyed or something, or else it will crash
Depresie is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 11-03-2015 , 09:20   Re: set_task on Entity? (Tripmine)
Reply With Quote #4

Quote:
Originally Posted by Depresie View Post
remember to remove the task in case the mine is destroyed or something, or else it will crash
No it cant be destroyed before the task completes (DAMAGE_NO)

Something=?

BTW: What is your relationship with hakken lol

Last edited by Chihuahuax; 11-03-2015 at 09:30.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 11-03-2015 , 10:38   Re: set_task on Entity? (Tripmine)
Reply With Quote #5

No need to remove task.
zmd94 is offline
Old 11-03-2015, 10:43
SkumTomteN
This message has been deleted by SkumTomteN. Reason: nvm
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 11-03-2015 , 10:44   Re: set_task on Entity? (Tripmine)
Reply With Quote #7

Never seen this code, thanks
__________________
Contact: Steam
Videos: Youtube
SkumTomteN is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 11-03-2015 , 11:14   Re: set_task on Entity? (Tripmine)
Reply With Quote #8

Quote:
Originally Posted by SkumTomteN View Post
Never seen this code, thanks
[offtopic]Thanks for what?[/offtopic]

Quote:
Originally Posted by zmd94 View Post
No need to remove task.
Great

Last edited by Chihuahuax; 11-03-2015 at 11:15.
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 11-03-2015 , 11:16   Re: set_task on Entity? (Tripmine)
Reply With Quote #9

Quote:
Originally Posted by Chihuahuax View Post
[offtopic]Thanks for what?[/offtopic]
For the code. Alot of work to be done, but it shouldnt be a problem
__________________
Contact: Steam
Videos: Youtube
SkumTomteN is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 11-03-2015 , 18:11   Re: set_task on Entity? (Tripmine)
Reply With Quote #10

Quote:
Originally Posted by SkumTomteN View Post
For the code. Alot of work to be done, but it shouldnt be a problem
lol i dont get you

If you're sayin that this plugin is incomplete, ...*I got it from here
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
Reply


Thread Tools
Display Modes

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 18:12.


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