07.09.2012, 09:49
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.
I hope someone can help me. Thanks!
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]);