21.12.2015, 10:38
Use this code :
Your code wouldn't work as expected because if player is in range of tInfo[tower][tower_Signal] then he is also in range of tInfo[tower][tower_Signal] / any_natural_number because
x > x/natural_number.
PHP код:
new tower = GetClosestTower(playerid);
if(tower == -1) // No Signal
{
PlayerTextDrawSetString(playerid, Textdraw2, "~w~Phone Signal - ~r~I I I I I");
}
else
{
new Float:dis = GetPlayerDistanceFromPoint(playerid, tInfo[tower][tower_Pos][0], tInfo[tower][tower_Pos][1], tInfo[tower][tower_Pos][2]);
if(dis > tInfo[tower][tower_Signal] / 5 ) // Bar One
{
PlayerTextDrawSetString(playerid, Textdraw2, "~w~Phone Signal - ~g~I ~r~I I I I");
}
else if(dis > tInfo[tower][tower_Signal] / 25 ) // Bar Two
{
PlayerTextDrawSetString(playerid, Textdraw2, "~w~Phone Signal - ~g~I I ~r~I I I");
}
else if(dis > tInfo[tower][tower_Signal] / 50) // Bar Three
{
PlayerTextDrawSetString(playerid, Textdraw2, "~w~Phone Signal - ~g~I I I ~r~I I");
}
else if(dis > tInfo[tower][tower_Signal] / 100)
{
PlayerTextDrawSetString(playerid, Textdraw2, "~w~Phone Signal - ~g~I I I I ~r~I"); // bar four
}
else
{
PlayerTextDrawSetString(playerid, Textdraw2, "~w~Phone Signal - ~g~I I I I I"); // bar five
}
}
x > x/natural_number.