[HELP] Not Showing Textdraw...
#1

DELETE
Reply
#2

To make the that textdraw update, you need a function to get the vehicle's speed and make sure it updates the textdraw with a timer. I'm not sure if I am 100% right about this. If I am wrong, someone please correct me.
Reply
#3

DELETE
Reply
#4

your code does too many calculations/checks on each update!
i cant be asked to read ur code bit by bit.
pawn Код:
new Float:SPD, Float:vx, Float:vy, Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vx,vy,vz);
SPD = floatsqroot(((vx*vx)+(vy*vy))+(vz*vz))*100;
new Str[4];format(Str,4,"%f",SPD*SPEED_MULTIPLIER);
TextDrawSetString(SpeedTxt[playerid], Str);
Something like that
Reply
#5

DELETE
Reply
#6

pawn Код:
public Speedometer_Update(playerid)
{
        new vid, Float:speed_x, Float:speed_y, Float:speed_z, Float:final_speed, string[50], Float:vehiclehealth;
 
        vid = GetPlayerVehicleID(playerid);
        if(vid != 0)
        {
                GetVehicleVelocity(vid, speed_x, speed_y, speed_z);
                final_speed = floatsqroot(((speed_x * speed_x) + (speed_y * speed_y)) + (speed_z * speed_z)) * 158.179;
                APlayerData[playerid][PlayerSpeed] = final_speed*2; //i dont know how its setup
                format(string, sizeof , string"~w~Speed: ~y~%f~w~ kph", final_speed*2);
                TextDrawSetString(APlayerData[playerid][SpeedometerText], speed_string);//Is this ur textdrawid ?
                GetVehicleHealth(vid, vehiclehealth);
                SetPlayerHealth(vid, vehiclehealth / 10.0);
                new vid = GetPlayerVehicleID(playerid);
                format(string, sizeof(string), "Vehicle: ~g~%s", VehicleNames[GetVehicleModel(vid)-400]);//use the same string no need for new one
        }
        else
        {
                TextDrawSetString(APlayerData[playerid][SpeedometerText], " ");
                TextDrawHideForPlayer(playerid, APlayerData[playerid][VehicleName]);
                APlayerData[playerid][PlayerSpeed] = 0; //--Sets Speed To 0--//
        }
}
is APlayerData[playerid][SpeedometerText] the textdraw id ?
Reply
#7

DELETE
Reply
#8

That is not the same code i have posted!
Reply
#9

DELETE
Reply
#10

pawn Код:
public Speedometer_Update(playerid)
{
    new vid, Float:speed_x, Float:speed_y, Float:speed_z, Float:final_speed, speed_string[50], final_speed_int, Float:vehiclehealth; //--Local Variables--//

    vid = GetPlayerVehicleID(playerid); //--Id Of Player Vehicle--//

    if(vid != 0) //--If The Player Is Inside A Vehicle--//
    {
        GetVehicleVelocity(vid, speed_x, speed_y, speed_z);
        final_speed = floatsqroot(((speed_x * speed_x) + (speed_y * speed_y)) + (speed_z * speed_z)) * 158.179;
        final_speed_int = floatround(final_speed, floatround_round);
        APlayerData[playerid][PlayerSpeed] = final_speed_int;
        format(speed_string, 50, "~w~Speed: ~y~%i~w~ kph", final_speed_int);
        TextDrawSetString(APlayerData[playerid][SpeedometerText], speed_string);
        GetVehicleHealth(vid, vehiclehealth);
        SetPlayerHealth(vid, vehiclehealth / 10.0);
        new str[50];
        new vid = GetPlayerVehicleID(playerid);
        format(str, sizeof(str), "Vehicle: ~g~%s", VehicleNames[GetVehicleModel(vid)-400]);
                TextDrawSetString(APlayerData[playerid][VehicleName], str);
    }
    else
    {
        TextDrawSetString(APlayerData[playerid][SpeedometerText], " "); //--Remove Speedo If Player Not Is Inside A Vehicle--//
        TextDrawHideForPlayer(playerid, APlayerData[playerid][VehicleName]);
        APlayerData[playerid][PlayerSpeed] = 0; //--Sets Speed To 0--//
    }
}
Try that, replacing the code I posted below with your "Speedometer_Update".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)