24.02.2011, 16:43
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
Speed:
Speed:
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;
}
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;
}
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);
}