AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help With this crash (https://forums.alliedmods.net/showthread.php?t=112774)

Doc-Holiday 12-21-2009 04:20

Help With this crash
 
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(clientuc_handleseed)
{    
    new 
button get_uc(uc_handleUC_Buttons);
    new 
oldbuttons pev(clientpev_oldbuttons);
    static 
targetbody;
    new 
Float:dist get_user_aiming(clienttargetbody);
    static 
FloatTime;
    
Time get_gametime();
    
    if ( !
g_being_healed[client])
    {
        if(
Is_Medic[client] && (button IN_USE) && !(oldbuttons IN_USE) && dist HEALING_DISTANCE )
        {
            if( (
<= 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(targetnamecharsmax(name));
                static 
name2[32] ; get_user_name(clientname2charsmax(name2));
                
                if ( 
health heal_min && CanBeHealed[target])
                {
                    
client_print(clientprint_center"Your target: %s"name);
                    
client_print(targetprint_center"You healer: %s"name2);
                    
emit_sound(targetCHAN_ITEMg_medkit_heal1.0ATTN_NORM0PITCH_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);
                    
_AddProgressclientHEAL_TIME);
                    
_AddProgresstargetHEAL_TIME);
                    
                    
g_LastHeal[client] = Time
                    
                
}
                else if(
health heal_min && CanBeHealed[target])
                {
                    
client_print(clientprint_center"Your target must be below %d health before you can heal them."heal_min);
                }
                if(!
CanBeHealed[target])
                {
                    
client_print(clientprint_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);
        
_AddProgressclientBAR_REMOVE);
        
        
_AddProgresstargetBAR_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);
        
        
_AddProgressclientBAR_REMOVE);
        
        
_AddProgresstargetBAR_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);
            
_AddProgressclientBAR_REMOVE);
            
            
_AddProgresstargetBAR_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);
            
_AddProgressclientBAR_REMOVE);
            
            
_AddProgresstargetBAR_REMOVE);
        } 



All times are GMT -4. The time now is 04:12.

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