Speedometer/Textdraw - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Speedometer/Textdraw (
/showthread.php?tid=375519)
Speedometer/Textdraw -
bleedis - 07.09.2012
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!
Re: Speedometer/Textdraw - HuSs3n - 07.09.2012
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
Re: Speedometer/Textdraw -
bleedis - 07.09.2012
When its onplayerconnect it shows only for first entering in car
Re: Speedometer/Textdraw -
Instand - 25.12.2013
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?
Re : Speedometer/Textdraw -
[HRD]Mar1 - 25.12.2013
Use OnPlayerStateChange And SetTimerEx