Need a working speedo
#1

Hi guys.. I have a speedo .. but it doesn't show realistic km/h

... does someone have a simple only speed (km/h) speedo ?

If yes it would be great

Bearfist
Reply
#2

There is one out there, I remember seeing one once on the forums.

Just search Speedo and go through them all.
Reply
#3

Yes Idid but ..
how to calculate kmh
...could you tell me ?

Bearfist
Reply
#4

If it's in miles per hour, simply divide by 1.6 to get km/h.
Reply
#5

uhm... multiply?
Reply
#6

Would this give a realistic kmh speedo

Code:
#define SLOTS 200

enum SavePlayerPosEnum {
Float:LastX,
Float:LastY,
Float:LastZ
}

new SavePlayerPos[SLOTS][SavePlayerPosEnum];
new Text:Speedo[SLOTS];
new UpdateSeconds;

forward UpdateSpeed();
Code:
SetTimer("UpdateSpeed",1000, 1);
Code:
public UpdateSpeed()
{
	new Float:x,Float:y,Float:z;
	new Float:distance,value; //string[256];
	//new Float:health;
	for(new i=0; i<SLOTS; i++)
	{
		if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
		{
			TextDrawDestroy(Speedo[i]);
		}
	}

	for(new i=0; i<SLOTS; i++)
	{
		if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
		{
			GetPlayerPos(i, x, y, z);
			distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
			value = floatround(distance * 5000);
			if(UpdateSeconds > 1)
			{
				value = floatround(value / UpdateSeconds);
			}
			format(string,sizeof(string),"~r~KM/H:%d",floatround(value/1600));
			Speedo[i] = TextDrawCreate(560, 380,string);
			TextDrawFont(Speedo[i], 1);
			TextDrawColor(Speedo[i],COLOR_GREEN);
			TextDrawSetShadow(Speedo[i],1);
			TextDrawAlignment(Speedo[i],1);
			TextDrawShowForPlayer (i, Speedo[i]);
		  TextDrawSetOutline(Speedo[i],1);
	    TextDrawBackgroundColor(Speedo[i],COLOR_BLACK);
		}
		SavePlayerPos[i][LastX] = x;
		SavePlayerPos[i][LastY] = y;
		SavePlayerPos[i][LastZ] = z;
	}
}
Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_ONFOOT)
	{
  TextDrawHideForPlayer(playerid, Speedo[playerid]);
	}
	return 1;
}
Reply
#7

No need to destroy the Textdraw, wiki up TextDrawSetString
Reply
#8

The speedo works...

Bearfist
Reply
#9

Quote:
Originally Posted by SilentHuntR
uhm... multiply?
Fine, complicate the issue with logic, but you're right
Reply
#10

Quote:
Originally Posted by ferriswheel
Quote:
Originally Posted by SilentHuntR
uhm... multiply?
Fine, complicate the issue with logic, but you're right
What do you mean with that post ??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)