First of all you might wanna clean up your code.
!is_user_connected( enemyz ) is a redundant check as get_user_aiming() returns data only from alive players.
Code:
get_user_aiming ( id,enemyz, body );
if ( ( get_user_team ( enemyz ) == SPEC ) || !is_user_connected( enemyz ) )
{
icon_controller ( id );
return PLUGIN_CONTINUE;
}
This implies that futher checks to enemyz are also redundant. To test if enemyz hold a valid player id you should add enemyz = 0 before calling get_user_aiming(). Further testing will be done by if( enemyz ).
Also redundant
Code:
if ( !p_resists[enemyz][RESISTIDX_MAGIC])
{
p_resists[enemyz][RESISTIDX_MAGIC] = 0;
}
I can't see the purpose of the format() call. Please note that iparm is declared as new iparm[2]; - format() goes out of bounds there.
Code:
iparm[0] = enemyz;
format( iparm[1], 31, "%s", "Entangling roots" );
This can be changed in regard to what I've said above.
Code:
if ( 0<enemyz<=32 && !stunned[enemyz] && get_user_team ( id )!=get_user_team ( enemyz ) && playeritem[enemyz]!=IMMUNITY && !hasblink[enemyz] && is_user_alive ( id ) && is_user_alive ( enemyz ) && !temp_immunity[enemyz] )
Extra param cooldownparm not needed here as id is part of the taskid. In your task simply do a id = taskid - 50;
Code:
set_task ( CVAR_ENTANGLE_COOLDOWN, "cooldown", 50 + id, cooldownparm, 1 );
If you want to emit_sound() if counter is a multiple of 10 you can do if( !(counter % 10) ). This is redundant
Code:
while ( counter >= 0 )
{
counter -= 10;
if ( counter == 0 )
{
emit_sound ( id, CHAN_ITEM, "turret/tu_ping.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
}
}
Another thig is this
Code:
set_task ( 0.1, "Task_Search_Event_Entangle", TASK_ULTIMATE_ENTANGLE_SEARCH + id, parm, 2 );
but Task_Search_Event_Entangle() is declared as
Code:
public Task_Search_Event_Entangle ( parm[2] )
Your firs call to Task_Search_Event_Entangle() acts like a "normal" function call but the second call requires that Task_Search_Event_Entangle() is a task with extra param. You should add a taskid in the declaration and work your way with that. You can build your taskid same way you did with the "cooldown()" task.
Please review your code as you have lots of redundant tests. While this shouldn't be a problem, in your case it's just a code overhead, not to mention that your task is recursive with a 0.1 seconds delay.