KillTimer will nicht

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Hallo,


    der Titel sagt bereits alles. Der Timer wird trotz KillTimer nicht gekillt und ich hab nicht die leiseste Ahnung wieso. Da ich das ganze immer alleine gestetet habe, beziehe ich mich auf die letzte if-Abfrage, also ob a kleiner gleich 0 ist. Wenns da aber schon fehlschlägt, dann wohl in der ganzen Funktion.


    //Globale Variable
    new Downstate_Timer[MAX_PLAYERS];


    //Unter OnPlayerSpawn
    Downstate_Timer[playerid] = SetTimerEx("DownstateTimer", 250, true, "i", playerid);


    //Timer Funktion
    forward DownstateTimer(playerid);
    public DownstateTimer(playerid)
    {
    Downstate_Counter[playerid]++;
    if(Downstate_Counter[playerid] == 4)
    {
    Downstate_Counter[playerid] = 0;

    new Float:a;
    GetPlayerArmour(playerid, a);
    if(0.0 < a < 100.0)
    {
    SetPlayerArmour(playerid, a - 1.0);
    }
    if(a == 100.0)
    {
    KillTimer(Downstate_Timer[playerid]);
    Condition[playerid] = CONDITION_ALIVE;
    Downstate_Counter[playerid] = 0;
    ClearAnimations(playerid);
    SetPlayerHealth(playerid, 30);
    SetPlayerArmour(playerid, 0);
    //TO DO: Hide all textdraws from the downstate
    }
    if(a <= 0.0)
    {
    KillTimer(Downstate_Timer[playerid]);
    Condition[playerid] = CONDITION_DEAD;
    Downstate_Counter[playerid] = 0;
    ApplyAnimation(playerid, "CRACK", "crckdeth1", 4.1, false, true, true, true, 24*60000, true);
    //TO DO: Offer Respawn Hotkey
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][0]); //Downstate
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][1]); //WeaponCoverBox
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][2]); //Infobox
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][3]); //HealthCoverBox
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][4]); //Indicator arrow
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][5]); //Stop the bleeding
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][6]); //Cry for help
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][7]); //Last strength
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][8]); //Medicine
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][9]); //Up and down arrow of main circle
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][10]); //Left and right arrow of main circle
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][11]); //Medicine drop down menu
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][12]); //Close box info
    //TO DO: Hide downstate action textdraws and infobox (when respawned, hide all downstate textdraws)
    }
    }
    return 1;
    }

  • Also, wenn ein Spieler stirbt, werden seine Animationen gecleart und seine HP auf unendlich gesetzt, sodass die default Sterbeanimation sofort übersprungen wird. OnPlayerDeath und OnPlayerSpawn werden also unmittelbar nacheinander aufgerufen. Wenn der Spieler respawnt, starte ich den Timer unter OnPlayerSpawn, wie oben im Code schon aufgezeigt.


    Kleines Addendum: Ich habe nun versucht den Timer manuell per CMD zu beenden. Das klappt auch nicht. Er wütet trotzdem rum.

    Einmal editiert, zuletzt von Manyula ()

  • Machs mal so:
    new Downstate_Timer[MAX_PLAYERS] = {-1,...};


    //Unter OnPlayerSpawn
    if(Downstate_Timer[playerid] != -1) KillTimer(Downstate_Timer[playerid]);
    Downstate_Timer[playerid] = SetTimerEx("DownstateTimer", 250, true, "i", playerid);


    Im Timer:
    KillTimer(Downstate_Timer[playerid]);
    Downstate_Timer[playerid] = -1;

  • Was steht so im Server Log?
    //Timer Funktion
    forward DownstateTimer(playerid);
    public DownstateTimer(playerid)
    {
    printf("Timer aufgerufen: %d | %d | %d", playerid, Downstate_Counter[playerid], Downstate_Timer[playerid]);
    Downstate_Counter[playerid]++;
    if(Downstate_Counter[playerid] == 4)
    {
    printf("4");
    Downstate_Counter[playerid] = 0;

    new Float:a;
    GetPlayerArmour(playerid, a);
    printf("a: %f", a);
    if(0.0 < a < 100.0)
    {
    SetPlayerArmour(playerid, a - 1.0);
    }
    if(a == 100.0)
    {
    printf("a == 100.0");
    KillTimer(Downstate_Timer[playerid]);
    Downstate_Timer[playerid] = -1;
    Condition[playerid] = CONDITION_ALIVE;
    Downstate_Counter[playerid] = 0;
    ClearAnimations(playerid);
    SetPlayerHealth(playerid, 30);
    SetPlayerArmour(playerid, 0);
    //TO DO: Hide all textdraws from the downstate
    }
    if(a <= 0.0)
    {
    printf("a <= 0.0");
    KillTimer(Downstate_Timer[playerid]);
    Downstate_Timer[playerid] = -1;
    Condition[playerid] = CONDITION_DEAD;
    Downstate_Counter[playerid] = 0;
    ApplyAnimation(playerid, "CRACK", "crckdeth1", 4.1, false, true, true, true, 24*60000, true);
    //TO DO: Offer Respawn Hotkey
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][0]); //Downstate
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][1]); //WeaponCoverBox
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][2]); //Infobox
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][3]); //HealthCoverBox
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][4]); //Indicator arrow
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][5]); //Stop the bleeding
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][6]); //Cry for help
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][7]); //Last strength
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][8]); //Medicine
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][9]); //Up and down arrow of main circle
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][10]); //Left and right arrow of main circle
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][11]); //Medicine drop down menu
    PlayerTextDrawHide(playerid, TD_Downstate[playerid][12]); //Close box info
    //TO DO: Hide downstate action textdraws and infobox (when respawned, hide all downstate textdraws)
    }
    }
    printf("Fertig.");
    return 1;
    }