Textdraw strange
#1

I want it to show the speed, but for some strange reason it only shows my current speed when im on foot running, when i enter a vehicle it stays at 0 :S

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    speedo[playerid] = TextDrawCreate(241,428,"Speed: 0/kmh"); //create the textdraw at position
    TextDrawFont(speedo[playerid],3); //font type of textdraw
    TextDrawLetterSize(speedo[playerid],0.699999,1.700000); //size...
    TextDrawColor(speedo[playerid],COLOR_GREY); //color
    SetTimerEx("Speed", 1000, true, "");
    TextDrawShowForPlayer(playerid,speedo[playerid]);
    if(IsPlayerInBoat(playerid))
    {
      ///
    }
    else
    {
      SetTimerEx("LongDriver", 3600000, false, "i"); // One Hour
    }

    return 1;
}
Speed:
pawn Код:
public Speed(playerid)
{
    GetPlayerSpeed(playerid);
    new speed[88];
    format(speed, sizeof(speed),"Speed: %i/kmh", GetPlayerSpeed(playerid));
    TextDrawSetString(speedo[playerid], speed);
    TextDrawShowForPlayer(playerid, speedo[playerid]);
    return 1;
}
Speed:
pawn Код:
stock GetPlayerSpeed(playerid)
{
    new Float:x, Float:y, Float:z, Float:rst;
    GetPlayerVelocity(playerid, x, y, z);
    rst = ((x*x) + (y*y));
    return floatround(rst * 200, floatround_round);
}
Reply
#2

Speed:
pawn Code:
PHP код:
public Speed(playerid)
{
    
GetPlayerSpeed(playerid);
    new 
speed[88];
    
format(speedsizeof(speed),"Speed: %i/kmh"GetPlayerSpeed(playerid));
    
TextDrawSetString(speedo[playerid], speed);
    
//TextDrawShowForPlayer(playerid, speedo[playerid]);
    
return 1;

try that
Reply
#3

Okay...But that does not really help my issue with it only showing on foot....
Reply
#4

Just have a timer, loop through all players and check if they're in a vehicle and show the speed if they are.
Reply
#5

But The simple question is, Why won't it work anyway?It should work if your in vehicle or on foot.But it's only working on foot.WHY?
Reply
#6

24 HOUR BUMP!!
Reply
#7

pawn Код:
stock GetPlayerSpeed(playerid)
{
    new Float:x, Float:y, Float:z, Float:rst;
    if(IsPlayerInAnyVehicle(playerid))
    {
        GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
    }
    else
    {
        GetPlayerVelocity(playerid, x, y, z);
    }
    rst = ((x*x) + (y*y));
    return floatround(rst * 200, floatround_round);
}
Reply
#8

This doesn't work accurate its way off, does anyone know of a legit GetPlayerSpeed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)