Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:buyhouse(playerid, params[])
- {
- new pName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, pName, sizeof(pName));
- for(new h = 0; h < sizeof(HouseInfo); h++)
- {
- if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntranceX], HouseInfo[h][hEntranceY], HouseInfo[h][hEntranceZ]) && HouseInfo[h][hOwned] == 0)
- {
- if(GetLevel(playerid) < HouseInfo[h][hLevelbuy])
- {
- format(msg, sizeof(msg), "You must be level %d to purchase this house", HouseInfo[h][hLevelbuy]);
- HouseMSG(playerid, msg);
- return 1;
- }
- if(PlayerInfo[playerid][pHouseKey] != -1 && strcmp(pName, HouseInfo[PlayerInfo[playerid][pHouseKey]][hOwner], true) == 0) return HouseMSG(playerid, "You already own a house, type /sellhouse if you want to buy this one.");
- if(GetCash(playerid) < HouseInfo[h][hPrice]) return HouseMSG(playerid, "You don't have the cash for that !");
- PlayerInfo[playerid][pHouseKey] = h;
- PlayerInfo[playerid][pSpawnType] = 1;
- HouseInfo[h][hOwned] = 1;
- HouseInfo[h][hLocked] = 1;
- HouseInfo[h][hRentable] = 0;
- HouseInfo[h][hRentprice] = 0;
- HouseInfo[h][hCash] = 0;
- strmid(HouseInfo[h][hOwner], GetName(playerid), 0, strlen(GetName(playerid)), 255);
- GiveCash(playerid, -HouseInfo[h][hPrice]);
- HouseMSG(playerid, "Congratulations, on your new Purchase !");
- HouseMSG(playerid, "Type /househelp to review the new property help section !");
- UpdateHouseText(h);
- UpdateHouseInfo(h);
- format(query, sizeof(query), "UPDATE `users` SET `housekey` = %d WHERE `housekey` = %d", -1, h);
- SavePlayerStats(playerid);
- return 1;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement