Need a working speedo - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need a working speedo (
/showthread.php?tid=74990)
Need a working speedo -
Bearfist - 27.04.2009
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
Re: Need a working speedo -
miokie - 27.04.2009
There is one out there, I remember seeing one once on the forums.
Just search Speedo and go through them all.
Re: Need a working speedo -
Bearfist - 27.04.2009
Yes Idid but ..
how to calculate kmh
...could you tell me ?
Bearfist
Re: Need a working speedo -
ferriswheel - 27.04.2009
If it's in miles per hour, simply divide by 1.6 to get km/h.
Re: Need a working speedo -
Joe Staff - 27.04.2009
uhm... multiply?
Re: Need a working speedo -
Bearfist - 27.04.2009
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;
}
Re: Need a working speedo -
Joe Staff - 27.04.2009
No need to destroy the Textdraw, wiki up TextDrawSetString
Re: Need a working speedo -
Bearfist - 27.04.2009
The speedo works...
Bearfist
Re: Need a working speedo -
ferriswheel - 27.04.2009
Quote:
Originally Posted by SilentHuntR
uhm... multiply?
|
Fine, complicate the issue with logic, but you're right
Re: Need a working speedo -
Bearfist - 27.04.2009
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
??