AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Velocity and DLLFunc_Spawn, creating entity (https://forums.alliedmods.net/showthread.php?t=105109)

xbatista 10-01-2009 09:06

Velocity and DLLFunc_Spawn, creating entity
 
dllfunc( DLLFunc_Spawn, sprite_ent ) and setting Velocity cause a bug in server, the entity is thrown from player to aim direction and when I don't use dllfunc( DLLFunc_Spawn, sprite_ent ) , it throws normally as it must.
So why it is buggy with setting Velocity?
It something like it goes only 1/4 of his direction and just stops...


PHP Code:

public Set_Sprite_Player(id, const sprite[])
{
    new 
sprite_ent create_entity("env_sprite")

    
entity_set_stringsprite_entEV_SZ_classname"FireShit")
    
entity_set_modelsprite_entsprite);

    
entity_set_edictsprite_entEV_ENT_ownerid)

    
entity_set_intsprite_entEV_INT_movetypeMOVETYPE_FLY)
    
set_pevsprite_entpev_solidSOLID_BBOX)

    
set_pevsprite_entpev_minsFloat:{-1.0,-1.0,-1.0})
    
set_pevsprite_entpev_maxsFloat:{1.0,1.0,1.0})

    
set_pevsprite_entpev_rendermodekRenderTransAdd )
    
set_pevsprite_entpev_renderamt200.0 )
    
    
set_pevsprite_entpev_framerate22.0 )
    
set_pevsprite_entpev_scale1.0 )

    
dllfuncDLLFunc_Spawnsprite_ent )
    
set_pevsprite_entpev_spawnflagsSF_SPRITE_STARTON )

    new 
Float:fAim[3],Float:fAngles[3],Float:fOrigin[3]
    
velocity_by_aim(id,64,fAim)
    
vector_to_angle(fAim,fAngles)
    
pev(id,pev_origin,fOrigin)
    
    
fOrigin[0] += fAim[0]
    
fOrigin[1] += fAim[1]
    
fOrigin[2] += fAim[2]
    
    
set_pevsprite_ent,pev_origin,fOrigin)
    
set_pevsprite_ent,pev_angles,fAngles)
    
    new 
Float:fVel[3]
    
velocity_by_aim(id1000,fVel)    
    
set_pevsprite_ent,pev_velocity,fVel)




hleV 10-01-2009 10:13

Re: Velocity and DLLFunc_Spawn, creating entity
 
Since you're already using Engine, use DispatchSpawn() to spawn entity.

xbatista 10-01-2009 12:27

Re: Velocity and DLLFunc_Spawn, creating entity
 
That doesn't correct my bug :/

xPaw 10-01-2009 12:39

Re: Velocity and DLLFunc_Spawn, creating entity
 
MOVETYPE_BOUNCE

xbatista 10-01-2009 12:44

Re: Velocity and DLLFunc_Spawn, creating entity
 
I don't need bounce and it not solved my problem, look at the code.
When DispatchSpawn(sprite_ent); after
PHP Code:

    new Float:fAim[3],Float:fAngles[3],Float:fOrigin[3]
    
velocity_by_aim(id,64,fAim)
    
vector_to_angle(fAim,fAngles)
    
pev(id,pev_origin,fOrigin)
    
    
fOrigin[0] += fAim[0]
    
fOrigin[1] += fAim[1]
    
fOrigin[2] += fAim[2]
    
    
set_pevsprite_ent,pev_origin,fOrigin)
    
set_pevsprite_ent,pev_angles,fAngles)
    
    new 
Float:fVel[3]
    
velocity_by_aim(id1000,fVel)    
    
set_pevsprite_ent,pev_velocity,fVel

Entity flyies to half and stops...
When DispatchSpawn(sprite_ent); before
PHP Code:

    new Float:fAim[3],Float:fAngles[3],Float:fOrigin[3]
    
velocity_by_aim(id,64,fAim)
    
vector_to_angle(fAim,fAngles)
    
pev(id,pev_origin,fOrigin)
    
    
fOrigin[0] += fAim[0]
    
fOrigin[1] += fAim[1]
    
fOrigin[2] += fAim[2]
    
    
set_pevsprite_ent,pev_origin,fOrigin)
    
set_pevsprite_ent,pev_angles,fAngles)
    
    new 
Float:fVel[3]
    
velocity_by_aim(id1000,fVel)    
    
set_pevsprite_ent,pev_velocity,fVel

I Don't see an sprite model entity, it's invisible.

When I delete DispatchSpawn(sprite_ent); , all works, but no ANIMATION of sprite playing.

xPaw 10-01-2009 13:11

Re: Velocity and DLLFunc_Spawn, creating entity
 
PHP Code:

void CSprite::Spawnvoid )
{
    
pev->solid            SOLID_NOT;
    
pev->movetype        MOVETYPE_NONE;
    
pev->effects        0;
    
pev->frame            0;
    
    
// ....


That's your problem. set the movetype, solid after spawning ent.

xbatista 10-01-2009 13:16

Re: Velocity and DLLFunc_Spawn, creating entity
 
Quote:

set the movetype, solid after spawning ent.
Wohoo solves the problem, thanks , btw from where the hell I can know this?

xPaw 10-01-2009 13:23

Re: Velocity and DLLFunc_Spawn, creating entity
 
hlsdk

Arkshine 10-01-2009 13:54

Re: Velocity and DLLFunc_Spawn, creating entity
 
http://svn.tcwonline.org/viewvc.cgi/...p&root=amxmodx

Code:
void CSprite::Spawn( void ) {     pev->solid          = SOLID_NOT;     pev->movetype       = MOVETYPE_NONE;     pev->effects        = 0;     pev->frame          = 0;     Precache();     SET_MODEL( ENT(pev), STRING(pev->model) );     m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1;     if ( pev->targetname && !(pev->spawnflags & SF_SPRITE_STARTON) )         TurnOff();     else         TurnOn();         // Worldcraft only sets y rotation, copy to Z     if ( pev->angles.y != 0 && pev->angles.z == 0 )     {         pev->angles.z = pev->angles.y;         pev->angles.y = 0;     } }

It's very useful so see how en entity is handle ; so you can adapt your code. Download the HLSDK.


All times are GMT -4. The time now is 22:41.

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