Speedometer help - 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 help (
/showthread.php?tid=487346)
Speedometer help -
Lyksus - 12.01.2014
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?
Re: Speedometer help -
Seif- - 12.01.2014
You need to redisplay the textdraw when you edit its string.
Re: Speedometer help -
EmilLykke - 12.01.2014
How?
Re: Speedometer help -
Seif- - 12.01.2014
Quote:
Originally Posted by EmilLykke
How?
|
Using TextDrawShowForPlayer of course.
Re: Speedometer help -
EmilLykke - 12.01.2014
Yeah, but where exactly?
Re: Speedometer help -
Seif- - 12.01.2014
After you set the string.
TextDrawSetString(textdraw, "string");
TextDrawShowForPlayer(playerid, textdraw);
Re: Speedometer help -
EmilLykke - 12.01.2014
Where exactly?
Re: Speedometer help -
Seif- - 12.01.2014
What do you mean where exactly?
Re: Speedometer help -
Pottus - 13.01.2014
BTW your velocity calculation is incorrect.
https://sampforum.blast.hk/showthread.php?tid=364124&page=3
Re: Speedometer help -
Lyksus - 13.01.2014
Now I have another issue... Can someone help me via skype please?