Speedometer/Textdraw
#1

Hey there, i have speedometer who is working just fine with 2 people in server but when there is more speedo get messy, like id 1 can see id 3 car`s speed and so on. U can just see random peoples speedo when driving.

pawn Код:
//ON top of the script
new
    fstr[128],
    Text:TD_Speedo[MAX_PLAYERS][2];
//onplayerupdate
    if (IsPlayerInAnyVehicle(playerid))
    {
        new
            vspeed;
        vspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid));

        format(fstr, sizeof(fstr), "%d", vspeed);
        TextDrawSetString(TD_Speedo[playerid][1], fstr);
    }
//if oldstatedriver
        for (new i; i <= 2; i++)
        TextDrawDestroy(TD_Speedo[playerid][i]);

//onplayerstatechange
            if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new
            Float:vhp,
            vspeed;
        GetVehicleHealth(GetPlayerVehicleID(playerid), vhp);
        vspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid));

        TD_Speedo[playerid][0] = TextDrawCreate(590.000000, 427.000000, "Km/h"); // speedo
        TextDrawBackgroundColor(TD_Speedo[playerid][0], 255);
        TextDrawFont(TD_Speedo[playerid][0], 1);
        TextDrawLetterSize(TD_Speedo[playerid][0], 0.389899, 1.299900);
        TextDrawColor(TD_Speedo[playerid][0], 13107455);
        TextDrawSetOutline(TD_Speedo[playerid][0], 1);
        TextDrawSetProportional(TD_Speedo[playerid][0], 1);

        format(fstr, sizeof(fstr), "%d", vspeed);
        TD_Speedo[playerid][1] = TextDrawCreate(560.000000, 427.000000, fstr);
        TextDrawBackgroundColor(TD_Speedo[playerid][1], 255);
        TextDrawFont(TD_Speedo[playerid][1], 1);
        TextDrawLetterSize(TD_Speedo[playerid][1], 0.389899, 1.299900);
        TextDrawColor(TD_Speedo[playerid][1], -1);
        TextDrawSetOutline(TD_Speedo[playerid][1], 1);
        TextDrawSetProportional(TD_Speedo[playerid][1], 1);
       
        for (new i; i <= 2; i++)
        TextDrawShowForPlayer(playerid, TD_Speedo[playerid][i]);
        }
     //
stock GetVehicleSpeed(vehicleid)
{
    new
        Float:vel[3],
        Float:tempspeed;
    GetVehicleVelocity(vehicleid, vel[0], vel[1], vel[2]);
    tempspeed = floatsqroot((vel[0] * vel[0]) + (vel[1] * vel[1]) + (vel[2] * vel[2])) * 151.2;
    return floatround(tempspeed, floatround_round);
}
//onplayerexitveh
    for (new i; i <= 2; i++)
        TextDrawDestroy(TD_Speedo[playerid][i]);
I hope someone can help me. Thanks!
Reply
#2

its better to create the textdraw in OnPlayerConnect, and show it when the player enter the vehicle, then hide it when he exit the vehicle, and destroy the text when the player disconnect
Reply
#3

When its onplayerconnect it shows only for first entering in car
Reply
#4

how to install this? please help me i search for it 1 week

is this for speedcamera?
them you can see the speed that is set on the speedcamera?
Reply
#5

Use OnPlayerStateChange And SetTimerEx
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)