Need small help with Buying house
#6

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:

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;
}
To prevent a player from buying another house if they already own 3 (implying you're using the code above):
pawn Код:
if(!IsPlayerAllowedToBuyHouse(playerid)) return SendClientMessage(playerid, -1, "You can't purchase another house, sell one first!");
However, I would recommend the first option, but it's up to you!
Reply


Messages In This Thread
Need small help with Buying house - by Sc0pion - 18.03.2015, 15:30
Re: Need small help with Buying house - by CalvinC - 18.03.2015, 15:32
Re: Need small help with Buying house - by iFiras - 18.03.2015, 15:37
Re: Need small help with Buying house - by Sc0pion - 18.03.2015, 17:18
Re: Need small help with Buying house - by Sc0pion - 18.03.2015, 17:45
Re: Need small help with Buying house - by SickAttack - 18.03.2015, 17:49
Re: Need small help with Buying house - by iFiras - 18.03.2015, 17:51
Re: Need small help with Buying house - by CalvinC - 18.03.2015, 17:59
Re: Need small help with Buying house - by Sc0pion - 18.03.2015, 19:26
Re: Need small help with Buying house - by SickAttack - 18.03.2015, 20:17

Forum Jump:


Users browsing this thread: 1 Guest(s)