Raised This Month: $ Target: $400
 0% 

Velocity and DLLFunc_Spawn, creating entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-01-2009 , 09:06   Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #1

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)


__________________
xbatista is offline
Send a message via Skype™ to xbatista
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 10-01-2009 , 10:13   Re: Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #2

Since you're already using Engine, use DispatchSpawn() to spawn entity.
__________________
hleV is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-01-2009 , 12:27   Re: Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #3

That doesn't correct my bug :/
__________________
xbatista is offline
Send a message via Skype™ to xbatista
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-01-2009 , 12:39   Re: Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #4

MOVETYPE_BOUNCE
__________________
xPaw is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-01-2009 , 12:44   Re: Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #5

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.
__________________
xbatista is offline
Send a message via Skype™ to xbatista
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-01-2009 , 13:11   Re: Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #6

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.
__________________
xPaw is offline
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 10-01-2009 , 13:16   Re: Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #7

Quote:
set the movetype, solid after spawning ent.
Wohoo solves the problem, thanks , btw from where the hell I can know this?
__________________
xbatista is offline
Send a message via Skype™ to xbatista
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-01-2009 , 13:23   Re: Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #8

hlsdk
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-01-2009 , 13:54   Re: Velocity and DLLFunc_Spawn, creating entity
Reply With Quote #9

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.
__________________
Arkshine is offline
Reply



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 22:41.


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