forward Speedo(playerid);
public Speedo(playerid) {
new vehicleid,
Float:speed_x,
Float:speed_y,
Float:speed_z,
Float:final_speed,
speed_string[256],
final_speed_int;
for(new i = 0; i < MAX_PLAYERS; i++)
{
vehicleid = GetPlayerVehicleID(i);
if(vehicleid != 0) {
GetVehicleVelocity(vehicleid, speed_x, speed_y, speed_z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136;
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"Speed: %i Km/H",final_speed_int);
TextDrawSetString(Speedoo[i], speed_string);
} else {
TextDrawSetString(Speedoo[i], "Speed: 0 Km/H ");
}
}
return 1;
}
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) {
TextDrawShowForPlayer(playerid,Speedoo[playerid]);
PlayerTextDrawShow(playerid, dashboard[playerid]);
PlayerTextDrawShow(playerid, carhealth[playerid]);
}
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) {
TextDrawHideForPlayer(playerid,Speedoo[playerid]);
PlayerTextDrawHide(playerid, dashboard[playerid]);
PlayerTextDrawHide(playerid, carhealth[playerid]);
}
return 1;
}
be sure that you have created "PlayerTextDraws" in "OnPlayerConnect"
|
Speedoo[playerid] = TextDrawCreate(510.000000, 371.000000, "Speed:");
TextDrawBackgroundColor(Speedoo[playerid], 255);
TextDrawFont(Speedoo[playerid], 1);
TextDrawLetterSize(Speedoo[playerid], 0.400000, 1.000000);
TextDrawColor(Speedoo[playerid], -1);
TextDrawSetOutline(Speedoo[playerid], 1);
TextDrawSetProportional(Speedoo[playerid], 1);
TextDrawUseBox(Speedoo[playerid], 1);
TextDrawBoxColor(Speedoo[playerid], -222);
TextDrawTextSize(Speedoo[playerid], 640.000000, 0.000000);
TextDrawSetSelectable(Speedoo[playerid], 0);
fuel[playerid] = CreatePlayerTextDraw(playerid, 510.000000, 386.000000, "Fuel:");
PlayerTextDrawBackgroundColor(playerid, fuel[playerid], 255);
PlayerTextDrawFont(playerid, fuel[playerid], 1);
PlayerTextDrawLetterSize(playerid, fuel[playerid], 0.409999, 1.000000);
PlayerTextDrawColor(playerid, fuel[playerid], -1);
PlayerTextDrawSetOutline(playerid, fuel[playerid], 1);
PlayerTextDrawSetProportional(playerid, fuel[playerid], 1);
PlayerTextDrawUseBox(playerid, fuel[playerid], 1);
PlayerTextDrawBoxColor(playerid, fuel[playerid], -222);
PlayerTextDrawTextSize(playerid, fuel[playerid], 660.000000, 0.000000);
PlayerTextDrawSetSelectable(playerid, fuel[playerid], 0);
dashboard[playerid] = CreatePlayerTextDraw(playerid, 531.000000, 351.000000, "Dash Board");
PlayerTextDrawBackgroundColor(playerid, dashboard[playerid], 255);
PlayerTextDrawFont(playerid, dashboard[playerid], 1);
PlayerTextDrawLetterSize(playerid, dashboard[playerid], 0.400000, 2.000000);
PlayerTextDrawColor(playerid, dashboard[playerid], 16777215);
PlayerTextDrawSetOutline(playerid, dashboard[playerid], 1);
PlayerTextDrawSetProportional(playerid, dashboard[playerid], 1);
PlayerTextDrawSetSelectable(playerid, dashboard[playerid], 0);
carhealth[playerid] = CreatePlayerTextDraw(playerid, 510.000000, 401.000000, "Health:");
PlayerTextDrawBackgroundColor(playerid, carhealth[playerid], 255);
PlayerTextDrawFont(playerid, carhealth[playerid], 1);
PlayerTextDrawLetterSize(playerid, carhealth[playerid], 0.319999, 1.000000);
PlayerTextDrawColor(playerid, carhealth[playerid], -1);
PlayerTextDrawSetOutline(playerid, carhealth[playerid], 1);
PlayerTextDrawSetProportional(playerid, carhealth[playerid], 1);
PlayerTextDrawUseBox(playerid, carhealth[playerid], 1);
PlayerTextDrawBoxColor(playerid, carhealth[playerid], -222);
PlayerTextDrawTextSize(playerid, carhealth[playerid], 660.000000, 0.000000);
PlayerTextDrawSetSelectable(playerid, carhealth[playerid], 0);