Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- command(buyproperty, playerid, params[])
- {
- if(IsPlayerInRangeOfPoint(playerid, 6, 355.0121,171.4519,1025.7891))
- {
- new Usage[128], Address[128], string[128];
- if(sscanf(params, "sz", Usage, Address))
- {
- SendClientMessage(playerid, WHITE, "SYNTAX: /buyproperty [usage] [address]");
- SendClientMessage(playerid, GREY, "Usage: House, Business");
- }
- else
- {
- if(strcmp(Usage, "house", true) == 0)
- {
- if(Player[playerid][House] == 0)
- {
- for(new h = 0; h < sizeof(Houses); h++)
- {
- if(!strcmp(Houses[h][hAddress], Address, true))
- {
- if(strcmp(Houses[h][hOwner], "Nobody", true) == 0)
- {
- if(Houses[h][HousePrice] == -1)
- {
- SendClientMessage(playerid, WHITE, "This house isn't purchasable.");
- }
- else
- {
- if(Player[playerid][Hotel] == 0)
- {
- if(Player[playerid][Money] >= Houses[h][HousePrice])
- {
- Player[playerid][Money] -= Houses[h][HousePrice];
- GivePlayerMoney(playerid, -Houses[h][HousePrice]);
- format(Houses[h][hOwner], 128, "%s", GetName(playerid));
- format(string, sizeof(string), "You bought the house with address %s for $%d.", Address, Houses[h][HousePrice]);
- SendClientMessage(playerid, ADMINBLUE, string);
- Player[playerid][House] = h;
- DestroyDynamicPickup(Houses[h][HPickupID]);
- Houses[h][HPickupID] = CreateDynamicPickup(1318, 23, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ], 0, -1, -1, 150.0);
- SaveHouse(h);
- SavePlayerData(playerid);
- }
- else
- {
- SendClientMessage(playerid, WHITE, "You do not have enough money to purchase this house.");
- }
- }
- else
- {
- SCM(playerid, RED, "You already live in a hotel");
- }
- }
- }
- else
- {
- SendClientMessage(playerid, WHITE, "Sorry, this house is already bought!");
- }
- }
- else
- {
- SendClientMessage(playerid, WHITE, "Sorry, but this address is not correct.");
- }
- }
- }
- else
- {
- SendClientMessage(playerid, WHITE, "You already have a house, type /sellproperty house.");
- }
- }
- }
- }
- else
- {
- SCM(playerid, WHITE, "You are not at the property office");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment