need help with speedometer
#1

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
Reply
#2

help please
Reply
#3

https://sampwiki.blast.hk/wiki/GetVehicleVelocity
Reply
#4

Ok but how to tell player the car speed ?!
Reply
#5

some help please ?
Reply
#6

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);
Reply
#7

Код:
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;
}
Reply
#8

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

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
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)