PDA

View Full Version : Speedo on textdraw help please


KaliKs
09/03/2014, 09:30 AM
Hey guys i got small problem about this speedo i have created it but if i go in game under the seatbelt it always shows its off when its on...

Timer:SpeedoCheck[1000]()
{
foreach(Player, i) {
if(GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerInfo[i][pSpeedoOn] == 1)
{
new veh = GetPlayerVehicleID(i);
new Float:Speed = GetVehicleSpeed(veh, 0);
new string[128];

format(string,sizeof(string),"%d MPH",floatround(Speed/1.609));
PlayerTextDrawSetString(i,Speedo6[i],string);
format(string,sizeof(string),"%.2f Gal",VehicleFuel[veh]);
PlayerTextDrawSetString(i,Speedo7[i],string);
switch(UsingSB{i})
{
case 0:
{
PlayerTextDrawSetString(i,Speedo8[i],"Off");
}
default:
{
PlayerTextDrawSetString(i,Speedo8[i],"On");
}
}
}
}
return 1;
}

Aerotactics
09/03/2014, 09:44 AM
Why do you use a switch?

if(UsingSB{i})
{
PlayerTextDrawSetString(i,Speedo8[i],"Off");
return 1;
}
else
{
PlayerTextDrawSetString(i,Speedo8[i],"On");
return 1;
}

PT
09/03/2014, 10:17 AM
Timer:SpeedoCheck[1000]()
{
foreach(Player, i)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerInfo[i][pSpeedoOn] == 1)
{
new Float:Speed = GetVehicleSpeed(veh, 0),
string[128];

format(string,sizeof(string),"%d MPH",floatround(Speed/1.609));
PlayerTextDrawSetString(i,Speedo6[i],string);
format(string,sizeof(string),"%.2f Gal",VehicleFuel[GetPlayerVehicleID(i)]);
PlayerTextDrawSetString(i,Speedo7[i],string);
format(string,sizeof(string),"%s", UsingSB{i} == 0 ? ("Off") : ("On"));
PlayerTextDrawSetString(i,Speedo8[i], string);
}
}
return 1;
}

KaliKs
09/03/2014, 11:16 AM
@PT it gives me error here

new Float:Speed = GetVehicleSpeed(veh, 0),

veh

PT
09/03/2014, 11:56 AM
Timer:SpeedoCheck[1000]()
{
foreach(Player, i)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER && PlayerInfo[i][pSpeedoOn] == 1)
{
new Float:Speed = GetVehicleSpeed(GetPlayerVehicleID(i), 0),
string[128];

format(string,sizeof(string),"%d MPH",floatround(Speed/1.609));
PlayerTextDrawSetString(i,Speedo6[i],string);
format(string,sizeof(string),"%.2f Gal",VehicleFuel[GetPlayerVehicleID(i)]);
PlayerTextDrawSetString(i,Speedo7[i],string);
format(string,sizeof(string),"%s", UsingSB{i} == 0 ? ("Off") : ("On"));
PlayerTextDrawSetString(i,Speedo8[i], string);
}
}
return 1;
}

oh sorry fixed.