SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/09/2011, 11:56 AM   #1
Urefeu
Huge Clucker
 
Join Date: Jul 2011
Posts: 348
Reputation: 0
Default Speedometer

Hello.

I, a few days ago, saw a speedometer that inftead to have the text to show the speed, had a real speedometer.

I mean numbers (0, 20, 40 ...) arranged in a circle and a needle that moves depending on speed.

If you know or have a way to do it, I take.

Thank you!
__________________
Urefeu is offline   Reply With Quote
Old 18/09/2011, 12:28 PM   #2
[LHT]Bally
Gangsta
 
[LHT]Bally's Avatar
 
Join Date: Aug 2011
Posts: 590
Reputation: 2
Default Re: Speedometer

use search there is lots of them

http://forum.sa-mp.com/showthread.php?t=128157 <<-- there is one i found

Last edited by [LHT]Bally; 18/09/2011 at 12:46 PM. Reason: wrong answer
[LHT]Bally is offline   Reply With Quote
Old 18/09/2011, 12:36 PM   #3
Tigerkiller
Gangsta
 
Tigerkiller's Avatar
 
Join Date: May 2010
Posts: 757
Reputation: 25
Default Re: Speedometer

no he doesnt need ****** and its possible to script
Tigerkiller is offline   Reply With Quote
Old 18/09/2011, 12:41 PM   #4
[MWR]Blood
High-roller
 
Join Date: Apr 2009
Posts: 2,406
Reputation: 105
Default Re: Speedometer

No, he doesn't need any hack to have the speedometer - it is a script, search around and you will find it.
[MWR]Blood is offline   Reply With Quote
Old 18/09/2011, 12:43 PM   #5
[LHT]Bally
Gangsta
 
[LHT]Bally's Avatar
 
Join Date: Aug 2011
Posts: 590
Reputation: 2
Default Re: Speedometer

use search there is lots of them

http://forum.sa-mp.com/showthread.php?t=128157 <<-- there is one i found

Last edited by [LHT]Bally; 18/09/2011 at 12:47 PM. Reason: wrong answer
[LHT]Bally is offline   Reply With Quote
Old 18/09/2011, 05:49 PM   #6
Urefeu
Huge Clucker
 
Join Date: Jul 2011
Posts: 348
Reputation: 0
Default Re: Speedometer

Thanks.

My final code is this :

Code:
#include <a_samp>
#include <colors>

enum td
{
	Text:TDSpeedClock[13]
}

new TextDraws[td];
new Text:TextDrawsd[MAX_PLAYERS];

public OnFilterScriptInit()
{
	TextDraws[TDSpeedClock][0] = TextDrawCreate(496.000000,400.000000,"~g~20");
 	TextDraws[TDSpeedClock][1] = TextDrawCreate(487.000000,388.000000,"~g~40");
 	TextDraws[TDSpeedClock][2] = TextDrawCreate(483.000000,375.000000,"~g~60");
 	TextDraws[TDSpeedClock][3] = TextDrawCreate(488.000000,362.000000,"~g~80");
 	TextDraws[TDSpeedClock][4] = TextDrawCreate(491.000000,349.000000,"~g~100");
 	TextDraws[TDSpeedClock][5] = TextDrawCreate(508.000000,336.500000,"~y~120");
 	TextDraws[TDSpeedClock][6] = TextDrawCreate(536.000000,332.000000,"~y~140");
 	TextDraws[TDSpeedClock][7] = TextDrawCreate(567.000000,337.000000,"~y~160");
 	TextDraws[TDSpeedClock][8] = TextDrawCreate(584.000000,348.000000,"~r~180");
 	TextDraws[TDSpeedClock][9] = TextDrawCreate(595.000000,360.000000,"~r~200");
 	TextDraws[TDSpeedClock][10] = TextDrawCreate(603.000000,374.000000,"~r~220");
 	TextDraws[TDSpeedClock][11] = TextDrawCreate(594.000000,386.000000,"~r~240");
 	TextDraws[TDSpeedClock][12] = TextDrawCreate(585.000000,399.000000,"~r~260");
 	for(new i = 0; i < 13; i++)
 		TextDrawSetShadow(TextDraws[TDSpeedClock][i], 1);
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
	{
		for(new i; i < 13; i++)
			TextDrawShowForPlayer(playerid, TextDraws[TDSpeedClock][i]);

	  	TextDrawsd[playerid] = TextDrawCreate(555.0, 402.0, "~b~.");

	}
	else
	{
		TextDrawHideForPlayer(playerid, TextDrawsd[playerid]);
		for(new i; i < 13; i++)
			TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][i]);
	}

	return 1;
}

