convert kilometers - 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: convert kilometers (
/showthread.php?tid=556661)
convert kilometers -
gabitzu4ever - 11.01.2015
PHP код:
if(strcmp(cmd, "/work", true) == 0)
{
new
Float: fX,
Float: fY,
Float: fZ,
Float:Distance
;
GetPlayerPos(playerid, fX, fY, fZ);
Distance = GetPointDistanceToPoint3D(fX, fY, fZ, 925.8821,-1757.5184,13.5469);
format(string, sizeof(string), " Kilomters %f to the point", Distance);
SendClientMessage(playerid, -1, string);
return 1;
}
PHP код:
forward Float:GetPointDistanceToPoint3D(Float: fX1, Float: fY1, Float: fZ1, Float: fX2, Float: fY2, Float: fZ2);
public Float:GetPointDistanceToPoint3D(Float: fX1, Float: fY1, Float: fZ1, Float: fX2, Float: fY2, Float: fZ2)
{
return floatsqroot(((fX1 -= fX2) * fX1) + ((fY1 -= fY2) * fY1) + ((fZ1 -= fZ2) * fZ1));
}
show meters, how to convert to kilometers ?
Re: convert kilometers -
M4D - 11.01.2015
1000 meter = 1 kilo meter !
So
Meter/1000 = KM
Re: convert kilometers -
gabitzu4ever - 11.01.2015
my script show
I want to look
Kilometers 34.7 to the point
Do You Understand?
Bad English
Re: convert kilometers -
CalvinC - 11.01.2015
I don't know if this works, but try to do:
pawn Код:
Distance = GetPointDistanceToPoint3D(fX, fY, fZ, 925.8821,-1757.5184,13.5469 / 100);
Re: convert kilometers -
CutX - 11.01.2015
Quote:
Originally Posted by gabitzu4ever
my script show
I want to look
Kilometers 34.7 to the point
Do You Understand?
Bad English 
|
format it like this
pawn Код:
format(string, sizeof(string), " Kilomters %.2f to the point", Distance);
and it'll be 2 decimal places
do:
%.1f for only 1
or:
%.0f for none
Re: convert kilometers -
gabitzu4ever - 11.01.2015
Quote:
Originally Posted by CalvinC
I don't know if this works, but try to do:
pawn Код:
Distance = GetPointDistanceToPoint3D(fX, fY, fZ, 925.8821,-1757.5184,13.5469 / 100);
|
No work
Re: convert kilometers -
gabitzu4ever - 11.01.2015
Quote:
Originally Posted by CutX
format it like this
pawn Код:
format(string, sizeof(string), " Kilomters %.2f to the point", Distance);
and it'll be 2 decimal places
do: %.1f for only 1
or: %.0f for none
|
Re: convert kilometers -
fordawinzz - 11.01.2015
Omfg.
pawn Код:
new Float: d, string[16];
d = GetPlayerDistanceFromPoint(playerid, 925.8821, -1757.5184, 13.5469) / 1000;
format(string, sizeof (string), "Distance: %.2f", d);
SendClientMessage(playerid, ~1, string);
Re: convert kilometers -
gabitzu4ever - 11.01.2015
Quote:
Originally Posted by fordawinzz
Omfg.
pawn Код:
new Float: d, string[16];
d = GetPlayerDistanceFromPoint(playerid, 925.8821, -1757.5184, 13.5469) / 1000;
format(string, sizeof (string), "Distance: %.2f", d); SendClientMessage(playerid, ~1, string);
|
work, thanks !!