AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Create entity failureS (https://forums.alliedmods.net/showthread.php?t=112927)

grimvh2 12-22-2009 06:40

Create entity failureS
 
I tried to create an entity when you press attack, so far any atempt failed,
The entity should be a ball, wich bounce a little and then stops

PHP Code:

new ball engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString,"info_target"));
 
set_pev(ballpev_classname"ball");
    
new 
Float:fOrigin[3];
pev(idpev_originfOrigin);
fOrigin[2] += 30.0;

//get_user_origin(id,origin,3) gives a runtime error 10 :s
    
new Float:fAngles[3];
pev(idpev_anglesfAngles);
    
engfunc(EngFunc_SetModelballballmodel);
    
set_pev(ballpev_anglesfAngles);
set_pev(ballpev_originfOrigin);
set_pev(ballpev_movetypeMOVETYPE_BOUNCE);
set_pev(ballpev_velocity500


Arkshine 12-22-2009 07:20

Re: Create entity failureS
 
set_pev(ball, pev_velocity, 500)

pev_velocity is a vector.

tuty 12-22-2009 08:04

Re: Create entity failureS
 
500.0 ?

Arkshine 12-22-2009 08:13

Re: Create entity failureS
 
VECTOR : { x, y, z }

To calculate the entity velocity, you need to know to scale the direction you want by a value.

What does exactly this entity ? It should spawn in front of you like if you throw a snow ball ?

grimvh2 12-22-2009 08:54

Re: Create entity failureS
 
Quote:

Originally Posted by Arkshine (Post 1026763)
VECTOR : { x, y, z }

To calculate the entity velocity, you need to know to scale the direction you want by a value.

What does exactly this entity ? It should spawn in front of you like if you throw a snow ball ?

Yea something like if you throw a snow ball

Arkshine 12-22-2009 11:01

Re: Create entity failureS
 
More like that ( I have not checked if it compiles, you get the idea ) :

Code:
new ball = create_entity( "info_target" );   if ( ball ) {     // Decompose the vector based on the player's view angle.         new Float:angles[3];     pev( id, pev_v_angle, angles );         engfunc( EngFunc_MakeVectors, angles );             // Calculate the eye position.         new Float:origin[3];     new Float:viewOfs[3];         pev( id, pev_origin, origin );     pev( id, pev_view_ofs, viewOfs );         xs_vec_add( origin, viewOfs, origin );             // Configure the entity.         set_pev( ball, pev_classname, "snowball" );     set_pev( ball, pev_angles, angles );     set_pev( ball, pev_origin, origin );     set_pev( ball, pev_owner, id );     set_pev( ball, pev_movetype, MOVETYPE_BOUNCE );         engfunc( EngFunc_SetModel, ball, ballmodel );         // Calculate the velocity by scaling the direction player aims with your value.         new Float:forward[3];     new Float:velocity[3];         pev( id, pev_velocity, velocity );     angle_vector( angles, ANGLEVECTOR_FORWARD, forward );         xs_vec_mul_scalar( forward, 500.0, forward );     xs_vec_add( forward, velocity, velocity );     set_pev( ball, pev_velocity, velocity ); }

grimvh2 12-23-2009 04:51

Re: Create entity failureS
 
PHP Code:

xs_vec_mul_scalarvelocity500.0Forwardvelocity ); 

to

PHP Code:

xs_vec_mul_scalarvelocity500.0Forward ); 

and forward to Forward.

Still not working, no errors in .log

Arkshine 12-23-2009 04:59

Re: Create entity failureS
 
I've edited a bit, forget to retrieve the player's velocity.

If still not working, attach the model. I will give you a full example.

grimvh2 12-23-2009 05:06

Re: Create entity failureS
 
Still nothing.

http://www.speedyshare.com/files/19936289/ttbball.mdl

(forum doesnt allow .mdl)

Arkshine 12-23-2009 05:09

Re: Create entity failureS
 
You forget the T model.


All times are GMT -4. The time now is 04:09.

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