Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // on top
- #define MAX_HOUSES 1000
- new SpawnedHouses
- enum HouseData
- {
- hInteriorID,
- Float: hInteriorX,
- Float: hInteriorY,
- Float: hInteriorZ,
- HousePrice,
- hExteriorID,
- Float: hExteriorX,
- Float: hExteriorY,
- HouseCocaine,
- HousePot,
- HouseMaterials,
- WeaponSlot1,
- WeaponSlot2,
- WeaponSlot3,
- WeaponSlot1Ammo,
- WeaponSlot2Ammo,
- WeaponSlot3Ammo,
- Float: hExteriorZ,
- VaultMoney,
- HPickupID,
- hOwner[255],
- LockStatus,
- };
- enum PlayerStatistics
- {
- HouseInterior,
- HouseExterior,
- House,
- Float: hExtX,
- Float: hExtY,
- Float: hExtZ,
- Float: hIntX,
- Float: hIntY,
- Float: hIntZ,
- hIntID,
- hExtID,
- InHouse,
- };
- new Houses[MAX_HOUSES][HouseData];
- new Player[MAX_PLAYERS][PlayerStatistics];
- // on gamemodeinit
- InitHouses();
- stock InitHouses()
- {
- new FileName[128];
- for(new i = 0; i < MAX_HOUSES; i++)
- {
- format(FileName, sizeof(FileName), "Houses/House_%d.ini", i);
- if(fexist(FileName))
- {
- Houses[i][hInteriorID] = dini_Int(FileName, "InteriorID");
- Houses[i][hInteriorX] = dini_Float(FileName, "InteriorX");
- Houses[i][hInteriorY] = dini_Float(FileName, "InteriorY");
- Houses[i][hInteriorZ] = dini_Float(FileName, "InteriorZ");
- Houses[i][HousePrice] = dini_Int(FileName, "HousePrice");
- Houses[i][hExteriorID] = dini_Int(FileName, "ExteriorID");
- Houses[i][hExteriorX] = dini_Float(FileName, "ExteriorX");
- Houses[i][hExteriorY] = dini_Float(FileName, "ExteriorY");
- Houses[i][hExteriorZ] = dini_Float(FileName, "ExteriorZ");
- Houses[i][VaultMoney] = dini_Int(FileName, "VaultMoney");
- Houses[i][HouseCocaine] = dini_Int(FileName, "HouseCocaine");
- Houses[i][HousePot] = dini_Int(FileName, "HousePot");
- Houses[i][HouseMaterials] = dini_Int(FileName, "HouseMaterials");
- Houses[i][hOwner] = dini_Get(FileName, "Owner");
- Houses[i][LockStatus] = dini_Int(FileName, "LockStatus");
- Houses[i][WeaponSlot1] = dini_Int(FileName, "WeaponSlot1");
- Houses[i][WeaponSlot2] = dini_Int(FileName, "WeaponSlot2");
- Houses[i][WeaponSlot3] = dini_Int(FileName, "WeaponSlot3");
- if(strcmp(Houses[i][hOwner], "Nobody", true) == 0)
- {
- Houses[i][LockStatus] = 0;
- Houses[i][HPickupID] = CreateDynamicPickup(1273, 23, Houses[i][hExteriorX], Houses[i][hExteriorY], Houses[i][hExteriorZ], 0, -1, -1, 150.0);
- }
- else
- {
- Houses[i][HPickupID] = CreateDynamicPickup(1318, 23, Houses[i][hExteriorX], Houses[i][hExteriorY], Houses[i][hExteriorZ], 0, -1, -1, 150.0);
- }
- printf("[system] House %d spawned.", i);
- SpawnedHouses++;
- }
- }
- return 1;
- }
- command(createhouse, playerid, params[])
- {
- new Usage[128], string[128];
- if(sscanf(params, "z", Usage))
- {
- if(Player[playerid][AdminLevel] >= 6)
- {
- SendClientMessage(playerid, WHITE, "SYNTAX: /createhouse [usage]");
- SendClientMessage(playerid, GREY, "Usage: Interior, Exterior or Complete.");
- }
- }
- else
- {
- if(Player[playerid][AdminLevel] >= 6)
- {
- if(strcmp(Usage, "exterior", true) == 0)
- {
- Player[playerid][HouseExterior]++;
- Player[playerid][hExtID] = GetPlayerInterior(playerid);
- GetPlayerPos(playerid, Player[playerid][hExtX], Player[playerid][hExtY], Player[playerid][hExtZ]);
- format(string, sizeof(string), "Exterior set! (X: %f, Y: %f, Z: %f).", Player[playerid][hExtX], Player[playerid][hExtY], Player[playerid][hExtZ]);
- SendClientMessage(playerid, WHITE, string);
- }
- if(strcmp(Usage, "interior", true) == 0)
- {
- Player[playerid][HouseInterior]++;
- Player[playerid][hIntID] = GetPlayerInterior(playerid);
- GetPlayerPos(playerid, Player[playerid][hIntX], Player[playerid][hIntY], Player[playerid][hIntZ]);
- format(string, sizeof(string), "Interior set! (X: %f, Y: %f, Z: %f).", Player[playerid][hIntX], Player[playerid][hIntY], Player[playerid][hIntZ]);
- SendClientMessage(playerid, WHITE, string);
- }
- if(strcmp(Usage, "complete", true) == 0)
- {
- if(Player[playerid][HouseInterior] > 0 || Player[playerid][HouseExterior] > 0)
- {
- new NewHouseID = SpawnedHouses+1;
- if(NewHouseID >= MAX_HOUSES)
- {
- SendClientMessage(playerid, WHITE, "Too many houses are currently spawned!");
- }
- else
- {
- format(string, sizeof(string), "Houses/House_%d.ini", NewHouseID);
- if(!fexist(string))
- {
- Houses[NewHouseID][hInteriorID] = Player[playerid][hIntID];
- Houses[NewHouseID][hExteriorID] = Player[playerid][hExtID];
- Houses[NewHouseID][hInteriorX] = Player[playerid][hIntX];
- Houses[NewHouseID][hInteriorY] = Player[playerid][hIntY];
- Houses[NewHouseID][hInteriorZ] = Player[playerid][hIntZ];
- Houses[NewHouseID][hExteriorX] = Player[playerid][hExtX];
- Houses[NewHouseID][hExteriorY] = Player[playerid][hExtY];
- Houses[NewHouseID][hExteriorZ] = Player[playerid][hExtZ];
- format(Houses[NewHouseID][hOwner], 255, "Nobody");
- Houses[NewHouseID][LockStatus] = 0;
- Houses[NewHouseID][HPickupID] = CreateDynamicPickup(1273, 23, Houses[NewHouseID][hExteriorX], Houses[NewHouseID][hExteriorY], Houses[NewHouseID][hExteriorZ], 0, -1, -1, 150.0);
- dini_Create(string);
- dini_IntSet(string, "InteriorID", Houses[NewHouseID][hInteriorID]);
- dini_FloatSet(string, "InteriorX", Houses[NewHouseID][hInteriorX]);
- dini_FloatSet(string, "InteriorY", Houses[NewHouseID][hInteriorY]);
- dini_FloatSet(string, "InteriorZ", Houses[NewHouseID][hInteriorZ]);
- dini_IntSet(string, "HousePrice", 0);
- dini_IntSet(string, "ExteriorID", 0);
- dini_FloatSet(string, "ExteriorX", Houses[NewHouseID][hExteriorX]);
- dini_FloatSet(string, "ExteriorY", Houses[NewHouseID][hExteriorY]);
- dini_FloatSet(string, "ExteriorZ", Houses[NewHouseID][hExteriorZ]);
- dini_IntSet(string, "VaultMoney", -1);
- dini_IntSet(string, "HouseCocaine", -1);
- dini_IntSet(string, "HousePot", -1);
- dini_IntSet(string, "HouseMaterials", -1);
- dini_Set(string, "Owner", "Nobody");
- dini_IntSet(string, "LockStatus", Houses[NewHouseID][LockStatus]);
- Player[playerid][HouseExterior]--;
- Player[playerid][HouseInterior]--;
- SpawnedHouses++;
- SendClientMessage(playerid, NICESKY, "Successfully created house!");
- SetPlayerInterior(playerid, Houses[NewHouseID][hExteriorID]);
- SetPlayerPos(playerid, Houses[NewHouseID][hExteriorX], Houses[NewHouseID][hExteriorY], Houses[NewHouseID][hExteriorZ]);
- }
- else
- {
- SendClientMessage(playerid, WHITE, "Error: File already exists!");
- }
- }
- }
- else
- {
- SendClientMessage(playerid, WHITE, "You must select an exterior and an interior first!");
- }
- }
- }
- }
- return 1;
- }
- command(buyhouse, playerid, params[])
- {
- #pragma unused params
- new string[128];
- if(Player[playerid][House] == 0)
- {
- for(new h = 0; h < sizeof(Houses); h++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 5, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ]))
- {
- 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][Money] >= Houses[h][HousePrice])
- {
- Player[playerid][Money] -= Houses[h][HousePrice];
- format(Houses[h][hOwner], 128, "%s", GetName(playerid));
- format(string, sizeof(string), "Congratulations! You are now the owner of this property (House %d)", h);
- SendClientMessage(playerid, ANNOUNCEMENT, 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);
- SendClientMessage(playerid, WHITE, "By purchasing a house, you've unlocked a bunch of new commands; use /help to find them out!");
- }
- else
- {
- SendClientMessage(playerid, WHITE, "You do not have enough money to purchase this house.");
- }
- }
- }
- else
- {
- SendClientMessage(playerid, WHITE, "Sorry, this house is not available!");
- }
- }
- }
- }
- else
- {
- SendClientMessage(playerid, WHITE, "You already have a house, type /abandonhouse.");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement