AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   _BBOX crashes server (https://forums.alliedmods.net/showthread.php?t=277704)

DavidLin 01-14-2016 11:32

_BBOX crashes server
 
When entity is tossed up ( above player ) the server crashes without any errors, when I changed entity solid type to _TRIGGER it works fine but I can't pick it up or do damage to it.

PHP Code:

public throwstickid ) {
        new 
Float:Origin], Float:Velocity], Float:Angles], Float:FAngles];
        
entity_get_vectoridEV_VEC_originOrigin );
        
velocity_by_aimid64Angles )
        
vector_to_angleAnglesFAngles );

        
FAngles] = 0.0;
        
Origin] += Angles];
        
Origin] += Angles];
        
Origin] += Angles];

        new 
entity_stick create_entity"info_target" );
        
entity_set_stringentity_stickEV_SZ_classnameentity_name );
        
entity_set_vectorentity_stickEV_VEC_anglesFAngles );
        
entity_set_intentity_stickEV_INT_solidSOLID_BBOX );
        
entity_set_intentity_stickEV_INT_movetypeMOVETYPE_TOSS );
        
entity_set_originentity_stickOrigin );
        
entity_set_modelentity_stickgModel );
        
entity_set_sizeentity_stickminModelmaxModel );
        
entity_set_floatentity_stickEV_FL_takedamage1.0 );
        
entity_set_floatentity_stickEV_FL_gravity0.8 ); 
        
entity_set_floatentity_stickEV_FL_healthget_pcvar_floatstick_health ) );
        
set_peventity_stickpev_iuser2id );

        
entity_set_intentity_stickEV_INT_renderfxkRenderFxGlowShell );
        
entity_set_vectorentity_stickEV_VEC_rendercolorFloat:{ 221.0173.0237.0 } );

        
velocity_by_aimid600Velocity );
        
entity_set_vectorentity_stickEV_VEC_velocityVelocity );
        
has_stickid ] = false;



DavidLin 01-14-2016 13:04

Re: _BBOX crashes server
 
So I discovered if an entity was thrown above it takes damage when it falls and this crashes server because of fall damage, is it possible to disable fall damage for an entity ?

EDIT: it crashes from knife kill too :D

Hunter4all 05-27-2016 02:38

Re: _BBOX crashes server
 
ok so i have the same problem too..

Server crashes when an entity is killed with a knife.
but with any other weapons it doesnt crash.
Can someone explain me why ?

Whitez 05-27-2016 17:17

Re: _BBOX crashes server
 
Register TakeDamage and check for entity class name
The code to disable damage from falling can be found somewhere around the forum

SpannerSpammer 05-28-2016 11:37

Re: _BBOX crashes server
 
The problem when you create a custom entity in goldsrc and enable takedamage is
that the engine will automatically kill the entity when it's health is less than zero.

You DO NOT want this to happen, you want to fully control when your
custom entity gets removed. To do this you need to set a health mask with
a high enough value that no weapon/explosive in-game can easily destroy it.

Code:

#define HEALTH_MASK  1000000.0
.
.
entity_set_float( entity_stick, EV_FL_health, HEALTH_MASK );

Then, check the health in some function, usually it's think function or a hooked
Takedamage function and then evaluate whether or not you need to kill the entity.
If you do, then perform whatever code cleanup required and then kill the entity.

Code:

public StickThink( ent )
{
    static Float:flHealth;
    flHealth = get_pcvar_float( stick_health );
    if ( flHealth < 1.0 ) flHealth = 1.0;      // idiot proof your HP value
    if ( flHealth > 500.0 ) flHealth = 500.0;

    if ( entity_get_float( ent, EV_FL_health ) <= (HEALTH_MASK - flHealth) )
    {
        // do any code cleanup here
        //
        // new id = entity_get_int( ent, EV_INT_iuser2 );
        // if ( SomeIsValidPlayerIDFunction(id) ) 
        //        client_print( id, print_chat, "Your stick was destroyed" );

        remove_entity( ent );
        return PLUGIN_CONTINUE;
    }
    .
    .
    .
    return PLUGIN_CONTINUE;
}

One last thing: If you use CVARs or load settings from a configuration file, don't
plug these values directly into your code. You need to idiot proof these values
before plugging them in, because an invalid setting can sometimes have unpredictable
results, like crashing the server.


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

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