17.07.2012, 15:43
I tested this exact code and it never shows speed always 0. If that's the case, then you may have not used it right, and/or put it into a script without putting all of it in.
There's one thing you can check for, though.
This one variable here:
Код:
new Float:PlayerPos[3][MAX_PLAYERS]; //Holds the player's last posistion.
Make sure of the following:
OnPlayerUpdate:
Код:
new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); format(string, sizeof(string), "Gas: ~%s~%d \%", FuelColor(vid), CarFuel[vid]); TextDrawSetString(speedo4[playerid], string); new distance = GetDistance(x, y, z, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]); PlayerPos[0][playerid] = x; PlayerPos[1][playerid] = y; PlayerPos[2][playerid] = z;
And, OnPlayerStateChange, when the player enters a vehicle:
Код:
new Float:x, Float:y, Float:z; GetPlayerPos(playerid, x, y, z); PlayerPos[0][playerid] = x; PlayerPos[1][playerid] = y; PlayerPos[2][playerid] = z;
3D text labels weren't done because I feel that a Text Draw for a speedometer is a better idea than the 3D text label, even connected to a vehicle. You're free to do it that way for your personal use, but I'm not going to do it.
And, as a note, I'm going to use this Speedo in my next GM - a San Fierro "Light Role Play".