Код:
#include <a_samp>
new Text:Textdraw2;
new Text:eSPEEDO[7];
#define SpeedCheck(%0,%1,%2,%3,%4) floatround(floatsqroot(%4?(%0*%0+%1*%1+%2*%2):(%0*%0+%1*%1) ) *%3*1.8)
public OnPlayerConnect(playerid)
{
SetTimer("Speedometer", 1000, 1);
// ==============================
eSPEEDO[1] = TextDrawCreate(489.375000, 333.666717, "");
TextDrawLetterSize(eSPEEDO[1], 0.449999, 1.600000);
TextDrawAlignment(eSPEEDO[1], 1);
TextDrawColor(eSPEEDO[1], -1);
TextDrawSetShadow(eSPEEDO[1], 0);
TextDrawSetOutline(eSPEEDO[1], 1);
TextDrawBackgroundColor(eSPEEDO[1], 255);
TextDrawFont(eSPEEDO[1], 3);
TextDrawSetProportional(eSPEEDO[1], 1);
eSPEEDO[2] = TextDrawCreate(489.375000, 348.833312, "");
TextDrawLetterSize(eSPEEDO[2], 0.449999, 1.600000);
TextDrawAlignment(eSPEEDO[2], 1);
TextDrawColor(eSPEEDO[2], -1);
TextDrawSetShadow(eSPEEDO[2], 0);
TextDrawSetOutline(eSPEEDO[2], 1);
TextDrawBackgroundColor(eSPEEDO[2], 255);
TextDrawFont(eSPEEDO[2], 3);
TextDrawSetProportional(eSPEEDO[2], 1);
eSPEEDO[3] = TextDrawCreate(488.750000, 365.750030, "");
TextDrawLetterSize(eSPEEDO[3], 0.449999, 1.600000);
TextDrawAlignment(eSPEEDO[3], 1);
TextDrawColor(eSPEEDO[3], -1);
TextDrawSetShadow(eSPEEDO[3], 0);
TextDrawSetOutline(eSPEEDO[3], 1);
TextDrawBackgroundColor(eSPEEDO[3], 255);
TextDrawFont(eSPEEDO[3], 3);
TextDrawSetProportional(eSPEEDO[3], 1);
eSPEEDO[4] = TextDrawCreate(623.250000, 387.666687, "usebox");
TextDrawLetterSize(eSPEEDO[4], 0.000000, 1.433333);
TextDrawTextSize(eSPEEDO[4], 485.500000, 0.000000);
TextDrawAlignment(eSPEEDO[4], 1);
TextDrawColor(eSPEEDO[4], 0);
TextDrawUseBox(eSPEEDO[4], true);
TextDrawBoxColor(eSPEEDO[4], 102);
TextDrawSetShadow(eSPEEDO[4], 0);
TextDrawSetOutline(eSPEEDO[4], 0);
TextDrawFont(eSPEEDO[4], 0);
// Unlocked
eSPEEDO[5] = TextDrawCreate(508.750000, 384.416412, "~g~UNLOCKED");
TextDrawLetterSize(eSPEEDO[4], 0.421875, 1.950000);
TextDrawAlignment(eSPEEDO[4], 1);
TextDrawColor(eSPEEDO[4], 8388863);
TextDrawSetShadow(eSPEEDO[4], 0);
TextDrawSetOutline(eSPEEDO[4], 1);
TextDrawBackgroundColor(eSPEEDO[4], 255);
TextDrawFont(eSPEEDO[4], 2);
TextDrawSetProportional(eSPEEDO[4], 1);
// Locked
eSPEEDO[6] = TextDrawCreate(517.500000, 384.999969, "~r~Locked");
TextDrawLetterSize(Textdraw2, 0.465624, 1.804166);
TextDrawAlignment(eSPEEDO[6], 1);
TextDrawColor(eSPEEDO[6], -1);
TextDrawSetShadow(eSPEEDO[6], 0);
TextDrawSetOutline(eSPEEDO[6], 1);
TextDrawBackgroundColor(eSPEEDO[6], 255);
TextDrawFont(eSPEEDO[6], 2);
TextDrawSetProportional(eSPEEDO[6], 1);
return 1;
}
forward Speedometer(playerid);
public Speedometer(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new speed;
speed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0);
new string1[150], string2[150], string3[150];
TextDrawShowForPlayer(playerid, eSPEEDO[1]);
TextDrawShowForPlayer(playerid, eSPEEDO[2]);
TextDrawShowForPlayer(playerid, eSPEEDO[3]);
TextDrawShowForPlayer(playerid, eSPEEDO[4]);
/*
if(CarInfo[playerid][cLock] == 0)
{
TextDrawShowForPlayer(playerid, eSPEEDO[5]); - Locked
}
else if(CarInfo[playerid][cLock] == 1)
{
TextDrawShowForPlayer(playerid, eSPEEDO[6]); - Unlocked
}
*/
format(string1,sizeof(string1),"Speed: ~y~%d", speed);
TextDrawSetString(eSPEEDO[1], string1);
format(string2,sizeof(string2),"Fuel: ~y~%d%"); //ex: gas[vehicle]
TextDrawSetString(eSPEEDO[2], string2);
format(string3,sizeof(string2),"Odometer: ~y~%d%"); //ex: CarInfo[playerid][cOdometer]
TextDrawSetString(eSPEEDO[3], string3);
}
else
{
TextDrawHideForPlayer(playerid, eSPEEDO[1]);
TextDrawHideForPlayer(playerid, eSPEEDO[2]);
TextDrawHideForPlayer(playerid, eSPEEDO[3]);
TextDrawHideForPlayer(playerid, eSPEEDO[4]);
TextDrawHideForPlayer(playerid, eSPEEDO[5]);
TextDrawHideForPlayer(playerid, eSPEEDO[6]);
}
return 1;
}
//
stock GetVehicleSpeed(vehicleid, get3d)
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vehicleid, x, y, z);
return SpeedCheck(x, y, z, 100.0, get3d);
}