Raised This Month: $ Target: $400
 0% 

Entity is touched = server crash


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 02-15-2015 , 07:38   Entity is touched = server crash
Reply With Quote #1

What is problem, why crashing without any errors?!
PHP Code:
#define TASK_EXPLODE 1111

#define EXPLOSION_MAX_DAMAGE 100
#define EXPLOSION_RANGE 300
#define EXPLOSION_BLAST_RADIUS 250

new toucher_owner;
new 
Float:g_origin[3];

// It's called when the entity is touched
public mine_explosion(touchertouched)
{
    
toucher_owner entity_get_edict(toucherEV_ENT_owner);
    
        
// Only crashing if this check is passed!
    
if(cs_get_user_team(touched) != cs_get_user_team(toucher_owner))
    {
        
entity_get_vector(toucherEV_VEC_origing_origin);
    
        
set_task(0.5"explode"toucher TASK_EXPLODE);
    
        
emit_sound(toucherCHAN_AUTO"ambience/particle_suck1.wav"VOL_NORMATTN_NORM0PITCH_NORM);
    }
}

public 
explode(toucher)
{    
    
toucher -= TASK_EXPLODE;
    
    new 
Float:position[3];
    
position[0] = g_origin[0] + random_float(-100.0100.0);
    
position[1] = g_origin[1] + random_float(-100.0100.0);
    
position[2] = g_origin[2] + random_float(-50.050.0);

    
te_explosion(Float:g_originFloat:positionzerogxplode, (random_num(0,20) + 20), 12TE_EXPLFLAG_NONE);
    
te_smoke(Float:g_originFloat:positionsteam16010);
        
    new 
players[32], numi;
    
get_players(playersnum"a");

    new 
targetFloat:target_origin[3], Float:distancedamage;
    new 
multiplier = (EXPLOSION_MAX_DAMAGE EXPLOSION_MAX_DAMAGE) / EXPLOSION_RANGE;
    
    for(
i=0i<numi++)
    {
        
target players[i];
        
        
entity_get_vector(targetEV_VEC_origintarget_origin);

        
distance get_distance_f(g_origintarget_origin);
        
        if(
distance EXPLOSION_RANGE && cs_get_user_team(toucher_owner) != cs_get_user_team(target))
        {
            
damage = (EXPLOSION_RANGE floatround(distance)) * multiplier;
            
damage sqroot(damage);
            
            
ExecuteHamB(Ham_TakeDamagetargettouchertoucherdamageDMG_ALWAYSGIB);
            
            
remove_entity(toucher);
        }
    }
}

stock te_explosion(Float:origin[3], Float:position[3], spritescaleframerateflags)
{
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYorigin);
    
write_byte(TE_EXPLOSION);
    
engfunc(EngFunc_WriteCoordposition[0]); // position.x
    
engfunc(EngFunc_WriteCoord ,position[1]); // position.y
    
engfunc(EngFunc_WriteCoordposition[2]); // position.z
    
write_short(sprite); // sprite index
    
write_byte(scale); // scale in 0.1's
    
write_byte(framerate); // framerate
    
write_byte(flags); // flags
    
message_end();
}

stock te_smoke(Float:origin[3], Float:position[3], spritescaleframerate)
{
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYorigin);
    
write_byte(TE_SMOKE);
    
engfunc(EngFunc_WriteCoordposition[0]); // position.x
    
engfunc(EngFunc_WriteCoord ,position[1]); // position.y
    
engfunc(EngFunc_WriteCoordposition[2]); // position.z
    
write_short(sprite); // sprite index
    
write_byte(scale); // scale in 0.1's
    
write_byte(framerate); // framerate
    
message_end();


Last edited by KiLLeR.; 02-15-2015 at 07:38.
KiLLeR. is offline
 



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 02:36.


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