18.03.2015, 17:49
Sc0pion, we aren't going to create all the code for you, we're just going to give you options/solutions. You'll have to make it work with the features you have in your script.
You could either create a new list item which saves in the player's user file (Ex: aUserInfo[playerid][user_houses]), and check if they own 3 houses and prevent them from buying another one, or you could loop through the houses and preform some checks:
To prevent a player from buying another house if they already own 3 (implying you're using the code above):
However, I would recommend the first option, but it's up to you!
You could either create a new list item which saves in the player's user file (Ex: aUserInfo[playerid][user_houses]), and check if they own 3 houses and prevent them from buying another one, or you could loop through the houses and preform some checks:
pawn Код:
stock IsPlayerAllowedToBuyHouse(playerid)
{
new count, name[MAX_PLAYER_NAME], bool:state = false;
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
for(new i = 0; i < MAX_HOUSES; i ++)
{
if(strcmp(hInfo[i][Owner], name, true) == 0) count ++;
if(count == 3)
{
state = true;
break;
}
}
if(state == true) return false;
return true;
}
pawn Код:
if(!IsPlayerAllowedToBuyHouse(playerid)) return SendClientMessage(playerid, -1, "You can't purchase another house, sell one first!");