public OnPlayerUpdate(playerid)
{
	new
	    Float:fPos[3],
	    Float:Pos[2],
	    Float:fSpeed;

	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		GetVehicleVelocity(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);

		fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) +
		 floatpower(fPos[2], 2)) * 100;
		 
		new Float:alpha = 640 - fSpeed;

	    TextDrawHideForPlayer(playerid, TextDrawsd[playerid]);
	    TextDrawDestroy(TextDrawsd[playerid]);
  		GetDotXY(548, 401, Pos[0], Pos[1], alpha, 32);
  		TextDrawsd[playerid] = TextDrawCreate(Pos[0], Pos[1], "~w~.");
		TextDrawLetterSize(TextDrawsd[playerid], 0.73, -2.60);
		TextDrawSetOutline(TextDrawsd[playerid], 0);
		TextDrawSetShadow(TextDrawsd[playerid], 1);
		TextDrawShowForPlayer(playerid, TextDrawsd[playerid]);
		
		new string[400];
		format(string, 400, "fSpeed : %f - alpha : %f - Pos[0] : %f - Pos[1] : %f", fSpeed, alpha, Pos[0], Pos[1]);
		SendClientMessageToAll(ORANGE, string);
	}


	return 1;
}

stock GetDotXY(Float:StartPosX, Float:StartPosY, &Float:NewX, &Float:NewY, Float:alpha, Float:dist)
{
	 NewX = StartPosX + (dist * floatsin(alpha, degrees));
	 NewY = StartPosY + (dist * floatcos(alpha, degrees));
}
I'm particularly interested in this part:

Code:
GetVehicleVelocity(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);

		fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) +
		 floatpower(fPos[2], 2)) * 100;
		 
		new Float:alpha = 640 - fSpeed;

	    TextDrawHideForPlayer(playerid, TextDrawsd[playerid]);
	    TextDrawDestroy(TextDrawsd[playerid]);
  		GetDotXY(548, 401, Pos[0], Pos[1], alpha, 32);
and

Code:
stock GetDotXY(Float:StartPosX, Float:StartPosY, &Float:NewX, &Float:NewY, Float:alpha, Float:dist)
{
	 NewX = StartPosX + (dist * floatsin(alpha, degrees));
	 NewY = StartPosY + (dist * floatcos(alpha, degrees));
}
The problem is that I find the speed a little faster ... With a bike, I get to 100km / h (again, the bikes, no matter).

Except that if such because, I remain at 50km / h, the speed is really slow ... So I try to reduce some of the counter.

If I chance '* 200' to '* 100', the counter is not going further than 140/160 km / h.

If I spend 320 to 640, the meter starts at 40 ...

In short, I do not know how to get a more realistic speed: /

Thank you in advance!
__________________
Urefeu is offline   Reply With Quote
Old 19/09/2011, 04:30 AM   #7
Urefeu
Huge Clucker
 
Join Date: Jul 2011
Posts: 348
Reputation: 0
Default Re: Speedometer

Up !
__________________
Urefeu is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] My speedometer Yuval_Baruch Scripting Help 2 15/12/2011 11:51 AM
speedometer? swieberdevos Help Archive 5 31/03/2011 12:55 PM
Speedometer..... Gh0sT_ Help Archive 8 14/11/2010 10:32 PM
SpeedoMeter Help Proteine Help Archive 7 15/10/2010 03:38 PM
Speedometer and Name car icebox10 Help Archive 0 30/07/2009 02:05 PM


All times are GMT. The time now is 02:05 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.