PDA

View Full Version : Function


GoldenLion
13/10/2016, 06:50 PM
Hi, the function below is supposed to get player's owned houses, but it returns 249 (the size of MAX_HOUSES). Here's the function:
GetHouseCount(playerid)
{
new count;

for (new i; i < MAX_HOUSES; i++) if (IsHouseOwner(playerid, i)) count++;

return count;
}

IsHouseOwner(playerid, houseid)
{
if (!strcmp(HouseInfo[houseid][HouseOwner], GetName(playerid))) return 1;
return 0;
}
What's up here?

EDIT: All I had to do was check if the house existed before checking if the player owns it...

Kaliber
13/10/2016, 07:22 PM
Do it like this:

IsHouseOwner(playerid, houseid)
{
return (HouseInfo[houseid][HouseOwner][0] != EOS && !strcmp(HouseInfo[houseid][HouseOwner], GetName(playerid)));
}

GoldenLion
13/10/2016, 07:26 PM
Do it like this:

IsHouseOwner(playerid, houseid)
{
return (HouseInfo[houseid][HouseOwner][0] != EOS && !strcmp(HouseInfo[houseid][HouseOwner], GetName(playerid)));
}
I appreciate your help, but I edited the thread half an hour ago saying that I found the issue lol.