Raised This Month: $ Target: $400
 0% 

Clear owner of a entity Notworking


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
proffs
Senior Member
Join Date: Jul 2013
Old 03-11-2014 , 04:22   Clear owner of a entity Notworking
Reply With Quote #1

PHP Code:
public grenade_throwindexgreindexwId ) {
        if( 
wId != CSW_HEGRENADE ) {
            return 
PLUGIN_CONTINUE;
        }
        if( 
GAME_DGBALL <= g_iCurrentGame <= GAME_ZMBOMBS )
        {
        
        
// set some variables
        
entity_set_edict(greindex,EV_ENT_euser1,index); // remember the owner
        
set_task(0.3,"clearowner",greindex); // but clear it in a bit
        
entity_set_int(greindex,EV_INT_iuser1,0); // hit ground yet?
        
entity_set_int(greindex,EV_INT_iuser2,0); // still play bouncing sounds?
        
entity_set_size(greindex,Float:{-6.0,-6.0,-6.0},Float:{6.0,6.0,6.0}); // I like big balls and I cannot lie!
        
entity_set_float(greindex,EV_FL_friction,0.6);
        
        new 
random_num(1255)
        new 
random_num(1255)
        new 
random_num(1255)
        
        
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
        
write_byte(22)
        
write_short(greindex)
        
write_short(beamspr)
        
write_byte(10)
        
write_byte(10)
        
write_byte(r)
        
write_byte(g)
        
write_byte(b)
        
write_byte(100)
        
message_end()
        
        
set_rendering(greindex,kRenderFxGlowShellrgb)
        
        
//                    drop
        
set_task3.0,"remove_ball",greindex );
        }
        return 
PLUGIN_CONTINUE;
}

public 
clearowner(ent
{
    if(
is_valid_ent(ent)) {
        
entity_set_edict(ent,EV_ENT_owner,0);
    }
}

public 
remove_ballent ) {
    if( 
is_valid_entent ) ) {
        
        if( 
get_entity_flagsent ) & FL_ONGROUND) {
            
remove_entityent );
        }
        else {
            
remove_entity(ent)
        }
        
    }

When ever I add this code:
PHP Code:
set_task(0.3,"clearowner",greindex); // but clear it in a bit 
PHP Code:
public clearowner(ent
{
    if(
is_valid_ent(ent)) {
        
entity_set_edict(ent,EV_ENT_owner,0);
    }

The server crashes when a player walks on a ball, and when u throw the ball it keeps floating on the floor.

Here is the original code:
PHP Code:
// grenade is thrown
 
public grenade_throw(index,greindex,wId) {
    if(!
get_cvar_num("dodgeball_on") || wId != CSW_HEGRENADE) {
        return 
PLUGIN_CONTINUE;
    }

    
// set some variables
    
entity_set_edict(greindex,EV_ENT_euser1,index); // remember the owner
    
set_task(0.3,"clearowner",greindex); // but clear it in a bit
    
entity_set_int(greindex,EV_INT_iuser1,0); // hit ground yet?
    //entity_set_int(greindex,EV_INT_iuser2,0); // still play bouncing sounds?
    
entity_set_size(greindex,Float:{-6.0,-6.0,-6.0},Float:{6.0,6.0,6.0}); // I like big balls and I cannot lie!
    
entity_set_float(greindex,EV_FL_friction,0.6);

    new 
rb;
    switch(
get_user_team(index)) {
        case 
1255;
        default: 
255;
    }

    
// make a trail
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
    
write_byte(22); // TE_BEAMFOLLOW
    
write_short(greindex); // ball
    
write_short(beamspr); // laserbeam
    
write_byte(10); // life
    
write_byte(10); // width
    
write_byte(r); // R
    
write_byte(0); // G
    
write_byte(b); // B
    
write_byte(100); // brightness
    
message_end();

    
// make it glow (so we can tell if it is dead or not)
    
set_rendering(greindex,kRenderFxGlowShell,r,0,b);

    
//                    drop
    
set_task(ROLL_TIME,"stop_roll",greindex);

    return 
PLUGIN_CONTINUE;
 }

 
// clear grenade's owner so user can touch it
 
public clearowner(ent) {
    if(
is_valid_ent(ent)) {
        
entity_set_edict(ent,EV_ENT_owner,0);
    }
 }

 
// stop a grenade from rolling too much
 
public stop_roll(ent) {
    if(
is_valid_ent(ent)) {

        
// make sure we're on the ground, this stops balls from stopping midair
        
if(get_entity_flags(ent) & FL_ONGROUND) {
            
entity_set_vector(ent,EV_VEC_velocity,Float:{0.0,0.0,0.0});
            
entity_set_float(ent,EV_FL_gravity,1.0);
        }
        else {
            
set_task(ROLL_TIME,"stop_roll",ent); // check again shortly
        
}

    }
 } 

Last edited by proffs; 03-11-2014 at 04:22.
proffs 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 06:02.


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