Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Sasi-Houses (Sasinosoft Houses), Simple House-Store System, Very Roleplaying.
- *
- * AUTHOR: [GF]Sasino97
- */
- #include <a_samp> //THANKS TO THE SA-MP TEAM
- #include <SII> //THANKS TO [DRuG]Slick FOR "Slick's INI Include (SII)"
- #define FILTERSCRIPT
- #define INVALID_HOUSE_ID -255 //Use a negative number here (Default -255)
- #define MAX_HOUSES 100 //Max houses
- #define MAX_BUSINESSES 100 //Max stores
- #define HOUSE_FILE "SasiHouses/Houses/HouseID%d.ini" //If you want you can change the tree
- #define BIZ_FILE "SasiHouses/Stores/BizID%d.ini" //If you want you can change the tree
- #define PRINT_HOUSES //This will print the log, (Write false or comment to disable)
- #define KEY_ENTER_PROPERTY KEY_SUBMISSION //Use the key you want (Default Is Mouse Cen).
- #define DIALOG_FORSALE_HOUSE 1500
- #define DIALOG_OTHERS_HOUSE 1501
- #define DIALOG_MY_HOUSE 1502
- #define DIALOG_SELL_HOUSE 1503
- #define DIALOG_FORSALE_STORE 1504
- #define DIALOG_OTHERS_STORE 1505
- #define DIALOG_MY_STORE 1506
- #define DIALOG_SELL_STORE 1507
- #define DIALOG_RENAME_STORE 1508
- new HousePickup[MAX_HOUSES];
- new BizPickup[MAX_BUSINESSES];
- enum HouseInfo
- {
- Name[24],
- Cost,
- Sell,
- Interior,
- VirtualWorld,
- Locked,
- Float:InteriorX,
- Float:InteriorY,
- Float:InteriorZ,
- Float:ExteriorX,
- Float:ExteriorY,
- Float:ExteriorZ,
- }
- new hInfo[MAX_HOUSES][HouseInfo];
- enum BusinessInfo
- {
- bName[24],
- bTitle[51],
- bCost,
- bSell,
- bInterior,
- bVirtualWorld,
- bLocked,
- Float:bInteriorX,
- Float:bInteriorY,
- Float:bInteriorZ,
- Float:bExteriorX,
- Float:bExteriorY,
- Float:bExteriorZ,
- }
- new bInfo[MAX_BUSINESSES][BusinessInfo];
- public OnFilterScriptInit()
- {
- print("\n-------------FILTERSCRIPT----------------- ");
- print(" Sasinosoft Houses, Simple House/Store System");
- print(" By [GF]Sasino97 Loaded. ");
- print("------------------------------------------\n ");
- //All Houses Here.
- // ID, extX, extY, extZ, intX, intY, intZ, price, sell, int, vw
- CreateHouse(0, 2140.7082, -1176.7008, 23.9921, 234.6087, 1187.8195, 1080.2578, 1000, 900, 3, 0);
- //All Stores Here.
- // ID Titolo Default extX extY extZ intX intY intz buy sell int vw
- CreateBusiness(0, "Ammu Nation" ,2145.7082, -1176.7008, 23.9921, 285.8361, -39.0166, 1001.5156, 1500, 500, 1, 0);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_FORSALE_HOUSE:
- {
- if(!response) return 1;
- if(GetPlayerMoney(playerid) < hInfo[GetHouseID(playerid)][Cost]) return ShowNoMoneyMessage(playerid);
- BuyHouse(playerid, GetHouseID(playerid));
- return 1;
- }
- case DIALOG_FORSALE_STORE:
- {
- if(!response) return 1;
- if(GetPlayerMoney(playerid) < bInfo[GetBizID(playerid)][bCost]) return ShowNoMoneyMessage(playerid);
- BuyBusiness(playerid, GetBizID(playerid));
- return 1;
- }
- case DIALOG_OTHERS_HOUSE:
- {
- if(!response) return 1;
- if(hInfo[GetHouseID(playerid)][Locked] == 1) return ShowLockedHouseMessage(playerid);
- EnterHouse(playerid, GetHouseID(playerid));
- return 1;
- }
- case DIALOG_OTHERS_STORE:
- {
- if(!response) return 1;
- if(bInfo[GetBizID(playerid)][bLocked] == 1) return ShowLockedStoreMessage(playerid);
- EnterBusiness(playerid, GetBizID(playerid));
- return 1;
- }
- case DIALOG_MY_HOUSE:
- {
- if(!response) return 1;
- switch(listitem)
- {
- case 0:
- {
- if(hInfo[GetHouseID(playerid)][Locked] == 1) return ShowLockedHouseMessage(playerid);
- EnterHouse(playerid, GetHouseID(playerid));
- return 1;
- }
- case 1:
- {
- if(hInfo[GetHouseID(playerid)][Locked] == 1)
- {
- hInfo[GetHouseID(playerid)][Locked] = 0;
- UnlockYourHouseMessage(playerid);
- }
- else
- {
- hInfo[GetHouseID(playerid)][Locked] = 1;
- LockYourHouseMessage(playerid);
- }
- return 1;
- }
- case 2:
- {
- new string[101];
- format(string,sizeof(string), "Do you really want to sell your house for $%d?", hInfo[GetHouseID(playerid)][Sell]);
- ShowPlayerDialog(playerid, DIALOG_SELL_HOUSE, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND", string, "Yes", "No");
- return 1;
- }
- }
- return 1;
- }
- case DIALOG_MY_STORE:
- {
- if(!response) return 1;
- switch(listitem)
- {
- case 0:
- {
- if(bInfo[GetBizID(playerid)][bLocked] == 1) return ShowLockedStoreMessage(playerid);
- EnterBusiness(playerid, GetBizID(playerid));
- return 1;
- }
- case 1:
- {
- if(bInfo[GetBizID(playerid)][bLocked] == 1)
- {
- bInfo[GetBizID(playerid)][bLocked] = 0;
- UnlockYourStoreMessage(playerid);
- }
- else
- {
- bInfo[GetBizID(playerid)][bLocked] = 1;
- LockYourStoreMessage(playerid);
- }
- return 1;
- }
- case 2:
- {
- ShowPlayerDialog(playerid, DIALOG_RENAME_STORE,DIALOG_STYLE_INPUT, "Write a new name for your store","You can make colors using {RRGGBB} codes", "OK", "Cancel");
- return 1;
- }
- case 3:
- {
- new string[256];
- format(string,sizeof(string), "Do you really want to sell your store for $%d?", bInfo[GetBizID(playerid)][bSell]);
- ShowPlayerDialog(playerid, DIALOG_SELL_STORE, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND", string, "Yes", "No");
- return 1;
- }
- }
- return 1;
- }
- case DIALOG_SELL_HOUSE:
- {
- if(!response) return 1;
- SellHouse(playerid, GetHouseID(playerid));
- return 1;
- }
- case DIALOG_SELL_STORE:
- {
- if(!response) return 1;
- SellBusiness(playerid, GetBizID(playerid));
- return 1;
- }
- case DIALOG_RENAME_STORE:
- {
- if(!response) return 1;
- if(strlen(inputtext) >= 51)
- {
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{FF0000}ERROR", "The max lenght is 50 characters", "OK", "");
- return 1;
- }
- new string[256];
- format(bInfo[GetBizID(playerid)][bTitle],51, inputtext);
- format(string, 256, BIZ_FILE, GetBizID(playerid));
- INI_Open(string);
- INI_WriteString("Title",bInfo[GetBizID(playerid)][bTitle]);
- INI_Save();
- INI_Close();
- return 1;
- }
- }
- return 0;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys & KEY_ENTER_PROPERTY)
- {
- for(new i=0; i<MAX_HOUSES; i++)
- {
- if(IsPlayerNearPoint(2.0, playerid, hInfo[i][InteriorX], hInfo[i][InteriorY], hInfo[i][InteriorZ]))
- {
- ExitHouse(playerid, i);
- }
- }
- for(new i=0; i<MAX_BUSINESSES; i++)
- {
- if(IsPlayerNearPoint(2.0, playerid, bInfo[i][bInteriorX], bInfo[i][bInteriorY], bInfo[i][bInteriorZ]))
- {
- ExitBusiness(playerid, i);
- }
- }
- if(GetHouseID(playerid) != INVALID_HOUSE_ID)
- {
- OpenHouseDialog(playerid, GetHouseID(playerid));
- return 1;
- }
- else if(GetBizID(playerid) != INVALID_HOUSE_ID)
- {
- OpenBusinessDialog(playerid, GetBizID(playerid));
- return 1;
- }
- }
- return 1;
- }
- /*
- CreateHouse
- Function: Creates a house.
- To use in: OnFilterScriptInit
- Arguments:
- -houseid: The ID of the house. Don't create 2 houses with the same ID.
- -eX, eY, eZ: La posizione esteriore della casa (L'entrata)
- -iX, iY, iZ: La posizione interiore della casa (L'uscita)
- -BuyPrice: Il costo della casa
- -SellPrice: La quantità che viene data al proprietario quando la rivende
- -INT: L' ID dell'interior della casa
- -VW: Il mondo virtuale della casa (Usa 2 VW diversi se vuoi avere 2 case con lo stesso interior)
- Returns:
- -true(1): Quando la casa esisteva gia, ed è stata caricata
- -null(-1): Quando la casa non esisteva ed è stata creata
- -false(0): Quando è impossibile caricare o creare
- */
- stock CreateHouse(houseid, Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, BuyPrice, SellPrice, INT, VW)
- {
- new housefile[51];
- format(housefile, sizeof(housefile), HOUSE_FILE, houseid);
- if(!INI_Exist(housefile)) //Se il file non esiste:
- {
- INI_Open(housefile);
- format(hInfo[houseid][Name], 24, "ForSale");
- INI_WriteString("Name", "ForSale");
- hInfo[houseid][Cost] = BuyPrice;
- INI_WriteInt("Cost", BuyPrice);
- hInfo[houseid][Sell] = SellPrice;
- INI_WriteInt("Sell", SellPrice);
- hInfo[houseid][Interior] = INT;
- INI_WriteInt("Interior", INT);
- hInfo[houseid][VirtualWorld] = VW;
- INI_WriteInt("VirtualWorld", VW);
- hInfo[houseid][Locked] = 1;
- INI_WriteInt("Locked", 1);
- hInfo[houseid][InteriorX] = iX;
- hInfo[houseid][InteriorY] = iY;
- hInfo[houseid][InteriorZ] = iZ;
- INI_WriteFloat("InteriorX", iX);
- INI_WriteFloat("InteriorY", iY);
- INI_WriteFloat("InteriorZ", iZ);
- hInfo[houseid][ExteriorX] = eX;
- hInfo[houseid][ExteriorY] = eY;
- hInfo[houseid][ExteriorZ] = eZ;
- INI_WriteFloat("ExteriorX", eX);
- INI_WriteFloat("ExteriorY", eY);
- INI_WriteFloat("ExteriorZ", eZ);
- HousePickup[houseid] = CreatePickup(1273, 23, eX, eY, eZ);
- Create3DTextLabel("Use mouse cen to open the menu", 0x33AA33AA, eX, eY, eZ+1, 20, 0, 1);
- Create3DTextLabel("Use mouse cen to exit the house", 0x33AA33AA, iX, iY, iZ+1, 20, VW, 1);
- #if defined PRINT_HOUSES
- print("------------Nuova Casa Creata------------");
- printf("- Houseid: %d", houseid);
- printf("- Costo: %d", BuyPrice);
- printf("- Ricavo Vendita: %d", SellPrice);
- printf("- Interior: %d", INT);
- printf("- Virtual World: %d", VW);
- print("-----------------------------------------");
- #endif
- INI_Save();
- INI_Close();
- return -1;
- }
- else if(INI_Exist(housefile))//altrimenti, se esiste il file
- {
- new destination[24];
- INI_Open(housefile);
- INI_ReadString(destination, "Name");
- format(hInfo[houseid][Name], 24, destination);
- hInfo[houseid][Locked] = INI_ReadInt("Locked");
- INI_Close();
- hInfo[houseid][Cost] = BuyPrice;
- hInfo[houseid][Sell] = SellPrice;
- hInfo[houseid][Interior] = INT;
- hInfo[houseid][VirtualWorld] = VW;
- hInfo[houseid][InteriorX] = iX;
- hInfo[houseid][InteriorY] = iY;
- hInfo[houseid][InteriorZ] = iZ;
- hInfo[houseid][ExteriorX] = eX;
- hInfo[houseid][ExteriorY] = eY;
- hInfo[houseid][ExteriorZ] = eZ;
- if(strcmp(hInfo[houseid][Name],"ForSale",true) == 0)
- {
- HousePickup[houseid] = CreatePickup(1273, 23, eX, eY, eZ);
- }
- else
- {
- HousePickup[houseid] = CreatePickup(1272, 23, eX, eY, eZ);
- }
- Create3DTextLabel("Use mouse cen to open the menu", 0x33AA33AA, eX, eY, eZ+1, 20, 0, 1);
- Create3DTextLabel("Use mouse cen to exit the house", 0x33AA33AA, iX, iY, iZ+1, 20, VW, 1);
- #if defined PRINT_HOUSES
- print("------------Casa Esistente Caricata------------");
- printf("- Houseid: %d", houseid);
- printf("- Costo: %d", BuyPrice);
- printf("- Ricavo Vendita: %d", SellPrice);
- printf("- Interior: %d", INT);
- printf("- Virtual World: %d", VW);
- print("----------------------------------------------");
- #endif
- return 1;
- }
- print("E Impossibile Creare Una Casa. Controlla Di Avere Le Seguenti Cartelle In Scriptfiles:");
- print("SasiHouses ------>");
- print(" Houses");
- print(" Stores");
- return 0;
- }
- /*
- CreateBusiness
- Funzione: Crea Un Negozio.
- Da Usare Con: OnFilterScriptInit
- Parametri:
- -bizid: L'ID del negozio. Non creare 2 negozi con lo stesso ID.
- -defaultname: Il nome iniziale del negozio.
- -eX, eY, eZ: La posizione esteriore del negozio (L'entrata)
- -iX, iY, iZ: La posizione interiore del negozio (L'uscita)
- -BuyPrice: Il costo del negozio
- -SellPrice: La quantità che viene data al proprietario quando lo rivende
- -INT: L'ID dell'interior del negozio
- -VW: Il mondo virtuale del negozio (Usa 2 VW diversi se vuoi avere 2 negozi con lo stesso interior)
- Riporta:
- -true(1): Quando il negozio esisteva gia, ed è stata caricata
- -null(-1): Quando il negozio non esisteva ed è stata creata
- -false(0): Quando è impossibile caricare o creare
- */
- stock CreateBusiness(bizid, defaultname[51], Float:eX, Float:eY, Float:eZ, Float:iX, Float:iY, Float:iZ, BuyPrice, SellPrice, INT, VW)
- {
- new bizfile[51];
- format(bizfile, sizeof(bizfile), BIZ_FILE, bizid);
- if(!INI_Exist(bizfile))
- {
- INI_Open(bizfile);
- format(bInfo[bizid][bName], 24, "ForSale");
- INI_WriteString("Owner", "ForSale");
- format(bInfo[bizid][bTitle], 51, defaultname);
- INI_WriteString("Title", defaultname);
- bInfo[bizid][bCost] = BuyPrice;
- INI_WriteInt("Cost", BuyPrice);
- bInfo[bizid][bSell] = SellPrice;
- INI_WriteInt("Sell", SellPrice);
- bInfo[bizid][bInterior] = INT;
- INI_WriteInt("Interior", INT);
- bInfo[bizid][bVirtualWorld] = VW;
- INI_WriteInt("VirtualWorld", VW);
- bInfo[bizid][bLocked] = 1;
- INI_WriteInt("Locked", 1);
- bInfo[bizid][bInteriorX] = iX;
- bInfo[bizid][bInteriorY] = iY;
- bInfo[bizid][bInteriorZ] = iZ;
- INI_WriteFloat("bInteriorX", iX);
- INI_WriteFloat("bInteriorY", iY);
- INI_WriteFloat("bInteriorZ", iZ);
- bInfo[bizid][bExteriorX] = eX;
- bInfo[bizid][bExteriorY] = eY;
- bInfo[bizid][bExteriorZ] = eZ;
- INI_WriteFloat("ExteriorX", eX);
- INI_WriteFloat("ExteriorY", eY);
- INI_WriteFloat("ExteriorZ", eZ);
- BizPickup[bizid] = CreatePickup(1318, 23, eX, eY, eZ);
- Create3DTextLabel("Use mouse cen to open the menu", 0x33AA33AA, eX, eY, eZ+1, 20, 0, 1);
- Create3DTextLabel("Use mouse cen to exit the store", 0x33AA33AA, iX, iY, iZ+1, 20, VW, 1);
- #if defined PRINT_HOUSES
- print("------------New Business Created------------");
- printf("- Business ID: %d", bizid);
- printf("- Buy Cost: %d", BuyPrice);
- printf("- Sell Cost: %d", SellPrice);
- printf("- Interior: %d", INT);
- printf("- Virtual World: %d", VW);
- print("--------------------------------------------");
- #endif
- INI_Save();
- INI_Close();
- return -1;
- }
- else if(INI_Exist(bizfile))
- {
- new destination[24];
- new dest2[24];
- INI_Open(bizfile);
- INI_ReadString(destination, "Name");
- INI_ReadString(dest2, "Title");
- format(bInfo[bizid][bName], 24, destination);
- format(bInfo[bizid][bTitle], 51, dest2);
- bInfo[bizid][bLocked] = INI_ReadInt("Locked");
- INI_Close();
- bInfo[bizid][bCost] = BuyPrice;
- bInfo[bizid][bSell] = SellPrice;
- bInfo[bizid][bInterior] = INT;
- bInfo[bizid][bVirtualWorld] = VW;
- bInfo[bizid][bInteriorX] = iX;
- bInfo[bizid][bInteriorY] = iY;
- bInfo[bizid][bInteriorZ] = iZ;
- bInfo[bizid][bExteriorX] = eX;
- bInfo[bizid][bExteriorY] = eY;
- bInfo[bizid][bExteriorZ] = eZ;
- BizPickup[bizid] = CreatePickup(1318, 23, eX, eY, eZ);
- Create3DTextLabel("Use mouse cen to open the menu", 0x33AA33AA, eX, eY, eZ+1, 20, 0, 1);
- Create3DTextLabel("Use mouse cen to exit the store", 0x33AA33AA, iX, iY, iZ+1, 20, VW, 1);
- #if defined PRINT_HOUSES
- print("------------Business Loaded------------");
- printf("- Business ID: %d", bizid);
- printf("- Buy Cost: %d", BuyPrice);
- printf("- Sell Cost: %d", SellPrice);
- printf("- Interior: %d", INT);
- printf("- Virtual World: %d", VW);
- print("---------------------------------------");
- #endif
- return 1;
- }
- print("E Impossibile Creare Un Negozio. Controlla Di Avere Le Seguenti Cartelle In Scriptfiles:");
- print("SasiHouses ------>");
- print(" Houses");
- print(" Stores");
- return 0;
- }
- /*
- OpenHouseDialog
- Function: Shows the dialog.
- Parameters:
- -playerid: The ID of the player.
- -houseid: The ID of the house.
- Returns:
- -true(1): When the house is for sale.
- -null(-1): When the house is bought.
- -false(0): When the house is bought and playerid is the owner.
- */
- stock OpenHouseDialog(playerid, houseid)
- {
- if(strcmp(hInfo[houseid][Name], "ForSale",true) == 0)
- {
- new string[180];
- if(GetPlayerMoney(playerid) >= hInfo[houseid][Cost]) { format(string,sizeof(string),"{33AA33}Buy this house for $%d", hInfo[houseid][Cost]); }
- else { format(string,sizeof(string),"{FF0000}Buy this house for $%d", hInfo[houseid][Cost]); }
- ShowPlayerDialog(playerid, DIALOG_FORSALE_HOUSE, DIALOG_STYLE_LIST, "{33AA33}For Sale!", string, "OK", "Close");
- return 1;
- }
- else
- {
- new string2[180];
- new name[24];
- GetPlayerName(playerid,name,sizeof(name));
- if(strcmp(hInfo[houseid][Name], name, true) == 0)
- {
- ShowPlayerDialog(playerid, DIALOG_MY_HOUSE,DIALOG_STYLE_LIST, "{33AA33}Welcome back to your house", "{33AA33}Enter in your house\n{33AA33}Open/Close the door\n{33AA33}Sell your house", "OK", "Close");
- return 0;
- }
- else
- {
- if(hInfo[houseid][Locked] == 1) { format(string2, sizeof(string2), "{FF0000}Enter this house");}
- else { format(string2, sizeof(string2), "{33AA33}Enter this house"); }
- ShowPlayerDialog(playerid, DIALOG_OTHERS_HOUSE,DIALOG_STYLE_LIST, "{33AA33}House", string2, "OK", "Chiudi");
- return -1;
- }
- }
- }
- /*
- OpenBusinessDialog
- Function: Shows the dialog.
- Parameters:
- -playerid: The ID of the player.
- -bizid: The ID of the business.
- Returns:
- -true(1): When the biz is for sale.
- -null(-1): When the biz is bought.
- -false(0): When the biz is bought and playerid is the owner.
- */
- stock OpenBusinessDialog(playerid, bizid)
- {
- if(strcmp(bInfo[bizid][bName], "ForSale",true) == 0)
- {
- new string[256];
- new str2[180];
- if(GetPlayerMoney(playerid) >= bInfo[bizid][bCost]) { format(string,sizeof(string),"{33AA33}Buy this store for $%d", bInfo[bizid][bCost]); }
- else { format(string,sizeof(string),"{FF0000}Buy this store for $%d", bInfo[bizid][bCost]); }
- format(str2,sizeof(str2),"{FF0000}\"%s\" {33AA33}Store For Sale!",bInfo[bizid][bTitle]);
- ShowPlayerDialog(playerid, DIALOG_FORSALE_STORE, DIALOG_STYLE_LIST, str2, string, "OK", "Close");
- return 1;
- }
- else
- {
- new string[180];
- new string2[180];
- new name[24];
- GetPlayerName(playerid,name,sizeof(name));
- if(strcmp(bInfo[bizid][bName], name, true) == 0)
- {
- new str[256];
- format(str,sizeof(str), "{33AA33}Welcome back to {FF0000}\"%s\"", bInfo[bizid][bTitle]);
- ShowPlayerDialog(playerid, DIALOG_MY_STORE, DIALOG_STYLE_LIST, str, "{33AA33}Enter your store\n{33AA33}Open/close the store\n{33AA33}Rename your store\n{33AA33}Sell your store", "OK", "Close");
- return 0;
- }
- else
- {
- format(string, sizeof(string), "%s\n{33AA33}Proprietario: %s", bInfo[bizid][bTitle], bInfo[bizid][bName]);
- if(bInfo[bizid][bLocked] == 1) { format(string2, sizeof(string2), "{FF0000}Enter this store");}
- else { format(string2, sizeof(string2), "{33AA33}Enter this store"); }
- ShowPlayerDialog(playerid, DIALOG_OTHERS_STORE, DIALOG_STYLE_LIST, string, string2, "OK", "Close");
- return -1;
- }
- }
- }
- /*
- GetHouseID
- Function: Gets the house ID of the player.
- Parameters:
- -playerid: The ID of the player.
- Returns:
- -houseid(): When playerid is near to any house pickup
- -invalid(-255): When playerid isn't near to any house
- */
- stock GetHouseID(playerid)
- {
- for(new i=0; i<MAX_HOUSES; i++)
- {
- if(IsPlayerNearPoint(2.0, playerid, hInfo[i][ExteriorX], hInfo[i][ExteriorY], hInfo[i][ExteriorZ]))
- {
- return i;
- }
- }
- return INVALID_HOUSE_ID;
- }
- /*
- GetBizID
- Function: Gets the biz ID of the player.
- Parameters:
- -playerid: The ID of the player.
- Returns:
- -bizid): When playerid is near to any biz pickup
- -invalid(-255): When playerid isn't near to any biz
- */
- stock GetBizID(playerid)
- {
- for(new i=0; i<MAX_HOUSES; i++)
- {
- if(IsPlayerNearPoint(2.0, playerid, bInfo[i][bExteriorX], bInfo[i][bExteriorY], bInfo[i][bExteriorZ]))
- {
- return i;
- }
- }
- return INVALID_HOUSE_ID;
- }
- /*
- IsPlayerNearPoint
- Function: Returns wheter playerid is near a point
- Parameters:
- -radi: The radius of the sphere.
- -playerid: The ID of the player.
- -x, y, z: The coordinates of the second point
- Returns:
- -true: When playerid is connected and near x,y,z
- -false: When playerid is connected but isn't near x,y,z
- -null: When playerid isn't connected
- */
- stock IsPlayerNearPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- tempposx = (oldposx -x);
- tempposy = (oldposy -y);
- tempposz = (oldposz -z);
- if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- return 1;
- }
- return 0;
- }
- return -1;
- }
- /*
- BuyHouse
- Function: The player buys the house
- Parameters:
- -playerid: The ID of the player.
- -houseid: The ID of the house.
- Returns:
- -true(1): When bought successfully
- -false(0): When an error has occurred
- */
- stock BuyHouse(playerid, houseid)
- {
- new string2[256];
- new name[24];
- GetPlayerName(playerid, name, sizeof(name));
- #if defined PRINT_HOUSES
- printf("%s Bought House ID %d", name, houseid);
- #endif
- GivePlayerMoney(playerid, -hInfo[houseid][Cost]);
- format(string2,sizeof(string2), HOUSE_FILE, houseid);
- INI_Open(string2);
- INI_WriteString("Name", name);
- INI_WriteInt("Locked", 0);
- INI_Save();
- INI_Close();
- hInfo[houseid][Name] = name;
- hInfo[houseid][Locked] = 0;
- DestroyPickup(HousePickup[houseid]);
- HousePickup[houseid] = CreatePickup(1272, 23, hInfo[houseid][ExteriorX], hInfo[houseid][ExteriorY], hInfo[houseid][ExteriorZ]);
- ShowBoughtHouseMessage(playerid);
- return 1;
- }
- /*
- BuyBusiness
- Function: The player buys the biz
- Parameters:
- -playerid: The ID of the player.
- -bizid: The ID of the biz.
- Returns:
- -true(1): When bought successfully
- -false(0): When an error has occurred
- */
- stock BuyBusiness(playerid, bizid)
- {
- new string2[256];
- new name[24];
- GetPlayerName(playerid, name, sizeof(name));
- #if defined PRINT_HOUSES
- printf("%s Bought Store ID %d", name, bizid);
- #endif
- GivePlayerMoney(playerid, -bInfo[bizid][bCost]);
- format(string2,sizeof(string2), BIZ_FILE, bizid);
- INI_Open(string2);
- INI_WriteString("Name", name);
- INI_WriteInt("Locked", 0);
- INI_Save();
- INI_Close();
- bInfo[bizid][bName] = name;
- bInfo[bizid][bLocked] = 0;
- ShowBoughtStoreMessage(playerid);
- return 1;
- }
- /*
- SellHouse
- Function: The player sells the house
- Parameters:
- -playerid: The ID of the player.
- -houseid: The ID of the house.
- Returns:
- -true(1): When sold successfully
- -false(0): When an error has occurred
- */
- stock SellHouse(playerid, houseid)
- {
- new string[256];
- new name[24];
- GetPlayerName(playerid, name, sizeof(name));
- format(string,sizeof(string),HOUSE_FILE, houseid);
- INI_Open(string);
- INI_WriteString("Name","ForSale");
- INI_WriteInt("Locked", 1);
- INI_Save();
- INI_Close();
- #if defined PRINT_HOUSES
- printf("%s Sold House ID %d", name, houseid);
- #endif
- GivePlayerMoney(playerid, hInfo[houseid][Sell]);
- hInfo[houseid][Locked] = 1;
- format(hInfo[houseid][Name], 255, "ForSale");
- DestroyPickup(HousePickup[houseid]);
- HousePickup[houseid] = CreatePickup(1273, 23, hInfo[houseid][ExteriorX], hInfo[houseid][ExteriorY], hInfo[houseid][ExteriorZ]);
- ShowSoldHouseMessage(playerid);
- return 1;
- }
- /*
- SellBusiness
- Function: The player sells the business
- Parameters:
- -playerid: The ID of the player.
- -bizid: The ID of the biz.
- Returns:
- -true(1): When sold successfully
- -false(0): When an error has occurred
- */
- stock SellBusiness(playerid, bizid)
- {
- new string[256];
- new name[24];
- GetPlayerName(playerid, name, sizeof(name));
- format(string,sizeof(string),BIZ_FILE, bizid);
- INI_Open(string);
- INI_WriteString("Name","ForSale");
- INI_WriteInt("Locked", 1);
- INI_Save();
- INI_Close();
- #if defined PRINT_HOUSES
- printf("%s Sold Store ID %d", name, bizid);
- #endif
- GivePlayerMoney(playerid, bInfo[bizid][bSell]);
- bInfo[bizid][bLocked] = 1;
- format(bInfo[bizid][bName], 255, "ForSale");
- ShowSoldStoreMessage(playerid);
- return 1;
- }
- /*
- EnterHouse
- Function: The player enters the house
- Parameters:
- -playerid: The ID of the player.
- -houseid: The ID of the house.
- Returns:
- -true(1): Everyway
- */
- stock EnterHouse(playerid, houseid)
- {
- SetPlayerPos(playerid, hInfo[houseid][InteriorX], hInfo[houseid][InteriorY], hInfo[houseid][InteriorZ]);
- SetPlayerInterior(playerid, hInfo[houseid][Interior]);
- SetPlayerVirtualWorld(playerid, hInfo[houseid][VirtualWorld]);
- return 1;
- }
- /*
- EnterBusiness
- Function: The player enters the business
- Parameters:
- -playerid: The ID of the player.
- -bizid: The ID of the biz.
- Returns:
- -true(1): Everyway
- */
- stock EnterBusiness(playerid, bizid)
- {
- SetPlayerPos(playerid, bInfo[bizid][bInteriorX], bInfo[bizid][bInteriorY], bInfo[bizid][bInteriorZ]);
- SetPlayerInterior(playerid, bInfo[bizid][bInterior]);
- SetPlayerVirtualWorld(playerid, bInfo[bizid][bVirtualWorld]);
- new string[180];
- format(string,sizeof(string),"Welcome to %s!", bInfo[bizid][bTitle]);
- ShowPlayerDialog(playerid,1499,DIALOG_STYLE_MSGBOX, string, "", "OK", "");
- return 1;
- }
- /*
- ExitHouse
- Function: The player exits the house
- Parameters:
- -playerid: The ID of the player.
- -houseid: The ID of the house.
- Returns:
- -true(1): Everyway
- */
- stock ExitHouse(playerid, houseid)
- {
- SetPlayerPos(playerid, hInfo[houseid][ExteriorX], hInfo[houseid][ExteriorY], hInfo[houseid][ExteriorZ]);
- SetPlayerInterior(playerid, 0);
- SetPlayerVirtualWorld(playerid, 0);
- return 1;
- }
- /*
- ExitBusiness
- Function: The player exits the business
- Parameters:
- -playerid: The ID of the player.
- -bizid: The ID of the biz.
- Returns:
- -true(1): Everyway
- */
- stock ExitBusiness(playerid, bizid)
- {
- SetPlayerPos(playerid, bInfo[bizid][bExteriorX], bInfo[bizid][bExteriorY], bInfo[bizid][bExteriorZ]);
- SetPlayerInterior(playerid, 0);
- SetPlayerVirtualWorld(playerid, 0);
- return 1;
- }
- //MESSAGES
- stock ShowLockedHouseMessage(playerid)
- {
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{FF0000}ERROR","This house is locked!","OK","");
- return 1;
- }
- stock ShowLockedStoreMessage(playerid)
- {
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{FF0000}ERROR","Sorry, this store is closed. Come later.","OK","");
- return 1;
- }
- stock ShowNoMoneyMessage(playerid)
- {
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{FF0000}ERROR","You don't have enough money!","OK","");
- return 1;
- }
- stock ShowSoldHouseMessage(playerid)
- {
- new string[51];
- format(string,sizeof(string),"House sold for $%d!", hInfo[GetHouseID(playerid)][Sell]);
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND", string, "OK", "");
- return 1;
- }
- stock ShowSoldStoreMessage(playerid)
- {
- new string[51];
- format(string,sizeof(string),"Store sold for $%d!", hInfo[GetHouseID(playerid)][Sell]);
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND", string, "OK", "");
- return 1;
- }
- stock ShowBoughtHouseMessage(playerid)
- {
- new string[51];
- format(string,sizeof(string),"House bought for $%d!", hInfo[GetHouseID(playerid)][Cost]);
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND", string, "OK", "");
- return 1;
- }
- stock ShowBoughtStoreMessage(playerid)
- {
- new string[51];
- format(string,sizeof(string),"Store bought for $%d!", hInfo[GetHouseID(playerid)][Cost]);
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND", string, "OK", "");
- return 1;
- }
- stock LockYourHouseMessage(playerid)
- {
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND","House closed!","OK","");
- return 1;
- }
- stock LockYourStoreMessage(playerid)
- {
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND","Store closed!","OK","");
- return 1;
- }
- stock UnlockYourHouseMessage(playerid)
- {
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND","House open!","OK","");
- return 1;
- }
- stock UnlockYourStoreMessage(playerid)
- {
- ShowPlayerDialog(playerid, 1499, DIALOG_STYLE_MSGBOX, "{33AA33}COMMAND","Store open!","OK","");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement