Color Fade

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
  • Folgender Code bewirkt folgendes:
    Der Spieler stirbt und respawnt danach sofort, indem er die Sterbeanimation überspringt, via SetPlayerHealth(playerid, FLOAT_INFINITY);.
    Wenn der Spieler stirbt, wird ein Timer gestartet, der dem Spieler einen 500ms color fade anzeigen soll. Dann liegt der Spieler da, und kann mittels eines CMD respawnen.
    Nun klappt das Faden aber nicht. Ich habe mich an diesem Tutorial orientiert, aber es klappt nicht.


    new PlayerText:DeathFadeTD[MAX_PLAYERS];


    DeathFadeTD[playerid] = CreatePlayerTextDraw(playerid, -20.000000, 0.000000, "_");
    PlayerTextDrawUseBox(playerid, DeathFadeTD[playerid], 1);
    PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF0000C8);
    PlayerTextDrawAlignment(playerid, DeathFadeTD[playerid], 0);
    PlayerTextDrawBackgroundColor(playerid, DeathFadeTD[playerid], 0xFF0000C8);
    PlayerTextDrawFont(playerid, DeathFadeTD[playerid], 3);
    PlayerTextDrawLetterSize(playerid, DeathFadeTD[playerid], 1.000000, 52.200000);
    PlayerTextDrawColor(playerid, DeathFadeTD[playerid], 0xFF0000C8);


    new DeathFadeCount[MAX_PLAYERS] = 0;


    forward DeathFader(playerid);
    public DeathFader(playerid)
    {
    DeathFadeCount[playerid]++;
    switch(DeathFadeCount[playerid])
    {
    case 1: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF0000BE);
    case 2: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF0000B4);
    case 3: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF0000AA);
    case 4: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF0000A0);
    case 5: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000096);
    case 6: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF00008C);
    case 7: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000082);
    case 8: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000078);
    case 9: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF00006E);
    case 10: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000064);
    case 11: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF00005A);
    case 12: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000050);
    case 13: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000046);
    case 14: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF00003C);
    case 15: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000032);
    case 16: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000028);
    case 17: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF00001E);
    case 18: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF000014);
    case 19: PlayerTextDrawBoxColor(playerid, DeathFadeTD[playerid], 0xFF00000A);
    case 20:
    {
    PlayerTextDrawHide(playerid, DeathFadeTD[playerid]);
    KillTimer(DeathFaderTimer[playerid]);
    }
    }
    return 1;
    }


    public OnPlayerDeath(playerid, killerid, reason)
    {
    if(GetPlayerVirtualWorld(playerid) == 0)
    {
    SetPlayerHealth(playerid, FLOAT_INFINITY);
    PlayerTextDrawShow(playerid, DeathFadeTD[playerid]);
    DeathFaderTimer[playerid] = SetTimerEx("DeathFader", 500/20, true, "i", playerid);
    ClearAnimations(playerid);
    GetPlayerPos(playerid, pDeathLoc[playerid][0], pDeathLoc[playerid][1], pDeathLoc[playerid][2]);
    GetPlayerFacingAngle(playerid, pDeathLoc[playerid][3]);
    }
    return 1;
    }


    public OnPlayerSpawn(playerid)
    {
    SetPlayerPos(playerid, pDeathLoc[playerid][0], pDeathLoc[playerid][1], pDeathLoc[playerid][2]);
    SetPlayerFacingAngle(playerid, pDeathLoc[playerid][3]);
    SetCameraBehindPlayer(playerid);
    TogglePlayerControllable(playerid, 0);
    ApplyAnimation(playerid, "PED", "KO_shot_front", 4.1, 0, 1, 1, 1, 1);
    return 1;
    }