31.12.2015, 07:51
I have recently posted a topic about the Phone Signal.
Well this topic is similar to that except the issue this time is that the GetClosestTower always pickups the tower which has the lowest ID. I have created a tower at San Fierro Medical Center, and there is a tower I have placed on Doherty's Skyscrapers. The phone signal on San Fierro Medical Center is two (indicating that the signal range still works at San Fierro Medical Center, however I wanted to extend the signal on the ocean so I have added another tower). I have noticed that even I am near towerID 3 (San Fierro's Medical Center Phone Tower) the phone signal remains at two bars, It suppose to be five bars, the towerID over Doherty's is two. So i am guessing that my GetClosestTower always returns the lowest towerID nearby the player, I wanted to change the way how it works instead of returning the lowest towerID nearby the player (if there are two or more towers nearby the player) how can I compare which tower is closer to the player?
GetClosestTower code
Well this topic is similar to that except the issue this time is that the GetClosestTower always pickups the tower which has the lowest ID. I have created a tower at San Fierro Medical Center, and there is a tower I have placed on Doherty's Skyscrapers. The phone signal on San Fierro Medical Center is two (indicating that the signal range still works at San Fierro Medical Center, however I wanted to extend the signal on the ocean so I have added another tower). I have noticed that even I am near towerID 3 (San Fierro's Medical Center Phone Tower) the phone signal remains at two bars, It suppose to be five bars, the towerID over Doherty's is two. So i am guessing that my GetClosestTower always returns the lowest towerID nearby the player, I wanted to change the way how it works instead of returning the lowest towerID nearby the player (if there are two or more towers nearby the player) how can I compare which tower is closer to the player?
GetClosestTower code
PHP код:
stock GetClosestTower(playerid)
{
new i=0;
new Float:_pos[3];
GetPlayerPos(playerid, _pos[0], _pos[1], _pos[2]);
while(i != MAX_TOWERS)
{
if(IsPlayerInRangeOfPoint(playerid, tInfo[i][tower_Signal], tInfo[i][tower_Pos][0], tInfo[i][tower_Pos][1], tInfo[i][tower_Pos][2]) && GetPlayerInterior(playerid) == tInfo[i][tower_Interior] && GetPlayerVirtualWorld(playerid) == tInfo[i][tower_World])
{
if(tInfo[i][tower_Pos][2]+800.0 >= _pos[2])
{ // Ignore this part, This code extends the signal range to the skies.
return i;
}
else
{
return -1;
}
}
i++;
}
return -1;
}