PHP Code:
public grenade_throw( index, greindex, wId ) {
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 r = random_num(1, 255)
new g = random_num(1, 255)
new b = random_num(1, 255)
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,kRenderFxGlowShell, r, g, b)
// drop
set_task( 3.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_ball( ent ) {
if( is_valid_ent( ent ) ) {
if( get_entity_flags( ent ) & FL_ONGROUND) {
remove_entity( ent );
}
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 r, b;
switch(get_user_team(index)) {
case 1: r = 255;
default: b = 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
}
}
}