Vehicle Health richtig auslesen

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
  • Hi ich habe mich an einem Tacho versucht der folgende funktionen hat; ModelID,Zustand,KMH


    Ich habe ein Prob mit der Abfrage des Zustands habs so gemacht aber es steht da ca 1.0000000


    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
    Textdraw0 = TextDrawCreate(618.000000, 346.000000, "_");
    TextDrawBackgroundColor(Textdraw0, 255);
    TextDrawFont(Textdraw0, 1);
    TextDrawLetterSize(Textdraw0, 0.539999, 1.000000);
    TextDrawColor(Textdraw0, -1);
    TextDrawSetOutline(Textdraw0, 0);
    TextDrawSetProportional(Textdraw0, 0);
    TextDrawSetShadow(Textdraw0, 1);
    TextDrawUseBox(Textdraw0, 1);
    TextDrawBoxColor(Textdraw0, 170);
    TextDrawTextSize(Textdraw0, 467.000000, 0.000000);
    TextDrawSetSelectable(Textdraw0, 0);
    Textdraw1 = TextDrawCreate(618.000000, 378.000000, "_");
    TextDrawBackgroundColor(Textdraw1, 255);
    TextDrawFont(Textdraw1, 1);
    TextDrawLetterSize(Textdraw1, 0.539999, 1.000000);
    TextDrawColor(Textdraw1, -1);
    TextDrawSetOutline(Textdraw1, 0);
    TextDrawSetProportional(Textdraw1, 0);
    TextDrawSetShadow(Textdraw1, 1);
    TextDrawUseBox(Textdraw1, 1);
    TextDrawBoxColor(Textdraw1, 170);
    TextDrawTextSize(Textdraw1, 467.000000, 2.000000);
    TextDrawSetSelectable(Textdraw1, 0);
    Textdraw2 = TextDrawCreate(618.000000, 362.000000, "_");
    TextDrawBackgroundColor(Textdraw2, 255);
    TextDrawFont(Textdraw2, 1);
    TextDrawLetterSize(Textdraw2, 0.539999, 1.000000);
    TextDrawColor(Textdraw2, -1);
    TextDrawSetOutline(Textdraw2, 0);
    TextDrawSetProportional(Textdraw2, 0);
    TextDrawSetShadow(Textdraw2, 1);
    TextDrawUseBox(Textdraw2, 1);
    TextDrawBoxColor(Textdraw2, 170);
    TextDrawTextSize(Textdraw2, 467.000000, 0.000000);
    TextDrawSetSelectable(Textdraw2, 0);
    Textdraw4 = TextDrawCreate(470.000000, 361.000000, "Km/h:");
    TextDrawBackgroundColor(Textdraw4, 255);
    TextDrawFont(Textdraw4, 1);
    TextDrawLetterSize(Textdraw4, 0.500000, 1.000000);
    TextDrawColor(Textdraw4, -1);
    TextDrawSetOutline(Textdraw4, 0);
    TextDrawSetProportional(Textdraw4, 1);
    TextDrawSetShadow(Textdraw4, 1);
    TextDrawSetSelectable(Textdraw4, 0);
    new Float:health,string[128],vehicleid;
    vehicleid=GetPlayerVehicleID(playerid);
    health=GetVehicleHealth(vehicleid,health);
    format(string,sizeof(string),"Zustand: %0f%",health);
    Textdraw5 = TextDrawCreate(470.000000, 377.000000, string);
    TextDrawBackgroundColor(Textdraw5, 255);
    TextDrawFont(Textdraw5, 1);
    TextDrawLetterSize(Textdraw5, 0.500000, 1.000000);
    TextDrawColor(Textdraw5, -1);
    TextDrawSetOutline(Textdraw5, 0);
    TextDrawSetProportional(Textdraw5, 1);
    TextDrawSetShadow(Textdraw5, 1);
    TextDrawSetSelectable(Textdraw5, 0);
    TextDrawShowForPlayer(playerid, Textdraw0);
    TextDrawShowForPlayer(playerid, Textdraw1);
    TextDrawShowForPlayer(playerid, Textdraw2);
    TextDrawShowForPlayer(playerid, Textdraw4);
    TextDrawShowForPlayer(playerid, Textdraw5);
    }
    if(newstate == PLAYER_STATE_ONFOOT)
    {
    TextDrawHideForAll(Textdraw0);
    TextDrawDestroy(Textdraw0);
    TextDrawHideForAll(Textdraw1);
    TextDrawDestroy(Textdraw1);
    TextDrawHideForAll(Textdraw2);
    TextDrawDestroy(Textdraw2);
    TextDrawHideForAll(Textdraw4);
    TextDrawDestroy(Textdraw4);
    TextDrawHideForAll(Textdraw5);
    TextDrawDestroy(Textdraw5);
    }
    return 1;
    }

  • Beavis
    Ist das so richtig mit flatrount funzt i wie nicht ;(
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
    Textdraw0 = TextDrawCreate(618.000000, 346.000000, "_");
    TextDrawBackgroundColor(Textdraw0, 255);
    TextDrawFont(Textdraw0, 1);
    TextDrawLetterSize(Textdraw0, 0.539999, 1.000000);
    TextDrawColor(Textdraw0, -1);
    TextDrawSetOutline(Textdraw0, 0);
    TextDrawSetProportional(Textdraw0, 0);
    TextDrawSetShadow(Textdraw0, 1);
    TextDrawUseBox(Textdraw0, 1);
    TextDrawBoxColor(Textdraw0, 170);
    TextDrawTextSize(Textdraw0, 467.000000, 0.000000);
    TextDrawSetSelectable(Textdraw0, 0);
    Textdraw1 = TextDrawCreate(618.000000, 378.000000, "_");
    TextDrawBackgroundColor(Textdraw1, 255);
    TextDrawFont(Textdraw1, 1);
    TextDrawLetterSize(Textdraw1, 0.539999, 1.000000);
    TextDrawColor(Textdraw1, -1);
    TextDrawSetOutline(Textdraw1, 0);
    TextDrawSetProportional(Textdraw1, 0);
    TextDrawSetShadow(Textdraw1, 1);
    TextDrawUseBox(Textdraw1, 1);
    TextDrawBoxColor(Textdraw1, 170);
    TextDrawTextSize(Textdraw1, 467.000000, 2.000000);
    TextDrawSetSelectable(Textdraw1, 0);
    Textdraw2 = TextDrawCreate(618.000000, 362.000000, "_");
    TextDrawBackgroundColor(Textdraw2, 255);
    TextDrawFont(Textdraw2, 1);
    TextDrawLetterSize(Textdraw2, 0.539999, 1.000000);
    TextDrawColor(Textdraw2, -1);
    TextDrawSetOutline(Textdraw2, 0);
    TextDrawSetProportional(Textdraw2, 0);
    TextDrawSetShadow(Textdraw2, 1);
    TextDrawUseBox(Textdraw2, 1);
    TextDrawBoxColor(Textdraw2, 170);
    TextDrawTextSize(Textdraw2, 467.000000, 0.000000);
    TextDrawSetSelectable(Textdraw2, 0);
    Textdraw4 = TextDrawCreate(470.000000, 361.000000, "Km/h:");
    TextDrawBackgroundColor(Textdraw4, 255);
    TextDrawFont(Textdraw4, 1);
    TextDrawLetterSize(Textdraw4, 0.500000, 1.000000);
    TextDrawColor(Textdraw4, -1);
    TextDrawSetOutline(Textdraw4, 0);
    TextDrawSetProportional(Textdraw4, 1);
    TextDrawSetShadow(Textdraw4, 1);
    TextDrawSetSelectable(Textdraw4, 0);
    new Float:health,string[128],vehicleid;
    floatround(Float:health,floatround_round);
    vehicleid=GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicleid,health);
    format(string,sizeof(string),"Zustand: %2.f%",health);
    Textdraw5 = TextDrawCreate(470.000000, 377.000000, string);
    TextDrawBackgroundColor(Textdraw5, 255);
    TextDrawFont(Textdraw5, 1);
    TextDrawLetterSize(Textdraw5, 0.500000, 1.000000);
    TextDrawColor(Textdraw5, -1);
    TextDrawSetOutline(Textdraw5, 0);
    TextDrawSetProportional(Textdraw5, 1);
    TextDrawSetShadow(Textdraw5, 1);
    TextDrawSetSelectable(Textdraw5, 0);
    TextDrawShowForPlayer(playerid, Textdraw0);
    TextDrawShowForPlayer(playerid, Textdraw1);
    TextDrawShowForPlayer(playerid, Textdraw2);
    TextDrawShowForPlayer(playerid, Textdraw4);
    TextDrawShowForPlayer(playerid, Textdraw5);
    }
    if(newstate == PLAYER_STATE_ONFOOT)
    {
    TextDrawHideForAll(Textdraw0);
    TextDrawDestroy(Textdraw0);
    TextDrawHideForAll(Textdraw1);
    TextDrawDestroy(Textdraw1);
    TextDrawHideForAll(Textdraw2);
    TextDrawDestroy(Textdraw2);
    TextDrawHideForAll(Textdraw4);
    TextDrawDestroy(Textdraw4);
    TextDrawHideForAll(Textdraw5);
    TextDrawDestroy(Textdraw5);
    }
    return 1;
    }

  • Lässt du es auch in den Timer Updaten?
    Scheinbar nicht
    und wenn du es auf 100 haben willst ganz einfach
    new Float:vHP;
    GetVehicleHealth(vehicleid,vHP);
    format(..."Leben: %d",floatround(vHP,floatround_round)/10);

    All in all it's just another brick in the wall

  • Wie mache ich das das mit dem timer geht er aktualisiert nicht und der Td is jetzt immer da ?


    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
    Textdraw0 = TextDrawCreate(618.000000, 346.000000, "_");
    TextDrawBackgroundColor(Textdraw0, 255);
    TextDrawFont(Textdraw0, 1);
    TextDrawLetterSize(Textdraw0, 0.539999, 1.000000);
    TextDrawColor(Textdraw0, -1);
    TextDrawSetOutline(Textdraw0, 0);
    TextDrawSetProportional(Textdraw0, 0);
    TextDrawSetShadow(Textdraw0, 1);
    TextDrawUseBox(Textdraw0, 1);
    TextDrawBoxColor(Textdraw0, 170);
    TextDrawTextSize(Textdraw0, 467.000000, 0.000000);
    TextDrawSetSelectable(Textdraw0, 0);
    Textdraw1 = TextDrawCreate(618.000000, 378.000000, "_");
    TextDrawBackgroundColor(Textdraw1, 255);
    TextDrawFont(Textdraw1, 1);
    TextDrawLetterSize(Textdraw1, 0.539999, 1.000000);
    TextDrawColor(Textdraw1, -1);
    TextDrawSetOutline(Textdraw1, 0);
    TextDrawSetProportional(Textdraw1, 0);
    TextDrawSetShadow(Textdraw1, 1);
    TextDrawUseBox(Textdraw1, 1);
    TextDrawBoxColor(Textdraw1, 170);
    TextDrawTextSize(Textdraw1, 467.000000, 2.000000);
    TextDrawSetSelectable(Textdraw1, 0);
    Textdraw2 = TextDrawCreate(618.000000, 362.000000, "_");
    TextDrawBackgroundColor(Textdraw2, 255);
    TextDrawFont(Textdraw2, 1);
    TextDrawLetterSize(Textdraw2, 0.539999, 1.000000);
    TextDrawColor(Textdraw2, -1);
    TextDrawSetOutline(Textdraw2, 0);
    TextDrawSetProportional(Textdraw2, 0);
    TextDrawSetShadow(Textdraw2, 1);
    TextDrawUseBox(Textdraw2, 1);
    TextDrawBoxColor(Textdraw2, 170);
    TextDrawTextSize(Textdraw2, 467.000000, 0.000000);
    TextDrawSetSelectable(Textdraw2, 0);
    Textdraw4 = TextDrawCreate(470.000000, 361.000000, "Km/h:");
    TextDrawBackgroundColor(Textdraw4, 255);
    TextDrawFont(Textdraw4, 1);
    TextDrawLetterSize(Textdraw4, 0.500000, 1.000000);
    TextDrawColor(Textdraw4, -1);
    TextDrawSetOutline(Textdraw4, 0);
    TextDrawSetProportional(Textdraw4, 1);
    TextDrawSetShadow(Textdraw4, 1);
    TextDrawSetSelectable(Textdraw4, 0);
    SetTimerEx("VehhealthTimer",100,true,"f",playerid);
    // new Float:health,string[128],vehicleid;
    // vehicleid=GetPlayerVehicleID(playerid);
    // GetVehicleHealth(vehicleid,health);
    // format(string,sizeof(string),"Zustand: %d%",floatround(health,floatround_round)/10);
    // Textdraw5 = TextDrawCreate(470.000000, 377.000000, string);
    TextDrawBackgroundColor(Textdraw5, 255);
    TextDrawFont(Textdraw5, 1);
    TextDrawLetterSize(Textdraw5, 0.500000, 1.000000);
    TextDrawColor(Textdraw5, -1);
    TextDrawSetOutline(Textdraw5, 0);
    TextDrawSetProportional(Textdraw5, 1);
    TextDrawSetShadow(Textdraw5, 1);
    TextDrawSetSelectable(Textdraw5, 0);
    TextDrawShowForPlayer(playerid, Textdraw0);
    TextDrawShowForPlayer(playerid, Textdraw1);
    TextDrawShowForPlayer(playerid, Textdraw2);
    TextDrawShowForPlayer(playerid, Textdraw4);
    TextDrawShowForPlayer(playerid, Textdraw5);
    }
    if(newstate == PLAYER_STATE_ONFOOT)
    {
    TextDrawHideForAll(Textdraw0);
    TextDrawDestroy(Textdraw0);
    TextDrawHideForAll(Textdraw1);
    TextDrawDestroy(Textdraw1);
    TextDrawHideForAll(Textdraw2);
    TextDrawDestroy(Textdraw2);
    TextDrawHideForAll(Textdraw4);
    TextDrawDestroy(Textdraw4);
    TextDrawHideForAll(Textdraw5);
    TextDrawDestroy(Textdraw5);
    }
    return 1;
    }
    public VehhealthTimer(playerid)
    {
    new Float:health,string[128],vehicleid;
    vehicleid=GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicleid,health);
    format(string,sizeof(string),"Zustand: %d%",floatround(health,floatround_round)/10);
    Textdraw5 = TextDrawCreate(470.000000, 377.000000, string);
    }

    2 Mal editiert, zuletzt von Ralf ()