ok so I have tried some of what was above and the error still persists. Even though some of the code is redundant and not "optimized" I would like to get it working before I worry about the optimization portion.
I have also set the function as a task instead of a direct call, and removed the delcared parm[2] from the function params.
Here is what I got now - I know there are still some redundancies, but thats ok for now. I would like to focus on what is completely wrong. I'm trying to port in some existing code from the original uwc3 mod plugin and this is the only part that is giving me trouble.
PHP Code:
public Ult_Entangle ( id )
{
if ( !Ult_Can_Use ( id, SKILLIDX_ENTANGLE ) )
{
return PLUGIN_HANDLED;
}
if ( is_user_alive ( id ) && Util_Is_Valid_Player( id ) && !issearching[id] && !ultimateused[id] )
{
new parm[2];
parm[0] = id;
parm[1] = ULTIMATESEARCHTIME;
set_task ( 0.1, "Task_Search_Event_Entangle", TASK_ULTIMATE_ENTANGLE_SEARCH + id, parm, 2 );
//Task_Search_Event_Entangle ( parm ); //Set_Task instead
}
return PLUGIN_CONTINUE;
}
PHP Code:
public Task_Search_Event_Entangle ( parm[] )
{
new iparm[2], waitparm[6];
new enemyz, body, counter;
new tmp_immunity = 0, id = parm[0];
if ( !Util_Is_Valid_Player( id ) )
{
issearching[id] = true;
icon_controller ( id );
return PLUGIN_CONTINUE;
}
get_user_aiming ( id, enemyz, body );
if ( !Util_Is_Valid_Player( enemyz ) )
{
issearching[id] = true;
icon_controller ( id );
return PLUGIN_CONTINUE;
}
if( temp_immunity[enemyz] || playeritem[enemyz]==IMMUNITY || hasblink[enemyz] )
{
tmp_immunity = 1;
}
if ( Util_NotSame_Team( id, enemyz ) && ( tmp_immunity || magic_saving_throw ( enemyz ) ) )
{
temp_immunity[enemyz] = true;
tmp_immunity = 1;
if ( Util_Should_Msg_Client( enemyz ) )
{
client_print ( enemyz, print_chat, "%L", enemyz, "ULTIMATE_ENGANGLE_RESISTANT", MOD );
}
iparm[0] = enemyz;
copy( iparm[1], 31, "Entangling roots" );
set_task ( 5.0, "Task_Reset_Immunity", TASK_RESET_IMMUNITY + id, iparm, 2 );
}
if ( !stunned[enemyz] && Util_NotSame_Team( id, enemyz ) && !tmp_immunity )
{
issearching[id] = false;
ultimateused[id] = true;
icon_controller ( id );
if ( Util_Should_Msg_Client( id ) )
{
if ( file_exists ( "sound/warcraft3/entanglingrootstarget1.wav" ) == 1 )
{
emit_sound ( id, CHAN_ITEM, "warcraft3/entanglingrootstarget1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
}
else
{
if ( file_exists ( "sound/weapons/cbar_hitbod3.wav" ) == 1 )
{
emit_sound ( id,CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
}
}
}
waitparm[0] = enemyz;
waitparm[1] = 100;
waitparm[5] = floatround ( get_user_maxspeed ( enemyz ) );
set_user_maxspeed ( enemyz,1.0 );
Task_Entangle_Stop ( waitparm );
stunned[enemyz] = true;
new cooldownparm[1];
cooldownparm[0] = id;
set_task ( CVAR_ENTANGLE_COOLDOWN, "cooldown", 50 + id, cooldownparm, 1 );
}
else
{
issearching[id] = true;
icon_controller ( id );
counter = parm[1];
while ( counter >= 0 )
{
counter -= 10;
if ( counter == 0 )
{
if( Util_Should_Msg_Client( id ) )
{
emit_sound ( id, CHAN_ITEM, "turret/tu_ping.wav", 1.0, ATTN_NORM, 0, PITCH_NORM );
}
}
}
--parm[1];
if ( parm[1]>0 && get_user_health ( id ) > 0 )
{
set_task ( 0.1, "Task_Search_Event_Entangle", TASK_ULTIMATE_ENTANGLE_SEARCH + id, parm, 2 );
}
else
{
issearching[id] = false;
icon_controller ( id );
}
}
return PLUGIN_CONTINUE;
PHP Code:
public Util_Is_Valid_Player( id )
{
if( 0 == id || id > MAX_PLAYERS )
{
return false;
}
if( is_user_connected( id ) && ( pev( id, pev_flags ) & FL_CLIENT ) )
{
return true;
}
return false;
}
public Util_Should_Msg_Client( id )
{
if( Util_Is_Valid_Player(id) && !is_user_bot( id ) )
{
return true;
}
return false;
}
public Util_IsSame_Team ( PlayerID, TargetID )
{
new bool:IsValidTeam = false;
if ( get_user_team ( PlayerID ) == get_user_team ( TargetID ) && !Util_Player_Is_Spec ( PlayerID ) && !Util_Player_Is_Spec ( TargetID ) )
{
IsValidTeam = true;
}
return IsValidTeam;
}
public Util_NotSame_Team ( PlayerID, TargetID )
{
new bool:IsValidTeam = false;
if ( get_user_team ( PlayerID ) != get_user_team ( TargetID ) && !Util_Player_Is_Spec ( PlayerID ) && !Util_Player_Is_Spec ( TargetID ) )
{
IsValidTeam = true;
}
return IsValidTeam;
}
Maybe I just need another set of eyes..... Thanks in advance.
__________________