Speedometer help
#1

Hello there community of SA-MP. I am requesting help, because my speedometer is not really working how I want it to work.

pawn Код:
forward Speedo(playerid);
    public Speedo(playerid)
    {
        new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[24],final_speed_int;
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleVelocity(vehicleid, speed_x, speed_y, speed_z);
        final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*95.0;
        final_speed_int = floatround(final_speed, floatround_round);
        if(final_speed_int >= 60)format(speed_string, sizeof(speed_string), "~b~S~w~peed: ~b~%i MPH", final_speed_int);
        else format(speed_string, sizeof(speed_string), "~b~S~w~peed: ~b~%i MPH", final_speed_int);
        TextDrawSetString(Speed[playerid], speed_string);
        return 1;
    }
pawn Код:
stock ShowVehicleTextdraws(playerid)
    {  
        Speed[playerid] = TextDrawCreate(489.000122, 357.155487, "~b~S~w~peed: ~b~ 100");
        TextDrawLetterSize(Speed[playerid], 0.449999, 1.600000);
        TextDrawAlignment(Speed[playerid], 1);
        TextDrawColor(Speed[playerid], -1);
        TextDrawSetShadow(Speed[playerid], 0);
        TextDrawSetOutline(Speed[playerid], 1);
        TextDrawBackgroundColor(Speed[playerid], 51);
        TextDrawFont(Speed[playerid], 1);
        TextDrawSetProportional(Speed[playerid], 1);

        TextDrawShowForPlayer(playerid, Text:Speed[playerid]);
        return 1;
    }
And it is displaying when the player goes into a vehicle yes. Can somene tell me, why the speedo stays at the 100 miles pr. hour displayed in the textdraw?
Reply
#2

You need to redisplay the textdraw when you edit its string.
Reply
#3

How?
Reply
#4

Quote:
Originally Posted by EmilLykke
Посмотреть сообщение
How?
Using TextDrawShowForPlayer of course.
Reply
#5

Yeah, but where exactly?
Reply
#6

After you set the string.
TextDrawSetString(textdraw, "string");
TextDrawShowForPlayer(playerid, textdraw);
Reply
#7

Where exactly?
Reply
#8

What do you mean where exactly?
Reply
#9

BTW your velocity calculation is incorrect.

https://sampforum.blast.hk/showthread.php?tid=364124&page=3
Reply
#10

Now I have another issue... Can someone help me via skype please?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)