For some reason it crashes when the target of the healer strafe from left or right
How ever straight back it doesn't crash at all. The code for the healing is below
PHP Code:
public FwdCmdStart(client, uc_handle, seed)
{
new button = get_uc(uc_handle, UC_Buttons);
new oldbuttons = pev(client, pev_oldbuttons);
static target, body;
new Float:dist = get_user_aiming(client, target, body);
static Float: Time;
Time = get_gametime();
if ( !g_being_healed[client])
{
if(Is_Medic[client] && (button & IN_USE) && !(oldbuttons & IN_USE) && dist < HEALING_DISTANCE )
{
if( (1 <= target <= g_iMaxPlayers) && is_user_alive(target) && !g_being_healed[target] && !g_healing[target] && Time - MEDIC_HEAL_COOLDOWN > g_LastHeal[client] && get_user_team(client) == get_user_team(target) )
{
new health = get_user_health(target);
new heal_min = get_pcvar_num(mhm);
static name[32] ; get_user_name(target, name, charsmax(name));
static name2[32] ; get_user_name(client, name2, charsmax(name2));
if ( health < heal_min && CanBeHealed[target])
{
client_print(client, print_center, "Your target: %s", name);
client_print(target, print_center, "You healer: %s", name2);
emit_sound(target, CHAN_ITEM, g_medkit_heal, 1.0, ATTN_NORM, 0, PITCH_NORM);
g_healing_teammate[client] = true
g_healing[client] = true;
g_target[client] = target;
g_being_healed[target] = true;
set_task(float(HEAL_TIME), "TaskFinishHeal", client);
_AddProgress( client, HEAL_TIME);
_AddProgress( target, HEAL_TIME);
g_LastHeal[client] = Time
}
else if(health > heal_min && CanBeHealed[target])
{
client_print(client, print_center, "Your target must be below %d health before you can heal them.", heal_min);
}
if(!CanBeHealed[target])
{
client_print(client, print_center, "Your target must first call for you, before you may heal them.");
}
}
}
}
else if(g_healing[client] && !(button & IN_USE) && (oldbuttons & IN_USE))
{
new targeti = g_target[client];
g_healing[client] = false;
g_being_healed[targeti] = false;
remove_task(client);
_AddProgress( client, BAR_REMOVE);
_AddProgress( target, BAR_REMOVE);
}
if ( g_healing[client] && dist > HEALING_DISTANCE )
{
new targeti = g_target[client];
g_healing[client] = false;
g_being_healed[targeti] = false;
remove_task(client);
_AddProgress( client, BAR_REMOVE);
_AddProgress( target, BAR_REMOVE);
}
if(g_healing[client] || g_being_healed[target])
{
if ( (button & IN_JUMP) || (button & IN_DUCK) || (button & IN_FORWARD) || (button & IN_BACK) ||
(button & IN_MOVELEFT) || (button & IN_MOVERIGHT) || (button & IN_ATTACK) || (button & IN_ATTACK2))
{
new targeti = g_target[client];
g_healing[client] = false;
g_being_healed[targeti] = false;
remove_task(client);
_AddProgress( client, BAR_REMOVE);
_AddProgress( target, BAR_REMOVE);
}
return FMRES_IGNORED;
}
Edit: I believe it has to do with the set_task not being removed....
Dont know how to do that i have tried plenty of things... the last if statment i tried doing it
This is my newest attempt at fixing it.
PHP Code:
if(g_healing[client] || g_being_healed[target])
{
if ( (button & IN_JUMP) || (button & IN_DUCK) || (button & IN_FORWARD) || (button & IN_BACK) ||
(button & IN_MOVELEFT) || (button & IN_MOVERIGHT) || (button & IN_ATTACK) || (button & IN_ATTACK2))
{
new targeti = g_target[client];
g_healing[client] = false;
g_being_healed[targeti] = false;
remove_task(client);
_AddProgress( client, BAR_REMOVE);
_AddProgress( target, BAR_REMOVE);
}