Vehicle velocity problem - 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: Vehicle velocity problem (
/showthread.php?tid=625639)
Vehicle velocity problem -
AndreiWow - 04.01.2017
I really don't know how velocity works but I use this on my server to get the speed and players complained that the speedo is showing too much, example when Landstalker goes reverse the speed increase up to 55 very fast.
If you drive a glendale straight you reach 160 and on some roads 200.
Sultan goes 200+, those are the vehicles I tested.
Код:
public Speedometer(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[16],final_speed_int;
vehicleid = GetPlayerVehicleID(i);
//new Float:vehicle_health,final_vehicle_health,health_string[256];
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*250.666667; // 250.666667 = kmph // 199,4166672= mph
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"%i",final_speed_int);
TextDrawSetString(speedo0[i], speed_string);
}
}
return 1;
}
Re: Vehicle velocity problem -
Lordzy - 04.01.2017
https://sampforum.blast.hk/showthread.php?tid=364124
Re: Vehicle velocity problem -
Freaksken - 04.01.2017
It's not as simple as it sounds. I use the number in
this post.
You can read more about it in
the whole thread.
Re: Vehicle velocity problem -
Lordzy - 04.01.2017
I did work on a speedometer two years ago where I faced such a problem. I wasn't satisfied with the value I used globally so I managed it to work well by using separate multiplier values according to the maximum speed of the vehicle. I was planning on increasing the vehicle speed limit, so to get things working well on my speedometer, I had to use separate multipliers.
Re: Vehicle velocity problem -
AndreiWow - 04.01.2017
Quote:
Originally Posted by Freaksken
|
Should I put 181.5 instead of 250.66667?
Re: Vehicle velocity problem -
Freaksken - 04.01.2017
Quote:
Originally Posted by AndreiWow
Should I put 181.5 instead of 250.66667?
|
Obviously.
Re: Vehicle velocity problem -
AndreiWow - 04.01.2017
Quote:
Originally Posted by Freaksken
Obviously.
|
Thanks, rep+