created houses loads only after server load mysql +rep
#8

ok replace it with this code, and see till how many CP this function works:
Код:
CMD:buyhouse(playerid, params[])
{
    print("CP: 1");
    for(new i = 1; i < MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[i][HouseExteriorX], hInfo[i][HouseExteriorY], hInfo[i][HouseExteriorZ]))
        {
            print("CP: 2");
            if(strmatch(hInfo[i][HouseOwner], "Nobody"))
            {
                print("CP: 3");
                if(pInfo[playerid][HouseKey] == 0)
                {
                    print("CP: 4");
                    if(pInfo[playerid][Money] >= hInfo[i][HousePrice])
                    {
                        print("CP: 6");
                        new string[256], Query[128];
                        format(string, sizeof(string), "Congratulations! You have purchased %s for $%d.", hInfo[i][HouseName], hInfo[i][HousePrice]);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                        format(hInfo[i][HouseOwner], 24, "%s", pName(playerid));
                        pInfo[playerid][Money] -= hInfo[i][HousePrice];
                        GivePlayerMoney(playerid, -hInfo[i][HousePrice]);
                        pInfo[playerid][HouseKey] = i;
                        SavePlayer(playerid);
                        mysql_format(mysql, Query, sizeof(Query), "UPDATE `Houses` SET `HouseOwner` = '%s' WHERE `hID` = %i", hInfo[i][HouseOwner], i);
                        mysql_query(mysql, Query);
                        mysql_free_result();
                        print("CP: 7");
                    }
                    else return SendClientMessage(playerid, COLOR_WHITE, "You don't have enough money to purchase this house.");
                }
                else return SendClientMessage(playerid, COLOR_WHITE, "You already own a house.");
            }
            else return SendClientMessage(playerid, COLOR_WHITE, "This house isn't for sale.");
        }
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)