Posts: 108
Threads: 21
Joined: Aug 2016
02.10.2016, 02:25
(
Последний раз редактировалось CannonBolt; 02.10.2016 в 12:53.
)
Hey i got this code.
Код:
GetDistanceBetweenPlayers(playera, playerb)
{
if(!IsPlayerConnected(playera) || !IsPlayerConnected(playerb))
{
return -1.00;
}
new Float:pPos[3], Float:pDistance;
GetPlayerPos(playerb, pPos[0], pPos[1], pPos[2]);
pDistance = GetPlayerDistanceFromPoint(playera, pPos[0], pPos[1], pPos[2]);
return pDistance;
}
Thing is now how do i convert it to KMs? if a player is 1000m from another player it will show as Distance: 1.2 KM
Posts: 547
Threads: 57
Joined: Dec 2010
If I'm not mistaken, if you want to convert it into km, just divide the result by 1000 as 1 km is 1000m.
Posts: 108
Threads: 21
Joined: Aug 2016
Quote:
Originally Posted by DTV
If I'm not mistaken, if you want to convert it into km, just divide the result by 1000 as 1 km is 1000m.
|
this is just a "/" right?
Also what about getting it as a decimal? 1.2 KM
Posts: 3,085
Threads: 37
Joined: Nov 2012
Reputation:
0
"/" is divide. It doesn't matter how you use it, it's about how you format the string.
Posts: 108
Threads: 21
Joined: Aug 2016
Could you explain a bit more.
1000m = 1Km
Код:
if(pDistance = 1-999)
TextDrawSetString(PlDis,Dis: %.0f%% M);
else if(pDistance = 1000 / 1000)
TextDrawSetString(PlDis,Dis: %.0f% KM);
This is right?
Output:
0 M
0.0 KM
I suck on conversions.
Posts: 223
Threads: 45
Joined: Feb 2016
Reputation:
0
u need to use float function if u want to get in decimal
Posts: 108
Threads: 21
Joined: Aug 2016
Above you,^^. what i want to know is how to convert it!
Posts: 547
Threads: 57
Joined: Dec 2010
You convert it like:
pawn Код:
new exampleint = 4,Float:floatvalue;
floatvalue = float(exampleint); //this is how you convert it
Posts: 108
Threads: 21
Joined: Aug 2016
Quote:
Originally Posted by DTV
You convert it like:
pawn Код:
new exampleint = 4,Float:floatvalue; floatvalue = float(exampleint); //this is how you convert it
|
Its give an error.