How to make it to km/h
#1

Код:
public CheckStatus()
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			if(IsPlayerInAnyVehicle(i))
			{
				if(TextShow[i] == false)
				{
				    /*TextDrawShowForPlayer(i, Text:Black0);
				    TextDrawShowForPlayer(i, Text:Black1);
				    TextDrawShowForPlayer(i, Text:Black2);
				    TextDrawShowForPlayer(i, Text:Black3);
				    TextDrawShowForPlayer(i, Text:LightBlack);*/
				    TextShow[i] = true;
				}
			    new String[128];
		        new Float:X, Float:Y, Float:Z, Float:Speed;
		        new vehicle = GetPlayerVehicleID(i);
                GetVehicleVelocity(GetPlayerVehicleID(i), X, Y, Z);
                Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 100.0);
				format(String,sizeof(String),"~w~Fuel: ~w~%i ~w~Speed: ~w~%i", Gas[vehicle], floatround(Speed, floatround_floor));
				if(VHSCreated[i] == true)
				{
					TextDrawDestroy(VHS[i]);
				}
				VHS[i] = TextDrawCreate(260.000000,420.000000,String);
				TextDrawAlignment(VHS[i],0);
				//TextDrawBackgroundColor(VHS[i],0x000000ff);
				TextDrawFont(VHS[i],1);
				TextDrawLetterSize(VHS[i],0.299999,1.000000);
				//TextDrawColor(VHS[i],0xffffffff);
				//TextDrawSetOutline(VHS[i],1);
				//TextDrawSetProportional(VHS[i],1);
				//TextDrawSetShadow(VHS[i],1);
            	TextDrawShowForPlayer(i, VHS[i]);
            	VHSCreated[i] = true;

			}
			else
			{
			    if(TextShow[i] == true)
			    {
					TextDrawHideForPlayer(i, Text:Black0);
					TextDrawHideForPlayer(i, Text:Black1);
					TextDrawHideForPlayer(i, Text:Black2);
					TextDrawHideForPlayer(i, Text:Black3);
					TextDrawHideForPlayer(i, Text:LightBlack);
					TextDrawHideForPlayer(i, Text:VHS[i]);
				    TextShow[i] = false;
				}
			}
		}
	}
}
How i make it to km/h i think its mph or whatever .. Max speed with inf is like 140 or something.. ??
Reply
#2

I think it was something like 136.66666667 for kmh.
Reply
#3

1 MP/H = 1.61 KM/H

Just multiply it or whatever.
Reply
#4

It's 136.666667
Got it from this tutorial
Reply
#5

And what i have to change :P ?
Reply
#6

pawn Код:
Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 100.0);
This one.
Reply
#7

Quote:
Originally Posted by Delux13
Посмотреть сообщение
pawn Код:
Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(X, 2), floatpower(Y, 2)),  floatpower(Z, 2))), 100.0);
This one.
Oh yeah i changed it to 150 you helped me i repped you
Reply
#8

The easiest way
just add this somewhere in the script:
pawn Код:
Float:GetVehicleSpeed(vehicleid)
{
  new
    Float:vX,
    Float:vY,
    Float:vZ;
  GetVehicleVelocity(vehicleid, vX, vY, vZ);
  return floatsqroot(vX*vX + vY*vY + vZ*vZ);
}
and add format:
pawn Код:
format(String,sizeof(String),"~w~Fuel: ~w~%i ~w~Speed: ~w~%d", Gas[vehicle], GetVehicleSpeed(vehicle) * 200);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)