house position error
#1

even if i am in range of a house it still says im not,i don;t know why

for(new i = 1; i <= 105; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
{
HouseInfo[i][hType] = type;
mysql_format(SQL,str,sizeof(str), "UPDATE houses SET `Type`='%d' WHERE `ID`='%d'",type,HouseInfo[i][hID]);
mysql_tquery(SQL,str,"","");
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You aren't in range of any house");
return 1;
}
}
Reply
#2

Of course it will you are looping at all the the houses without breaking it...
Reply
#3

You need to break the loop with "break;" in order to stop looking for houses once you find it. Try this code.

PHP Code:
for(new 1<= 105i++) {
    if(
IsPlayerInRangeOfPoint(playerid5.0HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))    {
        
HouseInfo[i][hType] = type;
        
mysql_format(SQL,str,sizeof(str), "UPDATE houses SET `Type`='%d' WHERE `ID`='%d'",type,HouseInfo[i][hID]);
        
mysql_tquery(SQL,str,"","");
        break;
    } else {
        
SendClientMessage(playeridCOLOR_LIGHTRED"You aren't in range of any house");
        return 
1;
    }

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)