SA-MP Forums Archive
need help with speedometer - 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)
+--- Thread: need help with speedometer (/showthread.php?tid=471996)



need help with speedometer - MrTinder - 26.10.2013

I start making a speedometer for my server but i can't.

This will be the Textdraw:

pawn Код:
Textdraw3 = TextDrawCreate(548 ,416 , "Speed");
TextDrawFont(Textdraw3 , 3);
TextDrawLetterSize(Textdraw3 , 0.4, 2.8000000000000003);
TextDrawColor(Textdraw3 , 0xffffffFF);
TextDrawSetOutline(Textdraw3 , false);
TextDrawSetProportional(Textdraw3 , true);
TextDrawSetShadow(Textdraw3 , 1);
and this will be the public:

pawn Код:
public SpeedMeter()
{
    for(new x; x<MAX_PLAYERS; x++)
    {
          new TDstring[256];
          format(TDstring, sizeof(TDstring), "~w~Speed: %i");
          TextDrawSetString(Textdraw3[x], TDstring);
    }
    return 1;
}
So i need help how to get the speed and then to show it to players


Re: need help with speedometer - MrTinder - 26.10.2013

help please


Re: need help with speedometer - DanishHaq - 26.10.2013

https://sampwiki.blast.hk/wiki/GetVehicleVelocity


Re: need help with speedometer - MrTinder - 26.10.2013

Ok but how to tell player the car speed ?!


Re: need help with speedometer - MrTinder - 26.10.2013

some help please ?


Re: need help with speedometer - Pottus - 26.10.2013

pawn Код:
new Float:vx, Float:vy, Float:vz, Float:vel;
vel = GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
vel = (floatsqroot(((vx*vx)+(vy*vy))+(vz*vz))* 181.5);



Re: need help with speedometer - LoLeC - 26.10.2013

Код:
public SpeedMeter()
{
    for(new x; x<MAX_PLAYERS; x++)
    {
         if(IsPlayerConnected(x) && IsPlayerInAnyVehicle(x))
         {
             new Float:x,Float:y,Float:z,TDstring[256],vehicleid = GetPlayerVehicleID(x);
             TextDrawShowForPlayer(x,Textdraw3[x]);
             GetVehicleVelocity(vehicleid,x,y,z);
             format(TDstring, sizeof(TDstring), "~w~Speed: %d",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*250.666667));
             TextDrawSetString(Textdraw3[x], TDstring);
         }
    }
    return 1;
}



Re: need help with speedometer - Pottus - 26.10.2013

LoLeC's solution will work but use 181.5 instead of 250.666667 he doesn't know what he's talking about.


Re: need help with speedometer - RayDcosta - 26.10.2013

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
LoLeC's solution will work but use 181.5 instead of 250.666667 he doesn't know what he's talking about.
+1 true that