Function
#1

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...
Reply
#2

Do it like this:

PHP код:
IsHouseOwner(playeridhouseid)
{
    return (
HouseInfo[houseid][HouseOwner][0] != EOS && !strcmp(HouseInfo[houseid][HouseOwner], GetName(playerid)));

Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Do it like this:

PHP код:
IsHouseOwner(playeridhouseid)
{
    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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)