Raised This Month: $ Target: $400
 0% 

Sometimes it throws sometimes not!!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HENNESSY
Member
Join Date: Sep 2013
Location: Russian Federation, Bela
Old 10-11-2014 , 20:15   Sometimes it throws sometimes not!!
Reply With Quote #1

I'm using the throw knife entity code from throwing knives plugin.

the problem is when i type /throw, sometimes it throw's a knife and sometimes no.

Why is that?

This is the code:

PHP Code:
public ThrowKnifeiIndex )
{
    static 
Float:flOrigin], Float:flVelocity], Float:flAngles], iEnt;
    
    
entity_get_vectoriIndexEV_VEC_originflOrigin );
    
entity_get_vectoriIndexEV_VEC_v_angleflAngles );
    
    
iEnt create_entity"info_target" );
    
    if( !
is_valid_entiEnt ) )
    {
        return;
    }
        
    
entity_set_stringiEntEV_SZ_classnameKNIFE_ENT );
    
entity_set_modeliEntKNIFE_MODEL );
        
    
entity_set_sizeiEntFloat:{ -1.0, -7.0, -1.0 }, Float:{ 1.07.01.0 } );
    
entity_set_originiEntflOrigin );
    
    
flAngles] -= 90.0;
    
entity_set_vectoriEntEV_VEC_anglesflAngles );
    
    
entity_set_intiEntEV_INT_effects32 );
    
entity_set_intiEntEV_INT_solidSOLID_TRIGGER );
    
entity_set_intiEntEV_INT_movetypeMOVETYPE_TOSS );
    
    
entity_set_edictiEntEV_ENT_owneriIndex );
    
    
set_renderingiEntkRenderFxGlowShell02500kRenderNormal25 );
    
    
VelocityByAimiIndexKNIFE_SPEEDflVelocity );
    
entity_set_vectoriEntEV_VEC_velocityflVelocity );

In the touch forward i just removed the entity with remove_entity( iEntity );

Thanks for help!
HENNESSY is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-12-2014 , 02:46   Re: Sometimes it throws sometimes not!!
Reply With Quote #2

Show us the full code. I can think only that you are trying to drop too fast or whatever and the entity is somehow not valid at this point. I can't see something wrong.
Code:
iEnt = create_entity( "info_target" );           if( !is_valid_ent( iEnt ) )     {         return;     }

Your code basically create another entity, set to it the knife model, set a size so it will be solid and you can touch it, and then set a velocity on this entity. The entity is not created or the velocity is not set ?
__________________

Last edited by HamletEagle; 10-12-2014 at 02:47.
HamletEagle is offline
HENNESSY
Member
Join Date: Sep 2013
Location: Russian Federation, Bela
Old 10-12-2014 , 06:32   Re: Sometimes it throws sometimes not!!
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Show us the full code. I can think only that you are trying to drop too fast or whatever and the entity is somehow not valid at this point. I can't see something wrong.
Code:
iEnt = create_entity( "info_target" );           if( !is_valid_ent( iEnt ) )     {         return;     }

Your code basically create another entity, set to it the knife model, set a size so it will be solid and you can touch it, and then set a velocity on this entity. The entity is not created or the velocity is not set ?
i checked that out by adding some debug messages to the code.

the result is that the entity is created successfully tough the knife isn't thrown.
HENNESSY is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-12-2014 , 07:00   Re: Sometimes it throws sometimes not!!
Reply With Quote #4

Again, give us the full code or a simple one that has the same problem.
__________________

Last edited by HamletEagle; 10-12-2014 at 07:00.
HamletEagle is offline
HENNESSY
Member
Join Date: Sep 2013
Location: Russian Federation, Bela
Old 10-12-2014 , 07:33   Re: Sometimes it throws sometimes not!!
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
Again, give us the full code or a simple one that has the same problem.
Here you go

PHP Code:
public UpdateClientData_Postidsendweaponscd_handle )
{
    if ( !
is_user_alive(id) )
    return 
FMRES_IGNORED;
    
    if( 
get_user_weaponid ) != CSW_KNIFE )
        return 
FMRES_IGNORED;

    
set_cd(cd_handleCD_flNextAttackget_gametime( ) + 0.1 );
    
    return 
FMRES_HANDLED;
}

public 
fwd_CmdStart(iduc_handleseed)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED
        
    
if( get_user_weaponid ) != CSW_KNIFE )
        return 
FMRES_IGNORED;
    
    static 
iButton;
    
iButton get_ucuc_handleUC_Buttons );
    
    if( 
iButton IN_ATTACK )
    {
        
set_ucuc_handleUC_ButtonsiButton & ~IN_ATTACK );
        
        if( !
g_bRoundStarted )
            return 
FMRES_HANDLED;
        
        
ThrowKnifeid );
    }
    
    if( 
iButton IN_ATTACK2 )
    {
        
set_ucuc_handleUC_ButtonsiButton & ~IN_ATTACK2 );
    }
    
    return 
FMRES_HANDLED
}

public 
ThrowKnifeiIndex )
{
    new 
Float:flGametime;
    
flGametime get_gametime( );
    
    if( 
g_flDelayiIndex ] > flGametime KNIFE_DELAY )
        return;
        
    
g_flDelayiIndex ] = flGametime;
    
    new 
Float:flOrigin], Float:flVelocity], Float:flAngles], iEnt;
    
    
entity_get_vectoriIndexEV_VEC_originflOrigin );
    
entity_get_vectoriIndexEV_VEC_v_angleflAngles );
    
    
iEnt create_entity"info_target" );
    
    if( !
iEnt )
    {
        
log_amx"ERROR: Entity isn't valid(%d)!"iEnt );
        return;
    }
        
    
entity_set_stringiEntEV_SZ_classnameKNIFE_ENT );
    
entity_set_modeliEntKNIFE_MODEL );
        
    new 
Float:MinBox] = { -1.0, -7.0, -1.0 };
    new 
Float:MaxBox] = { 1.07.01.0 };
        
    
entity_set_sizeiEntMinBoxMaxBox );
    
    
flAngles] -= 90.0;
    
    
entity_set_originiEntflOrigin );
    
entity_set_vectoriEntEV_VEC_anglesflAngles );
    
    
entity_set_intiEntEV_INT_effects);
    
entity_set_intiEntEV_INT_solid);
    
entity_set_intiEntEV_INT_movetype);
    
    
entity_set_edictiEntEV_ENT_owneriIndex );
    
    
set_renderingiEntkRenderFxGlowShell02500kRenderNormal25 );
    
    
VelocityByAimiIndexKNIFE_SPEEDflVelocity );
    
entity_set_vectoriEntEV_VEC_velocityflVelocity );

HENNESSY 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 17:44.


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