08.01.2015, 20:48
why you are looping inside the size of the "hInfo" array while you should loop inside houses such MAX_HOUSES as an example.
And why you are returning the size of the array if he was really in range of it, instead of returning a "true" value?
P.S , if you want this function to work as if the player's name same as owner's name or not, move return 1; under strcmp statement
And why you are returning the size of the array if he was really in range of it, instead of returning a "true" value?
pawn Код:
/* An example, let's put MAX_HOUSES 400 */
#define MAX_HOUSES 400
stock IsPlayerNearAnyHouse(playerid)
{
for(new i = 0; i < MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, hInfo[i][hPos][0], hInfo[i][hPos][1], hInfo[i][hPos][2]))
{
return 1; // returning one so it can work with "hid == 0" or "hid == 1"
// He's near the house already, we don't need to check if his name same as owner's name
if(strcmp(GetNameEx(playerid), hInfo[i][hOwner], true) == 0)
{
printf("%i", i);
}
}
}
return 0;