From cdb6f5a76ecca8031c476a2e7c02df688235611c Mon Sep 17 00:00:00 2001 From: Lorenc Pekaj Date: Mon, 10 Sep 2018 18:24:53 +1000 Subject: [PATCH] modulize houses --- .../irresistible/cnr/features/_features.pwn | 3 + .../cnr/features/houses/_houses.pwn | 10 + .../cnr/features/{ => houses}/furniture.pwn | 225 ++++- .../cnr/features/houses/house.pwn | 858 ++++++++++++++++++ gamemodes/irresistible/cnr/player.pwn | 3 - 5 files changed, 1086 insertions(+), 13 deletions(-) create mode 100644 gamemodes/irresistible/cnr/features/houses/_houses.pwn rename gamemodes/irresistible/cnr/features/{ => houses}/furniture.pwn (80%) create mode 100644 gamemodes/irresistible/cnr/features/houses/house.pwn diff --git a/gamemodes/irresistible/cnr/features/_features.pwn b/gamemodes/irresistible/cnr/features/_features.pwn index 8a9099a..5d7d65d 100644 --- a/gamemodes/irresistible/cnr/features/_features.pwn +++ b/gamemodes/irresistible/cnr/features/_features.pwn @@ -21,6 +21,9 @@ // #include "irresistible\cnr\features\fishing.pwn" // #include "irresistible\cnr\features\vote.pwn" +// houses +#include "irresistible\cnr\features\houses\_houses.pwn" + // gangs and facilities #include "irresistible\cnr\features\gangs\_gangs.pwn" diff --git a/gamemodes/irresistible/cnr/features/houses/_houses.pwn b/gamemodes/irresistible/cnr/features/houses/_houses.pwn new file mode 100644 index 0000000..2a9cd0b --- /dev/null +++ b/gamemodes/irresistible/cnr/features/houses/_houses.pwn @@ -0,0 +1,10 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc Pekaj + * Module: cnr\features\_features.pwn + * Purpose: encloses all feature modules & components (cnr) + */ + +/* ** Includes ** */ +#include "irresistible\cnr\features\houses\house.pwn" +#include "irresistible\cnr\features\houses\furniture.pwn" diff --git a/gamemodes/irresistible/cnr/features/furniture.pwn b/gamemodes/irresistible/cnr/features/houses/furniture.pwn similarity index 80% rename from gamemodes/irresistible/cnr/features/furniture.pwn rename to gamemodes/irresistible/cnr/features/houses/furniture.pwn index 8279008..cde8b99 100644 --- a/gamemodes/irresistible/cnr/features/furniture.pwn +++ b/gamemodes/irresistible/cnr/features/houses/furniture.pwn @@ -1,18 +1,221 @@ /* - * Irresistible Gaming 2018 + * Irresistible Gaming (c) 2018 * Developed by Lorenc Pekaj - * Module: static_cnr\furniture.inc - * Purpose: removals of static furniture objects in buildings or player interiors + * Module: + * Purpose: */ -/* ** Hooks ** */ -hook OnPlayerConnect( playerid ) { - initializePlayerInteriors( playerid ); - return 1; -} +/* ** Includes ** */ +#include < YSI\y_hooks > -/* ** Functions ** */ -static stock initializePlayerInteriors( playerid ) +/* ** Definitions ** */ +#define MAX_FURNITURE ( 50 ) + +// Furniture Categories +#define FC_DOORS 0 +#define FC_TABLECHAIR 1 +#define FC_FITNESS 2 +#define FC_KITCHENBATH 3 +#define FC_ELECTRONIC 4 +#define FC_BEDROOM 5 +#define FC_LOUNGE 6 +#define FC_FLOWERS 7 +#define FC_MISC 8 +#define FC_WEAPONS 9 +#define FC_HOLIDAYS 10 +#define FC_FOODRINK 11 + +/* ** Variables ** */ +enum E_FURINTURE_DATA +{ + E_CATEGORY, E_NAME[ 21 ], E_MODEL, + E_COST +}; + +new + g_furnitureCategory[ ] [ ] = + { + { "Doors" }, { "Tables and Chairs" }, { "Fitness" }, { "Kitchen and Bathroom" }, { "Electronics" }, { "Bedroom" }, + { "Lounge" }, { "Flowers and Plants" }, { "Miscellaneous" }, { "Weapons" }, { "Holiday" }, { "Food/Drink" } + }, + g_houseFurniture[ ] [ E_FURINTURE_DATA ] = + { + // Doors + { FC_DOORS, "Red Door", 1504, 175 }, + { FC_DOORS, "Blue Door", 1505, 175 }, + { FC_DOORS, "White Door", 1506, 175 }, + { FC_DOORS, "Yellow Door", 1507, 175 }, + // Tables and Chairs + { FC_TABLECHAIR, "Wooden Open Table", 1817, 50 }, + { FC_TABLECHAIR, "Dining Chair", 2079, 60 }, + { FC_TABLECHAIR, "Office Chair", 1806, 62 }, + { FC_TABLECHAIR, "Wooden Circle Table", 1815, 75 }, + { FC_TABLECHAIR, "Cluckin' Table Sml", 2763, 80 }, + { FC_TABLECHAIR, "Cluckin' Table", 2762, 125 }, + { FC_TABLECHAIR, "Dining Table", 2115, 135 }, + { FC_TABLECHAIR, "Circle Dining Chair", 2125, 135 }, + { FC_TABLECHAIR, "Circle Dining Table", 2030, 150 }, + { FC_TABLECHAIR, "Swivel Chair", 1663, 180 }, + { FC_TABLECHAIR, "Rocking Chair", 11734, 200 }, + { FC_TABLECHAIR, "Gamer Chair", 19999, 320 }, + { FC_TABLECHAIR, "Poker Table", 19474, 500 }, + { FC_TABLECHAIR, "Lab Table", 3383, 900 }, + // Fitness + { FC_FITNESS, "Mattress #1", 2815, 50 }, + { FC_FITNESS, "Mattress #2", 2817, 50 }, + { FC_FITNESS, "Mattress #3", 2833, 50 }, + { FC_FITNESS, "Mattress #4", 2836, 50 }, + { FC_FITNESS, "Mattress #5", 2847, 50 }, + { FC_FITNESS, "Cycle", 2630, 950 }, + { FC_FITNESS, "Treadmill", 2627, 1250 }, + { FC_FITNESS, "Weight Lifting", 2628, 1550 }, + // Kitchen and Bathroom + { FC_KITCHENBATH, "Soap", 19874, 15 }, + { FC_KITCHENBATH, "Toilet Paper", 19873, 20 }, + { FC_KITCHENBATH, "Towel holder", 11707, 300 }, + { FC_KITCHENBATH, "Double Metal Cabin", 2007, 400 }, + { FC_KITCHENBATH, "Metal Shelf x4", 2063, 400 }, + { FC_KITCHENBATH, "Metal Table", 941, 500 }, + { FC_KITCHENBATH, "Metal Counter", 937, 600 }, + { FC_KITCHENBATH, "Metal Bench-top", 936, 685 }, + { FC_KITCHENBATH, "Toilet", 2514, 700 }, + { FC_KITCHENBATH, "Bathroom Sink", 2523, 900 }, + { FC_KITCHENBATH, "Wooden Double Draw", 2139, 910 }, + { FC_KITCHENBATH, "Wooden Low-unit", 2138, 925 }, + { FC_KITCHENBATH, "Washing Machine", 1208, 925 }, + { FC_KITCHENBATH, "Laundry Unit", 2303, 980 }, + { FC_KITCHENBATH, "White Bath Tub", 2519, 1000 }, + { FC_KITCHENBATH, "Corner Wooden Bench", 2305, 1100 }, + { FC_KITCHENBATH, "Wooden Bench w/ Sink", 2136, 1185 }, + { FC_KITCHENBATH, "Stable Counter", 2339, 1200 }, + { FC_KITCHENBATH, "Bath Tub", 2526, 1200 }, + { FC_KITCHENBATH, "Shower System", 14481, 1290 }, + { FC_KITCHENBATH, "Stable Shelf", 2141, 1300 }, + { FC_KITCHENBATH, "Stable Sink", 2132, 1500 }, + { FC_KITCHENBATH, "Love Spa", 11732, 2000 }, + { FC_KITCHENBATH, "Cooker and Oven", 2135, 2200 }, + { FC_KITCHENBATH, "Deep Fryer", 2413, 2300 }, + // Electronics + { FC_ELECTRONIC, "Blender", 19830, 120 }, + { FC_ELECTRONIC, "Mini Stereo Speaker", 2233, 450 }, + { FC_ELECTRONIC, "Coffee Machine", 11743, 500 }, + { FC_ELECTRONIC, "Red Guitar", 19317, 650 }, + { FC_ELECTRONIC, "White Guitar", 19318, 675 }, + { FC_ELECTRONIC, "Bass speaker", 2229, 675 }, + { FC_ELECTRONIC, "Black Guitar", 19319, 700 }, + { FC_ELECTRONIC, "8 Bit TV", 1748, 700 }, + { FC_ELECTRONIC, "VCR Player", 1719, 900 }, + { FC_ELECTRONIC, "Gaming Console", 2028, 1000 }, + { FC_ELECTRONIC, "Small TV with VCR", 2595, 1100 }, + { FC_ELECTRONIC, "Laptop", 19893, 1250 }, + { FC_ELECTRONIC, "TV Small", 1518, 1575 }, + { FC_ELECTRONIC, "Swank TV", 1792, 1600 }, + { FC_ELECTRONIC, "TV with Wall Hook", 2596, 1790 }, + { FC_ELECTRONIC, "TV With Stance", 1717, 2000 }, + { FC_ELECTRONIC, "Doozy TV with Stance", 2224, 2050 }, + { FC_ELECTRONIC, "Stereo System", 2100, 2175 }, + { FC_ELECTRONIC, "Wide-screen TV", 1786, 2500 }, + { FC_ELECTRONIC, "Huge LCD", 19786, 3000 }, + { FC_ELECTRONIC, "Small TV Unit", 2297, 3700 }, + { FC_ELECTRONIC, "TV Unit", 2296, 4000 }, + { FC_ELECTRONIC, "PC with Desk", 2181, 4200 }, + // Bedroom + { FC_BEDROOM, "Wooden Stance", 1743, 650 }, + { FC_BEDROOM, "Wooden Counter", 1416, 750 }, + { FC_BEDROOM, "Wooden Drawer", 1417, 800 }, + { FC_BEDROOM, "Hobo bed", 1745, 800 }, + { FC_BEDROOM, "Luxurious bed", 2298, 1300 }, + { FC_BEDROOM, "Super Luxurious bed", 2563, 1750 }, + { FC_BEDROOM, "Lavish Red Bed", 11720, 2000 }, + { FC_BEDROOM, "Love Bed", 11731, 4200 }, + // Lounge + { FC_LOUNGE, "Wooden Couch", 1755, 275 }, + { FC_LOUNGE, "Couch", 1754, 350 }, + { FC_LOUNGE, "Leather Couch", 1702, 500 }, + { FC_LOUNGE, "Single Couch", 1704, 850 }, + { FC_LOUNGE, "Luxury Mattress", 1828, 900 }, + { FC_LOUNGE, "Bookshelf", 1742, 1000 }, + { FC_LOUNGE, "Leather Couch", 1723, 1650 }, + { FC_LOUNGE, "TV Stand", 2313, 1700 }, + { FC_LOUNGE, "Fireplace", 11724, 4800 }, + { FC_LOUNGE, "Chandelier", 19806, 5200 }, + // Flowers and plants + { FC_FLOWERS, "Flower Plant 3", 2001, 30 }, + { FC_FLOWERS, "Flower Plant 4", 2253, 35 }, + { FC_FLOWERS, "Clear Flower Vase", 2247, 35 }, + { FC_FLOWERS, "Painted Flower Vase", 2251, 40 }, + { FC_FLOWERS, "Plant Vase", 2245, 50 }, + { FC_FLOWERS, "Flower Wall-Mount", 3810, 120 }, + { FC_FLOWERS, "Weed Plant", 19473, 2250 }, + // Miscellaneous + { FC_MISC, "Chainsaw Dildo", 19086, 69 }, + { FC_MISC, "Massive Die", 1851, 80 }, + { FC_MISC, "Deer Head Mount", 1736, 120 }, + { FC_MISC, "Striped Surfboard", 2404, 140 }, + { FC_MISC, "Beach Surfboard", 2406, 150 }, + { FC_MISC, "Flamed Torch", 3461, 175 }, + { FC_MISC, "Rocking Unicorn", 11733, 180 }, + { FC_MISC, "Do Not Cross Tape", 19834, 250 }, + { FC_MISC, "Grill", 19831, 300 }, + { FC_MISC, "Boxing Bag", 1985, 300 }, + { FC_MISC, "Car Engine", 19917, 500 }, + { FC_MISC, "Drum Kit", 19609, 800 }, + { FC_MISC, "Mechanic Computer", 19903, 1000 }, + { FC_MISC, "Pool Table", 2964, 1250 }, + { FC_MISC, "Cow", 19833, 1337 }, + { FC_MISC, "Deer", 19315, 1337 }, + { FC_MISC, "Money Safe", 2332, 2000 }, + { FC_MISC, "Mechanic Shelves", 19899, 2000 }, + { FC_MISC, "Dance Floor", 19128, 3250 }, + { FC_MISC, "Craps Table", 1824, 4000 }, + { FC_MISC, "Boxing Arena", 14781, 15000 }, + // Weapons + { FC_WEAPONS, "Brass Knuckles", 331, 25 }, + { FC_WEAPONS, "Pool Cue", 338, 40 }, + { FC_WEAPONS, "Parachute", 371, 60 }, + { FC_WEAPONS, "Purple Dildo", 321, 69 }, + { FC_WEAPONS, "Sledge Hammer", 19631, 90 }, + { FC_WEAPONS, "Landmine", 19602, 100 }, + { FC_WEAPONS, "Ammo Box", 19832, 120 }, + { FC_WEAPONS, "Antique Sword", 19590, 250 }, + { FC_WEAPONS, "Mac 10", 352, 250 }, + { FC_WEAPONS, "Tec 9", 372, 290 }, + { FC_WEAPONS, "Rifle", 357, 300 }, + { FC_WEAPONS, "Desert Eagle", 348, 500 }, + { FC_WEAPONS, "Shotgun", 349, 600 }, + { FC_WEAPONS, "Sawn-off Shotgun", 350, 800 }, + { FC_WEAPONS, "Sniper", 358, 800 }, + { FC_WEAPONS, "Spas 12", 351, 900 }, + { FC_WEAPONS, "M4", 356, 900 }, + { FC_WEAPONS, "Minigun", 362, 1337 }, + { FC_WEAPONS, "Heatseeker", 360, 1337 }, + { FC_WEAPONS, "RPG", 359, 1337 }, + // Holiday + { FC_HOLIDAYS, "Xmas Box 1", 19054, 100 }, + { FC_HOLIDAYS, "Xmas Box 2", 19055, 100 }, + { FC_HOLIDAYS, "Xmas Box 3", 19056, 100 }, + { FC_HOLIDAYS, "Xmas Box 4", 19057, 100 }, + { FC_HOLIDAYS, "Xmas Box 5", 19058, 100 }, + { FC_HOLIDAYS, "Witch Pot", 19527, 200 }, + { FC_HOLIDAYS, "Devil Face", 11704, 666 }, + { FC_HOLIDAYS, "Xmas Tree", 19076, 777 }, + // Food/Drink + { FC_FOODRINK, "Pizza Box", 19571, 10 }, + { FC_FOODRINK, "Coffee Mug", 19835, 15 }, + { FC_FOODRINK, "Pizza", 19580, 30 }, + { FC_FOODRINK, "Ordinary Brandy", 19821, 45 }, + { FC_FOODRINK, "Fine Scotch", 19823, 90 }, + { FC_FOODRINK, "Beer Keg", 19812, 150 }, + { FC_FOODRINK, "Vintage Whiskey", 19824, 155 }, + { FC_FOODRINK, "Premium Brandy", 19820, 190 }, + { FC_FOODRINK, "Premium Wine", 19822, 220 } + }, + g_houseFurnitureData [ MAX_HOUSES ] [ MAX_FURNITURE ], + Iterator: housefurniture [ MAX_HOUSES ] < MAX_FURNITURE > +; + +/* ** Hooks ** */ +hook OnPlayerConnect( playerid ) { //Katie - 271.884979,306.631988,999.148437 - DEFAULT - 2 RemoveBuildingForPlayer( playerid, 2251, 266.4531, 303.3672, 998.9844, 0.25 ); @@ -492,3 +695,5 @@ static stock initializePlayerInteriors( playerid ) RemoveBuildingForPlayer( playerid, 1742, -2160.3906, 647.3906, 1056.5859, 0.25 ); RemoveBuildingForPlayer( playerid, 1738, -2158.3906, 647.0859, 1057.2344, 0.25 ); } + +/* ** Functions ** */ diff --git a/gamemodes/irresistible/cnr/features/houses/house.pwn b/gamemodes/irresistible/cnr/features/houses/house.pwn new file mode 100644 index 0000000..596cec2 --- /dev/null +++ b/gamemodes/irresistible/cnr/features/houses/house.pwn @@ -0,0 +1,858 @@ +/* + * Irresistible Gaming (c) 2018 + * Developed by Lorenc Pekaj + * Module: + * Purpose: + */ + +/* ** Error checking ** */ +#if !defined __sfcnr__houses + #define __sfcnr__houses +#endif + +/* ** Includes ** */ +#include < YSI\y_hooks > + +/* ** Definitions ** */ +#define MAX_HOUSES ( 2000 ) +#define MAX_HOUSE_WEAPONS ( 7 ) // (do not change) +#define HOUSE_MAPICON_RADIUS ( 25.0 ) + +#define H_DEFAULT_X 266.4996 +#define H_DEFAULT_Y 304.9577 +#define H_DEFAULT_Z 999.1484 + +#define PROGRESS_BRUTEFORCE 1 + +/* ** Macros ** */ +#define IsPlayerHomeOwner(%0,%1) ( strmatch( g_houseData[ %1 ] [ E_OWNER ], ReturnPlayerName( %0 ) ) ) + +/* ** Variables ** */ +enum E_HOUSE_DATA +{ + E_OWNER[ 24 ], E_HOUSE_NAME[ 30 ], + + Float: E_EX, Float: E_EY, Float: E_EZ, + Float: E_TX, Float: E_TY, Float: E_TZ, + + E_COST, E_INTERIOR_ID, E_CHECKPOINT[ 2 ], + E_WORLD, Text3D: E_LABEL [ 2 ], E_PASSWORD[ 5 ], + + bool: E_CRACKED, bool: E_BEING_CRACKED, E_CRACKED_TS, + E_CRACKED_WAIT, E_MAP_ICON +}; + +enum E_HINTERIOR_DATA +{ + E_NAME[ 19 ], Float: E_EX, Float: E_EY, + Float: E_EZ, E_INTERIOR_ID, E_COST, + bool: E_VIP, Float: E_PREVIEW_POS[ 3 ], Float: E_PREVIEW_LOOKAT[ 3 ] +}; + +new + g_houseInteriors[ ] [ E_HINTERIOR_DATA ] = + { + { "Cattus Interior", H_DEFAULT_X, H_DEFAULT_Y, H_DEFAULT_Z, 2, 0, false, { 266.60010, 302.42820, 999.14840 }, { 271.44260, 306.64240, 999.15580 } }, + { "Assum Interior", 243.71980, 304.963500, 999.14840, 1, 10000, false, { 249.61870, 300.89080, 999.14840 }, { 244.85410, 305.49680, 999.14840 } }, + { "Fossor Interior", 2218.4036, -1076.2621, 1050.4844, 1, 15000, false, { 2202.6704, -1078.198, 1050.4844 }, { 2211.8030, -1074.362, 1050.4844 } }, + //{ "Angusto Interior", 260.98790, 1284.29470, 1080.2578, 4, 20000, false, { 253.80180, 1294.2167, 1080.2578 }, { 258.55260, 1288.3639, 1080.2578 } }, + { "Organum Interior", 309.37170, 311.674700, 1003.3047, 4, 25000, false, { 310.13720, 310.80550, 1003.3047 }, { 300.02930, 300.86170, 1003.5391 } }, + //{ "Bulbus Interior", -68.84510, 1351.19570, 1080.2109, 6, 25000, false, { -71.41990, 1366.0359, 1080.2185 }, { -64.59070, 1360.7052, 1080.2185 } }, + //{ "Vindemia Interior", 295.08510, 1472.25520, 1080.2578, 15, 25000, false, { 290.14430, 1488.8372, 1080.2578 }, { 294.96960, 1483.6603, 1080.2578 } }, + { "Aurora Interior", -2170.344, 639.502500, 1052.3750, 1, 30000, false, { -2168.073, 646.40000, 1057.5938 }, { -2158.598, 638.13010, 1057.5861 } }, + { "Fragor Interior", 318.58580, 1114.47920, 1083.8828, 5, 35000, false, { 326.31450, 1117.5468, 1083.8828 }, { 317.28550, 1122.6113, 1083.8828 } }, + //{ "Mundus Interior", 24.012500, 1340.15890, 1084.3750, 10, 40000, false, { 19.801100, 1340.7814, 1084.3750 }, { 34.253800, 1342.9272, 1084.3750 } }, + { "Artus Interior", 2237.5259, -1081.6458, 1049.0234, 2, 40000, false, { 2236.2290, -1081.065, 1049.0234 }, { 2244.2285, -1069.357, 1049.0234 } }, + { "Caelum Interior", 2233.6931, -1115.2620, 1050.8828, 5, 40000, false, { 2235.1128, -1114.911, 1050.8828 }, { 2229.8982, -1105.175, 1050.8903 } }, + { "Rotta Interior", 2495.9663, -1692.0857, 1014.7422, 3, 50000, false, { 2491.1794, -1694.953, 1014.7461 }, { 2497.4587, -1704.258, 1014.7422 } }, + { "Ascensor Interior", 2317.8369, -1026.7662, 1050.2178, 9, 50000, false, { 2320.9111, -1025.776, 1050.2109 }, { 2319.0242, -1014.091, 1050.2109 } }, + { "Colonel Interior", 2807.5693, -1174.7520, 1025.5703, 8, 60000, false, { 2812.0911, -1173.043, 1025.5703 }, { 2806.0210, -1165.486, 1025.5703 } }, + //{ "Godfather Interior", 140.28170, 1365.92150, 1083.8594, 5, 65000, false, { 135.53440, 1366.6400, 1083.8615 }, { 143.49590, 1375.7461, 1083.8668 } }, + { "Recens Interior", 2270.4192, -1210.5172, 1047.5625, 10, 70000, false, { 2248.2854, -1207.207, 1049.0234 }, { 2261.0574, -1213.011, 1049.0234 } }, + { "Novus Interior", 2365.2341, -1135.5957, 1050.8826, 8, 72000, false, { 2375.3567, -1121.340, 1050.8750 }, { 2367.7095, -1130.863, 1050.8826 } }, + { "Securuse Interior", 2324.3826, -1149.5442, 1050.7101, 12, 80000, false, { 2317.5684, -1136.016, 1054.3047 }, { 2333.1262, -1147.694, 1050.7031 } }, + //{ "Lorem Interior", 234.13900, 1063.72110, 1084.2123, 6, 82500, false, { 235.83530, 1070.2394, 1084.1903 }, { 226.63560, 1073.0388, 1086.2266 } }, + //{ "Domus Interior", 225.73480, 1021.44500, 1084.0177, 7, 120000, false, { 224.76680, 1022.3558, 1084.0150 }, { 241.65380, 1037.2081, 1084.0118 } }, + { "Madd Doggs Mansion", 1260.6455, -785.46530, 1091.9063, 5, 1337, true , { 1262.1033, -772.6712, 1091.9063 }, { 1282.7361, -783.5193, 1089.9375 } }, + { "Butcher Interior", 964.93310, 2160.13210, 1011.0303, 1, 1337, true , { 933.67050, 2118.9556, 1012.8329 }, { 947.38930, 2163.8730, 1011.0234 } }, + { "Bar Interior", 501.93780, -67.563000, 998.75780, 11, 1337, true , { 511.80380, -68.01930, 999.25000 }, { 490.78870, -78.92080, 998.75780 } }, + { "Casino Interior", 1133.1831, -15.833100, 1000.6797, 12, 1337, true , { 1114.8433, -12.31790, 1003.0643 }, { 1136.3059, 2.6477000, 1000.6797 } } + }, + g_houseData [ MAX_HOUSES ] [ E_HOUSE_DATA ], + Iterator: houses < MAX_HOUSES >, + + szg_houseInteriors [ 24 * sizeof( g_houseInteriors ) ], + g_HouseWeapons [ MAX_HOUSES ] [ MAX_HOUSE_WEAPONS ], + g_HouseWeaponAmmo [ MAX_HOUSES ] [ MAX_HOUSE_WEAPONS ], + + p_InHouse [ MAX_PLAYERS ] +; + +/* ** Hooks ** */ +hook OnScriptInit( ) +{ + // load all house interiors into a string once + for( new i = 0; i < sizeof( g_houseInteriors ); i++ ) { + format( szg_houseInteriors, sizeof( szg_houseInteriors ), "%s%s%s\n", szg_houseInteriors, g_houseInteriors[ i ] [ E_VIP ] ? ( COL_GOLD ) : "", g_houseInteriors[ i ] [ E_NAME ] ); + } + + // load all houses + mysql_function_query( dbHandle, "SELECT * FROM `HOUSES`", true, "OnHouseLoad", "" ); + return 1; +} + +hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) +{ + if ( dialogid == DIALOG_HOUSE_CONFIG && response ) + { + if ( p_InHouse[ playerid ] == -1 ) return SendError( playerid, "You're not inside any house." ); + if ( !strmatch( g_houseData[ p_InHouse[ playerid ] ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) return SendError( playerid, "You are not the owner of this house." ); + DeletePVar( playerid, "gate_edititem" ); // Definitely not in the gate dialog lol + switch( listitem ) + { + case 0: ShowPlayerDialog( playerid, DIALOG_HOUSE_TITLE, DIALOG_STYLE_INPUT, "{FFFFFF}Set House Title", ""COL_WHITE"Input the house title you want to change with:", "Confirm", "Back" ); + case 1: ShowPlayerDialog( playerid, DIALOG_HOUSE_INTERIORS, DIALOG_STYLE_LIST, "{FFFFFF}House Interiors", szg_houseInteriors, "Select", "Back" ); + case 2: ShowPlayerDialog( playerid, DIALOG_HOUSE_SET_PW, DIALOG_STYLE_INPUT, "{FFFFFF}Set House Password", ""COL_WHITE"Enter your desired house password below.\n\n"COL_GREY"Note:"COL_WHITE" You can disable it by typing \"N/A\" (without the quotation marks).", "Confirm", "Back" ); + case 3: ShowHouseWeaponStorage( playerid ); + case 4: ShowPlayerDialog( playerid, DIALOG_FURNITURE, DIALOG_STYLE_LIST, "{FFFFFF}Furniture", "Purchase Furniture\nSelect Furniture Easily\nSelect Furniture Manually\nSelect Furniture Nearest\n"COL_RED"Remove All Furniture", "Confirm", "Back" ); + } + } + else if ( dialogid == DIALOG_HOUSE_WEAPONS ) + { + if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this while you're in jail." ); + if ( response ) + { + if ( p_InHouse[ playerid ] == -1 ) return SendError( playerid, "You're not inside any house." ); + if ( !strmatch( g_houseData[ p_InHouse[ playerid ] ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) return SendError( playerid, "You are not the owner of this house." ); + if ( g_HouseWeapons[ p_InHouse[ playerid ] ] [ listitem ] != 0 ) + { + GivePlayerWeapon( playerid, g_HouseWeapons[ p_InHouse[ playerid ] ] [ listitem ], g_HouseWeaponAmmo[ p_InHouse[ playerid ] ] [ listitem ] ); + SendServerMessage( playerid, "You have withdrawn your "COL_GREY"%s"COL_WHITE" with %d ammo.", ReturnWeaponName( g_HouseWeapons[ p_InHouse[ playerid ] ] [ listitem ] ), g_HouseWeaponAmmo[ p_InHouse[ playerid ] ] [ listitem ] ); + g_HouseWeapons[ p_InHouse[ playerid ] ] [ listitem ] = 0; + g_HouseWeaponAmmo[ p_InHouse[ playerid ] ] [ listitem ] = -1; + SaveHouseWeaponStorage( p_InHouse[ playerid ] ); + ShowHouseWeaponStorage( playerid ); + } + else + { + if ( listitem > 2 && p_VIPLevel[ playerid ] < VIP_REGULAR ) return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ); + p_HouseWeaponAddSlot{ playerid } = listitem; + ShowPlayerDialog( playerid, DIALOG_HOUSE_WEAPONS_ADD, DIALOG_STYLE_MSGBOX, "{FFFFFF}House Weapon Storage", "{FFFFFF}Would you like to insert your current weapon into this slot?", "Insert", "Back" ); + } + } + else cmd_h( playerid, "config" ); + } + else if ( dialogid == DIALOG_HOUSE_WEAPONS_ADD ) + { + if ( response ) + { + if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this while you're in jail." ); + if ( p_InHouse[ playerid ] == -1 ) return SendError( playerid, "You're not inside any house." ); + if ( !strmatch( g_houseData[ p_InHouse[ playerid ] ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) return SendError( playerid, "You are not the owner of this house." ); + if ( IsMeleeWeapon( GetPlayerWeapon( playerid ) ) ) + { + SendError( playerid, "You cannot insert melee weapons." ); + cmd_h( playerid, "config" ); + return 1; + } + new current_weapon = GetPlayerWeapon( playerid ); + new current_ammo = GetPlayerAmmo( playerid ); + if ( ( 16 <= current_weapon <= 18 ) || current_weapon == 35 ) { + SendError( playerid, "You cannot store this weapon." ); + cmd_h( playerid, "config" ); + return 1; + } + if ( current_ammo > 0x7FFF || current_ammo <= 0 ) current_ammo = 0x7FFF; + listitem = p_HouseWeaponAddSlot{ playerid }; + g_HouseWeapons[ p_InHouse[ playerid ] ] [ listitem ] = current_weapon; + g_HouseWeaponAmmo[ p_InHouse[ playerid ] ] [ listitem ] = current_ammo; + SendServerMessage( playerid, "You have inserted your "COL_GREY"%s"COL_WHITE" into your weapon storage.", ReturnWeaponName( current_weapon ) ); + RemovePlayerWeapon( playerid, current_weapon ); + SaveHouseWeaponStorage( p_InHouse[ playerid ] ); + ShowHouseWeaponStorage( playerid ); + } + else ShowHouseWeaponStorage( playerid ); + } + else if ( dialogid == DIALOG_HOUSE_SET_PW ) + { + if ( response ) + { + if ( p_InHouse[ playerid ] == -1 ) return SendError( playerid, "You're not inside any house." ); + else if ( !strmatch( g_houseData[ p_InHouse[ playerid ] ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) return SendError( playerid, "You are not the owner of this house." ); + else if ( !strlen( inputtext ) || strlen( inputtext ) > 4 ) + { + SendError( playerid, "Your password must vary between 0 and 4 characters." ); + ShowPlayerDialog( playerid, DIALOG_HOUSE_SET_PW, DIALOG_STYLE_INPUT, "{FFFFFF}Set House Password", ""COL_WHITE"Enter your desired house password below.\n\n"COL_GREY"Note:"COL_WHITE" You can disable it by typing \"N/A\" or \"NULL\" (without the quotation marks).", "Confirm", "Back" ); + } + else if ( strmatch( inputtext, "N/A" ) || strmatch( inputtext, "NULL" ) ) + { + format( g_houseData[ p_InHouse[ playerid ] ] [ E_PASSWORD ], 4, "N/A" ); + SendServerMessage( playerid, "You have successfully disabled your house's password." ); + format( szNormalString, 60, "UPDATE `HOUSES` SET `PASSWORD`='N/A' WHERE `ID`=%d", p_InHouse[ playerid ] ); + mysql_single_query( szNormalString ); + cmd_h( playerid, "config" ); + } + else + { + SendServerMessage( playerid, "You have changed your house password to "COL_GREY"%s"COL_WHITE".", inputtext ); + format( g_houseData[ p_InHouse[ playerid ] ] [ E_PASSWORD ], 5, "%s", inputtext ); + format( szNormalString, 60, "UPDATE `HOUSES` SET `PASSWORD`='%s' WHERE `ID`=%d", mysql_escape( inputtext ), p_InHouse[ playerid ] ); + mysql_single_query( szNormalString ); + cmd_h( playerid, "config" ); + } + } + else cmd_h( playerid, "config" ); + } + else if ( dialogid == DIALOG_HOUSE_INTERIORS ) + { + if ( response ) + { + if ( p_InHouse[ playerid ] == -1 ) + return SendError( playerid, "You're not inside any house." ); + + if ( !strmatch( g_houseData[ p_InHouse[ playerid ] ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) + return SendError( playerid, "You are not the owner of this house." ); + + p_ViewingInterior{ playerid } = listitem; + ShowPlayerDialog( playerid, DIALOG_HOUSE_INT_CONFIRM, DIALOG_STYLE_LIST, "{FFFFFF}House Interiors", "Purchase House Interior\nPreview House Interior", "Select", "Back" ); + } + else cmd_h( playerid, "config" ); + } + else if ( dialogid == DIALOG_HOUSE_INT_CONFIRM ) + { + if ( response ) + { + if ( p_InHouse[ playerid ] == -1 ) + return SendError( playerid, "You're not inside any house." ); + + if ( !strmatch( g_houseData[ p_InHouse[ playerid ] ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) + return SendError( playerid, "You are not the owner of this house." ); + + new + intid = p_ViewingInterior{ playerid }; + + switch( listitem ) + { + case 0: + { + if ( g_houseInteriors[ intid ] [ E_COST ] > GetPlayerCash( playerid ) ) + { + ShowPlayerDialog( playerid, DIALOG_HOUSE_INT_CONFIRM, DIALOG_STYLE_LIST, "{FFFFFF}House Interiors", "Purchase House Interior\nPreview House Interior", "Select", "Back" ); + SendError( playerid, "This interior costs "COL_GOLD"%s"COL_WHITE". You don't have this amount.", number_format( g_houseInteriors[ intid ] [ E_COST ] ) ); + } + else if ( g_houseInteriors[ intid ] [ E_VIP ] && !p_VIPLevel[ playerid ] ) + { + ShowPlayerDialog( playerid, DIALOG_HOUSE_INT_CONFIRM, DIALOG_STYLE_LIST, "{FFFFFF}House Interiors", "Purchase House Interior\nPreview House Interior", "Select", "Back" ); + SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ); + } + else if ( ArePlayersInHouse( p_InHouse[ playerid ], playerid ) ) + { + ShowPlayerDialog( playerid, DIALOG_HOUSE_INT_CONFIRM, DIALOG_STYLE_LIST, "{FFFFFF}House Interiors", "Purchase House Interior\nPreview House Interior", "Select", "Back" ); + SendError( playerid, "You cannot purchase a house interior if there are people inside the building." ); + } + else + { + if ( g_houseInteriors[ intid ] [ E_VIP ] && p_VIPLevel[ playerid ] && ( ( p_VIPExpiretime[ playerid ] - g_iTime ) / 86400 ) < 3 ) + return SendError( playerid, "You need more than 3 days of V.I.P in order to complete this." ); + + new houseid = p_InHouse[ playerid ]; + GivePlayerCash( playerid, -( g_houseInteriors[ intid ] [ E_COST ] ) ); + + if ( intid != 0 ) + SendServerMessage( playerid, "You have purchased a %s for "COL_GOLD"%s"COL_WHITE". This has been applied to the House ID %d.", g_houseInteriors[ intid ] [ E_NAME ], number_format( g_houseInteriors[ intid ] [ E_COST ] ), houseid ); + else + SendServerMessage( playerid, "You have successfully reset your interior to the default interior." ); + + destroyAllFurniture( houseid ); + FillHomeWithFurniture( houseid, intid ); + g_houseData[ houseid ] [ E_TX ] = g_houseInteriors[ intid ] [ E_EX ]; + g_houseData[ houseid ] [ E_TY ] = g_houseInteriors[ intid ] [ E_EY ]; + g_houseData[ houseid ] [ E_TZ ] = g_houseInteriors[ intid ] [ E_EZ ]; + g_houseData[ houseid ] [ E_INTERIOR_ID ] = g_houseInteriors[ intid ] [ E_INTERIOR_ID ]; + SetPlayerPos( playerid, g_houseInteriors[ intid ] [ E_EX ], g_houseInteriors[ intid ] [ E_EY ], g_houseInteriors[ intid ] [ E_EZ ] ); + SetPlayerInterior( playerid, g_houseInteriors[ intid ] [ E_INTERIOR_ID ] ); + DestroyDynamicCP( g_houseData[ houseid ] [ E_CHECKPOINT ] [ 1 ] ); + g_houseData[ houseid ] [ E_CHECKPOINT ] [ 1 ] = CreateDynamicCP( g_houseInteriors[ intid ] [ E_EX ], g_houseInteriors[ intid ] [ E_EY ], g_houseInteriors[ intid ] [ E_EZ ], 1.0, g_houseData[ houseid ] [ E_WORLD ], g_houseData[ houseid ] [ E_INTERIOR_ID ], -1, 50.0 ); + format( szBigString, sizeof( szBigString ), "UPDATE HOUSES SET TX=%f, TY=%f, TZ=%f, INTERIOR=%d WHERE ID=%d", g_houseInteriors[ intid ] [ E_EX ], g_houseInteriors[ intid ] [ E_EY ], g_houseInteriors[ intid ] [ E_EZ ], g_houseData[ houseid ] [ E_INTERIOR_ID ], houseid ); + mysql_single_query( szBigString ); + DestroyDynamic3DTextLabel( g_houseData[ houseid ] [ E_LABEL ] [ 1 ] ); + g_houseData[ houseid ] [ E_LABEL ] [ 1 ] = CreateDynamic3DTextLabel( "[EXIT]", COLOR_GOLD, g_houseData[ houseid ] [ E_TX ], g_houseData[ houseid ] [ E_TY ], g_houseData[ houseid ] [ E_TZ ], 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, g_houseData[ houseid ] [ E_WORLD ] ); + pauseToLoad( playerid ); + } + } + case 1: + { + if ( p_WantedLevel[ playerid ] ) { + ShowPlayerDialog( playerid, DIALOG_HOUSE_INT_CONFIRM, DIALOG_STYLE_LIST, "{FFFFFF}House Interiors", "Purchase House Interior\nPreview House Interior", "Select", "Back" ); + return SendError( playerid, "This feature requires you not to have a wanted level." ); + } + if ( ArePlayersInHouse( p_InHouse[ playerid ], playerid ) ) { + ShowPlayerDialog( playerid, DIALOG_HOUSE_INT_CONFIRM, DIALOG_STYLE_LIST, "{FFFFFF}House Interiors", "Purchase House Interior\nPreview House Interior", "Select", "Back" ); + return SendError( playerid, "You cannot view a house interior if there are people inside the building." ); + } + TogglePlayerControllable( playerid, 0 ); + SetPlayerPos( playerid, g_houseInteriors[ intid ] [ E_EX ], g_houseInteriors[ intid ] [ E_EY ], g_houseInteriors[ intid ] [ E_EZ ] ); + SetPlayerInterior( playerid, g_houseInteriors[ intid ] [ E_INTERIOR_ID ] ); + InterpolateCameraPos( playerid, g_houseInteriors[ intid ] [ E_PREVIEW_POS ] [ 0 ], g_houseInteriors[ intid ] [ E_PREVIEW_POS ] [ 1 ], g_houseInteriors[ intid ] [ E_PREVIEW_POS ] [ 2 ] + 1.5, g_houseInteriors[ intid ] [ E_PREVIEW_LOOKAT ] [ 0 ], g_houseInteriors[ intid ] [ E_PREVIEW_LOOKAT ] [ 1 ], g_houseInteriors[ intid ] [ E_PREVIEW_LOOKAT ] [ 2 ], 15000, CAMERA_MOVE ); + InterpolateCameraLookAt( playerid, g_houseInteriors[ intid ] [ E_PREVIEW_LOOKAT ] [ 0 ], g_houseInteriors[ intid ] [ E_PREVIEW_LOOKAT ] [ 1 ], g_houseInteriors[ intid ] [ E_PREVIEW_LOOKAT ] [ 2 ], g_houseInteriors[ intid ] [ E_PREVIEW_POS ] [ 0 ], g_houseInteriors[ intid ] [ E_PREVIEW_POS ] [ 1 ], g_houseInteriors[ intid ] [ E_PREVIEW_POS ] [ 2 ] + 1.5, 15000, CAMERA_MOVE ); + SendServerMessage( playerid, "You are now previewing "COL_GREY"%s "COL_GOLD"%s"COL_WHITE". Press your enter key to stop.", g_houseInteriors[ intid ] [ E_NAME ], number_format( g_houseInteriors[ intid ] [ E_COST ] ) ); + SetPVarInt( playerid, "viewing_houseints", 1 ); + } + } + } + else ShowPlayerDialog( playerid, DIALOG_HOUSE_INTERIORS, DIALOG_STYLE_LIST, "{FFFFFF}House Interiors", szg_houseInteriors, "Select", "Back" ); + } + else if ( dialogid == DIALOG_HOUSE_TITLE ) + { + if ( response ) + { + if ( p_InHouse[ playerid ] == -1 ) + return SendError( playerid, "You're not inside any house." ); + + if ( !strmatch( g_houseData[ p_InHouse[ playerid ] ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) + return SendError( playerid, "You are not the owner of this house." ); + + if ( ! ( 1 <= strlen( inputtext ) <= 30 ) ) + return ShowPlayerDialog( playerid, DIALOG_HOUSE_TITLE, DIALOG_STYLE_INPUT, "{FFFFFF}Set House Title", ""COL_WHITE"Input the house title you want to change with:\n\n"COL_RED"Must be between 1 and 30 characters.", "Confirm", "Back" ); + + if ( textContainsIP( inputtext ) ) + return SendError( playerid, "We do not condone advertising." ); + + new houseid = p_InHouse[ playerid ]; + format( g_houseData[ houseid ] [ E_HOUSE_NAME ], 30, "%s", inputtext); + mysql_format( dbHandle, szNormalString, sizeof( szNormalString ), "UPDATE `HOUSES` SET `NAME`='%s' WHERE `ID`=%d", g_houseData[ houseid ] [ E_HOUSE_NAME ], p_InHouse[ playerid ] ); + mysql_single_query( szNormalString ); + format( szBigString, sizeof( szBigString ), ""COL_GOLD"House:"COL_WHITE" %s(%d)\n"COL_GOLD"Owner:"COL_WHITE" %s\n"COL_GOLD"Price:"COL_WHITE" %s", g_houseData[ houseid ] [ E_HOUSE_NAME ], houseid, g_houseData[ houseid ] [ E_OWNER ], number_format( g_houseData[ houseid ] [ E_COST ] ) ); + UpdateDynamic3DTextLabelText( g_houseData[ houseid ] [ E_LABEL ] [ 0 ], COLOR_WHITE, szBigString ); + SendServerMessage( playerid, "You have successfully changed the name of your house." ); + cmd_h( playerid, "config" ); + } + else cmd_h( playerid, "config" ); + } + else if ( dialogid == DIALOG_HOUSE_PW && response ) + { + new i = p_PasswordedHouse[ playerid ]; + if ( !strlen( inputtext ) || strlen( inputtext ) > 4 || strmatch( inputtext, "N/A" ) || !strmatch( inputtext, g_houseData[ i ] [ E_PASSWORD ] ) ) ShowPlayerDialog( playerid, DIALOG_HOUSE_PW, DIALOG_STYLE_PASSWORD, "{FFFFFF}House Authentication", ""COL_GREEN"This house is password locked!\n"COL_WHITE"You may only enter this house if you enter the correct password.\n\n"COL_RED"Incorrect Password!", "Enter", "Cancel" ); + else + { + if ( !IsPlayerInRangeOfPoint( playerid, 3.0, g_houseData[ i ] [ E_EX ], g_houseData[ i ] [ E_EY ], g_houseData[ i ] [ E_EZ ] ) ) return SendError( playerid, "You are not near the house entrance!" ); + SendServerMessage( playerid, "Password correct. Access has been granted." ); + p_InHouse[ playerid ] = i; + SetPlayerPos( playerid, g_houseData[ i ] [ E_TX ], g_houseData[ i ] [ E_TY ], g_houseData[ i ] [ E_TZ ] ); + SetPlayerVirtualWorld( playerid, g_houseData[ i ] [ E_WORLD ] ); + SetPlayerInterior( playerid, g_houseData[ i ] [ E_INTERIOR_ID ] ); + } + } + return 1; +} + +/* ** Commands ** */ +CMD:bruteforce( playerid, params[ ] ) +{ + /* ** ANTI SPAM ** */ + if ( GetPVarInt( playerid, "last_bruteforce" ) > g_iTime ) return SendError( playerid, "You must wait 30 seconds before using this command again." ); + /* ** END OF ANTI SPAM ** */ + + if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This command is restricted for F.B.I agents." ); + if ( !( p_inFBI{ playerid } == true && p_inArmy{ playerid } == false && p_inCIA{ playerid } == false ) ) return SendError( playerid, "This command is restricted for F.B.I agents." ); + + foreach ( new i : houses ) + { + if ( IsPlayerInDynamicCP( playerid, g_houseData[ i ] [ E_CHECKPOINT ] [ 0 ] ) && !strmatch( g_houseData[ i ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) + { + if ( g_iTime > g_houseData[ i ] [ E_CRACKED_TS ] && g_houseData[ i ] [ E_CRACKED ] ) g_houseData[ i ] [ E_CRACKED ] = false; // The Virus Is Disabled. + + if ( g_houseData[ i ] [ E_CRACKED_WAIT ] > g_iTime ) + return SendError( playerid, "This house had its password recently had a cracker run through. Come back later." ); + + if ( strmatch( g_houseData[ i ] [ E_PASSWORD ], "N/A" ) ) + return SendError( playerid, "This house does not require cracking as it doesn't have a password." ); + + if ( g_houseData[ i ] [ E_CRACKED ] || g_houseData[ i ] [ E_BEING_CRACKED ] ) + return SendError( playerid, "This house is currently being cracked or is already cracked." ); + + if ( IsHouseOnFire( i ) ) + return SendError( playerid, "This house is on fire, you cannot bruteforce it!" ), 1; + + g_houseData[ i ] [ E_BEING_CRACKED ] = true; + p_HouseCrackingPW[ playerid ] = i; + SetPVarInt( playerid, "last_bruteforce", g_iTime + 30 ); + ShowProgressBar( playerid, "Brute Forcing Password", PROGRESS_BRUTEFORCE, 5000, COLOR_BLUE ); + return 1; + } + } + SendError( playerid, "You are not standing in any house checkpoint." ); + return 1; +} + +CMD:h( playerid, params[ ] ) +{ + if ( p_accountSecurityData[ playerid ] [ E_ID ] && ! p_accountSecurityData[ playerid ] [ E_VERIFIED ] && p_accountSecurityData[ playerid ] [ E_MODE ] != SECURITY_MODE_DISABLED ) + return SendError( playerid, "You must be verified in order to use this feature. "COL_YELLOW"(use /verify)" ); + + if ( ! p_VIPLevel[ playerid ] && p_OwnedHouses[ playerid ] > GetPlayerHouseSlots( playerid ) && ! strmatch( params, "sell" ) ) { + ResetSpawnLocation( playerid ); + return SendError( playerid, "Please renew your V.I.P or sell this home to match your house allocated limit (/h sell)." ); + } + + new + ID = p_InHouse[ playerid ], + query[ 140 ] + ; + if ( strmatch( params, "spawn" ) ) + { + SendServerMessage( playerid, "We have changed the command to simply "COL_GREY"/spawn"COL_WHITE"." ); + return ShowPlayerSpawnMenu( playerid ); + } + else if ( strmatch( params, "config" ) ) + { + if ( ID == -1 ) return SendError( playerid, "You're not in any house." ); + else if ( !strmatch( g_houseData[ ID ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) return SendError( playerid, "You are not the owner of this house." ); + else + { + ShowPlayerDialog( playerid, DIALOG_HOUSE_CONFIG, DIALOG_STYLE_LIST, "{FFFFFF}House Configuration", "Set House Title\nUpgrade Interior\nSet House Password\nWeapon Storage\nFurniture", "Select", "Cancel" ); + } + return 1; + } + else if ( strmatch( params, "buy" ) ) + { + if ( p_OwnedHouses[ playerid ] >= GetPlayerHouseSlots( playerid ) ) return SendError( playerid, "You cannot purchase any more houses, you've reached the limit." ); + if ( GetPlayerScore( playerid ) < 200 ) return SendError( playerid, "You need at least 200 score to buy a house." ); + + foreach ( new i : houses ) + { + if ( IsPlayerInDynamicCP( playerid, g_houseData[ i ] [ E_CHECKPOINT ] [ 0 ] ) || ( ID != -1 && ID == i ) ) + { + if ( strmatch( g_houseData[ i ] [ E_OWNER ], "No-one" ) ) + { + if ( GetPlayerCash( playerid ) < g_houseData[ i ] [ E_COST ] ) + return SendError( playerid, "You don't have enough money to purchase this house." ); + + if ( g_houseData[ i ] [ E_COST ] == 1337 && !p_VIPLevel[ playerid ] ) + return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ); + + GivePlayerCash( playerid, -( g_houseData[ i ] [ E_COST ] ), .force_save = true ); + SendServerMessage( playerid, "You have bought this home for "COL_GOLD"%s"COL_WHITE"!", number_format( g_houseData[ i ] [ E_COST ] ) ); + SetHouseOwner( i, ReturnPlayerName( playerid ) ); + + p_OwnedHouses[ playerid ] ++; + return 1; + } + else return SendError( playerid, "This house isn't for sale." ); + } + } + return SendError( playerid, "You are not around any house entrances." ); + } + else if ( strmatch( params, "sell" ) ) + { + if ( ID == -1 ) return SendError( playerid, "You're not in any house." ); + else if ( !strmatch( g_houseData[ ID ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) return SendError( playerid, "You are not the owner of this house." ); + else + { + format( szBigString, sizeof( szBigString ), "[SELL] [%s] %s | %s | %d\r\n", getCurrentDate( ), ReturnPlayerName( playerid ), g_houseData[ ID ][ E_OWNER ], ID ); + AddFileLogLine( "log_houses.txt", szBigString ); + p_OwnedHouses[ playerid ] --; + format( g_houseData[ ID ] [ E_PASSWORD ], 4, "N/A" ); + format( g_houseData[ ID ] [ E_OWNER ], 7, "No-one" ); + format( g_houseData[ ID ] [ E_HOUSE_NAME ], 5, "Home" ); + for( new i; i < MAX_HOUSE_WEAPONS; i++ ) { g_HouseWeapons[ ID ] [ i ] = 0, g_HouseWeaponAmmo[ ID ] [ i ] = -1; } + SaveHouseWeaponStorage( ID ); + GivePlayerCash( playerid, ( g_houseData[ ID ] [ E_COST ] / 2 ) ); + destroyAllFurniture( ID ); + FillHomeWithFurniture( ID, 0 ); + g_houseData[ ID ] [ E_TX ] = g_houseInteriors[ 0 ] [ E_EX ]; + g_houseData[ ID ] [ E_TY ] = g_houseInteriors[ 0 ] [ E_EY ]; + g_houseData[ ID ] [ E_TZ ] = g_houseInteriors[ 0 ] [ E_EZ ]; + g_houseData[ ID ] [ E_INTERIOR_ID ] = 2; + format( query, sizeof( query ), "UPDATE HOUSES SET OWNER='No-one',PASSWORD='N/A',NAME='Home',TX=%f,TY=%f,TZ=%f,INTERIOR=%d WHERE ID=%d", g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], g_houseData[ ID ] [ E_INTERIOR_ID ], ID ); + mysql_single_query( query ); + format( szBigString, sizeof( szBigString ), ""COL_GOLD"House:"COL_WHITE" Home(%d)\n"COL_GOLD"Owner:"COL_WHITE" No-one\n"COL_GOLD"Price:"COL_WHITE" %s", ID, number_format( g_houseData[ ID ] [ E_COST ] ) ); + UpdateDynamic3DTextLabelText( g_houseData[ ID ] [ E_LABEL ] [ 0 ], COLOR_WHITE, szBigString ); + DestroyDynamic3DTextLabel( g_houseData[ ID ] [ E_LABEL ] [ 1 ] ); + g_houseData[ ID ] [ E_LABEL ] [ 1 ] = CreateDynamic3DTextLabel( "[EXIT]", COLOR_GOLD, g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, g_houseData[ ID ] [ E_WORLD ] ); + DestroyDynamicCP( g_houseData[ ID ] [ E_CHECKPOINT ] [ 1 ] ); + g_houseData[ ID ] [ E_CHECKPOINT ] [ 1 ] = CreateDynamicCP( g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], 1.0, g_houseData[ ID ] [ E_WORLD ], g_houseData[ ID ] [ E_INTERIOR_ID ], -1, 50.0 ); + SetPlayerPos( playerid, g_houseData[ ID ] [ E_EX ], g_houseData[ ID ] [ E_EY ], g_houseData[ ID ] [ E_EZ ] ); + DestroyDynamicMapIcon( g_houseData[ ID ] [ E_MAP_ICON ] ); + SetPlayerInterior( playerid, 0 ); + SetPlayerVirtualWorld( playerid, 0 ); + SendServerMessage( playerid, "You have successfully sold your house for "COL_GOLD"%s", number_format( ( g_houseData[ ID ] [ E_COST ] / 2 ) ) ); + } + return 1; + } + else if ( strmatch( params, "offer cancel" ) ) + { + new + bool: bResults = false; + + foreach(new i : Player) + { + if ( p_HouseOfferer[ i ] == playerid ) + { + bResults = true; + p_HouseOfferer [ i ] = INVALID_PLAYER_ID; + p_HouseOfferTicks [ i ] = 0; + p_HouseSellingID [ i ] = 0; + p_HouseSellingPrice [ i ] = 0; + } + } + + if ( bResults ) + return SendServerMessage( playerid, "You have successfully canceled all house offers you have made to players." ); + + return SendError( playerid, "You have not made any house offers to anybody." ); + } + else if ( strmatch( params, "offer take" ) ) + { + new + houseid = p_HouseSellingID[ playerid ], + sellerid = p_HouseOfferer[ playerid ], + sellingprice = p_HouseSellingPrice[ playerid ] + ; + + if ( !IsPlayerConnected( sellerid ) ) SendError( playerid, "The person who offered you a house is no longer online." ); + else if ( p_HouseOfferTicks[ playerid ] < g_iTime ) SendError( playerid, "This house offer has expired %d seconds ago.", g_iTime - p_HouseOfferTicks[ playerid ] ); + else if ( GetPlayerCash( playerid ) < p_HouseSellingPrice[ playerid ] ) SendError( playerid, "You do not have enough money to accept this offer (%s).", number_format( p_HouseSellingPrice[ playerid ] ) ); + else if ( g_houseData[ houseid ] [ E_COST ] <= 1337 && !p_VIPLevel[ playerid ] ) SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" ); + else if ( p_OwnedHouses[ playerid ] >= GetPlayerHouseSlots( playerid ) ) SendError( playerid, "You cannot purchase any more houses, you've reached the limit." ); + else + { + format( szBigString, sizeof( szBigString ), "[SELL TO] [%s] %s | %s | %s | %d\r\n", getCurrentDate( ), ReturnPlayerName( playerid ), ReturnPlayerName( sellerid ), number_format( sellingprice ), houseid ); + AddFileLogLine( "log_houses.txt", szBigString ); + + p_OwnedHouses[ sellerid ] --; + p_OwnedHouses[ playerid ] ++; + + // destroyAllFurniture( houseid ); + mysql_single_query( sprintf( "UPDATE `FURNITURE` SET `OWNER`=%d WHERE `HOUSE_ID`=%d", p_AccountID[ playerid ], houseid ) ); + SetHouseOwner( houseid, ReturnPlayerName( playerid ) ); + + GivePlayerCash( playerid, -sellingprice ); + GivePlayerCash( sellerid, sellingprice ); + + SendServerMessage( sellerid, "You have successfully sold your house for "COL_GOLD"%s"COL_WHITE" to %s(%d)!", number_format( p_HouseSellingPrice[ playerid ] ), ReturnPlayerName( playerid ), playerid ); + SendServerMessage( playerid, "You have successfully bought %s(%d)'s home for "COL_GOLD"%s"COL_WHITE"!", ReturnPlayerName( sellerid ), sellerid, number_format( p_HouseSellingPrice[ playerid ] ) ); + } + return ( p_HouseOfferer[ playerid ] = INVALID_PLAYER_ID ), ( p_HouseOfferTicks[ playerid ] = 0 ), 1; + } + else if ( !strcmp( params, "offer", false, 5 ) ) + { + new offerid, price; + + if ( ID == -1 ) return SendError( playerid, "You're not in any house." ); + else if ( !strmatch( g_houseData[ ID ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) return SendError( playerid, "You are not the owner of this house." ); + else if ( sscanf( params[ 6 ],""#sscanf_u"d", offerid, price ) ) return SendUsage( playerid, "/h offer [PLAYER_ID] [PRICE]" ); + else if ( !IsPlayerConnected( offerid ) ) return SendError( playerid, "This player is not connected." ); + else if ( offerid == playerid ) return SendError( playerid, "You cannot make a house offer to yourself." ); + else if ( price > 30000000 ) return SendError( playerid, "The maximum amount you can sell a house for is $30,000,000." ); + else if ( price < g_houseData[ ID ] [ E_COST ] / 2 ) return SendError( playerid, "You cannot sell your house to somebody for less than half its cost." ); + else if ( GetDistanceBetweenPlayers( playerid, offerid ) > 4.0 ) return SendError( playerid, "You cannot send offers to players who are not near you." ); + else if ( p_HouseOfferTicks[ offerid ] > g_iTime ) return SendError( playerid, "Please wait %d seconds to make an house price offer to this player again.", p_HouseOfferTicks[ offerid ] - g_iTime ); + else if ( g_houseData[ ID ] [ E_COST ] <= 1337 && !p_VIPLevel[ offerid ] ) return SendError( playerid, "You cannot offer V.I.P homes to sell to regular players." ); + else if ( p_OwnedHouses[ offerid ] >= GetPlayerHouseSlots( offerid ) ) return SendError( playerid, "This player cannot purchase any more houses, they have reached the limit." ); + else + { + // Cannot sell to non vip vip homes k + p_HouseOfferer[ offerid ] = playerid; + p_HouseOfferTicks[ offerid ] = g_iTime + 15; + p_HouseSellingID[ offerid ] = ID; + p_HouseSellingPrice[ offerid ] = price; + SendServerMessage( offerid, "%s(%d) wishes to offer his house (id %d) for %s to you. Use "COL_GREY"/h offer take"COL_WHITE" to take the offer.", ReturnPlayerName( playerid ), playerid, ID, number_format( price ) ); + SendServerMessage( playerid, "You have offered %s(%d) %s for your house (id %d), cancel the offer with "COL_GREY"/h offer cancel"COL_WHITE".", ReturnPlayerName( offerid ), offerid, number_format( price ), ID ); + } + return 1; + } + return SendUsage( playerid, "/h [CONFIG/BUY/SELL/OFFER/OFFER TAKE/OFFER CANCEL]" ); +} + +/* ** SQL Threads ** */ +thread OnHouseLoad( ) +{ + new + rows, fields, i = -1, + loadingTick = GetTickCount( ) + ; + + cache_get_data( rows, fields ); + if ( rows ) + { + static weapon_info[ 40 ], house_name[ 30 ], password[ 5 ], owner[ 24 ]; + + while( ++ i < rows ) + { + // set name., owner, password again (less memory) + cache_get_field_content( i, "NAME", house_name, dbHandle, 30 ); + cache_get_field_content( i, "PASSWORD", password, dbHandle, 5 ); + cache_get_field_content( i, "OWNER", owner, dbHandle, 24 ); + + // create home handle + new house_sql_id = cache_get_field_content_int( i, "ID", dbHandle ); + new handle = CreateHouse( house_name, + cache_get_field_content_int( i, "COST", dbHandle ), + cache_get_field_content_float( i, "EX", dbHandle ), + cache_get_field_content_float( i, "EY", dbHandle ), + cache_get_field_content_float( i, "EZ", dbHandle ), + cache_get_field_content_float( i, "TX", dbHandle ), + cache_get_field_content_float( i, "TY", dbHandle ), + cache_get_field_content_float( i, "TZ", dbHandle ), + cache_get_field_content_int( i, "INTERIOR", dbHandle ), + password, owner, house_sql_id + ); + + if ( handle != ITER_NONE ) { + // store weapon information + cache_get_field_content( i, "WEAPONS", weapon_info ), sscanf( weapon_info, "p<.>e", g_HouseWeapons[ handle ] ); + cache_get_field_content( i, "AMMO", weapon_info ), sscanf( weapon_info, "p<.>e", g_HouseWeaponAmmo[ handle ] ); + } + } + } + printf( "[HOUSES]: %d houses have been loaded. (Tick: %dms)", rows, GetTickCount( ) - loadingTick ); + + // Make Lorenc the owner of unowned VIP houses + foreach ( new houseid : houses ) if ( g_houseData[ houseid ] [ E_COST ] < 10000 ) { + if ( strmatch( g_houseData[ houseid ] [ E_OWNER ], "No-one" ) ) { + SetHouseOwner( houseid, "Lorenc" ); + } + } + + // The server crashes when the fires aren't correctly loaded. + CreateFire( ); + return 1; +} + +/* ** Functions ** */ +stock CreateHouse( house_name[ 30 ], cost, Float: eX, Float: eY, Float: eZ, Float: tX = H_DEFAULT_X, Float: tY = H_DEFAULT_Y, Float: tZ = H_DEFAULT_Z, interior = 2, password[ 5 ] = "N/A", owner[ 24 ] = "No-one", sql_id = ITER_NONE ) +{ + new + hID = ( 0 <= sql_id < MAX_HOUSES ) ? sql_id : Iter_Free( houses ); + + if ( Iter_Contains( houses, sql_id ) ) + hID = ITER_NONE; + + if ( hID != ITER_NONE ) + { + Iter_Add( houses, hID ); + + // set house name, password, owner + format( g_houseData[ hID ] [ E_HOUSE_NAME ], 30, "%s", house_name ); + format( g_houseData[ hID ] [ E_PASSWORD ], 5, "%s", password ); + format( g_houseData[ hID ] [ E_OWNER ], 24, "%s", owner ); + + // set home variables + g_houseData[ hID ] [ E_COST ] = cost; + g_houseData[ hID ] [ E_EX ] = eX; + g_houseData[ hID ] [ E_EY ] = eY; + g_houseData[ hID ] [ E_EZ ] = eZ; + g_houseData[ hID ] [ E_TX ] = tX; + g_houseData[ hID ] [ E_TY ] = tY; + g_houseData[ hID ] [ E_TZ ] = tZ; + g_houseData[ hID ] [ E_INTERIOR_ID ] = interior; + g_houseData[ hID ] [ E_WORLD ] = ( hID + MAX_HOUSES ); + + // reset weapons (in case) + for( new i; i < MAX_HOUSE_WEAPONS; i++ ) { + g_HouseWeapons[ hID ] [ i ] = 0, g_HouseWeaponAmmo[ hID ] [ i ] = -1; + } + + // prefurnish home + if ( sql_id == ITER_NONE ) FillHomeWithFurniture( hID, 0 ); + + // set global + g_houseData[ hID ] [ E_MAP_ICON ] = strmatch( owner, "No-one" ) ? CreateDynamicMapIcon( eX, eY, eZ, 31, 0, -1, -1, -1, HOUSE_MAPICON_RADIUS ) : -1; + + g_houseData[ hID ] [ E_CHECKPOINT ] [ 0 ] = CreateDynamicCP( eX, eY, eZ, 1.0, -1, 0, -1, 100.0 ); + g_houseData[ hID ] [ E_CHECKPOINT ] [ 1 ] = CreateDynamicCP( tX, tY, tZ, 1.0, g_houseData[ hID ] [ E_WORLD ], g_houseData[ hID ] [ E_INTERIOR_ID ], -1, 100.0 ); + + format( szBigString, sizeof( szBigString ), ""COL_GOLD"House:"COL_WHITE" %s(%d)\n"COL_GOLD"Owner:"COL_WHITE" %s\n"COL_GOLD"Price:"COL_WHITE" %s", g_houseData[ hID ] [ E_HOUSE_NAME ], hID, g_houseData[ hID ] [ E_OWNER ], number_format( cost ) ); + + g_houseData[ hID ] [ E_LABEL ] [ 0 ] = CreateDynamic3DTextLabel( szBigString, COLOR_WHITE, eX, eY, eZ, 20.0 ); + g_houseData[ hID ] [ E_LABEL ] [ 1 ] = CreateDynamic3DTextLabel( "[EXIT]", COLOR_GOLD, tX, tY, tZ, 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, g_houseData[ hID ] [ E_WORLD ] ); + + // insert if non existant prior + if ( sql_id == ITER_NONE ) { + format( szBigString, sizeof( szBigString ), "INSERT INTO `HOUSES` VALUES (%d,'Home','No-one',%d,%f,%f,%f,%f,%f,%f,%d,'N/A','0.0.0.0.0.0.0.','-1.-1.-1.-1.-1.-1.-1.')", hID, cost, eX, eY, eZ, tX, tY, tZ, interior ); + mysql_single_query( szBigString ); + } + } + return hID; +} + +stock DestroyHouse( houseid ) +{ + if ( ! Iter_Contains( houses, houseid ) ) + return 0; + + new + query[ 40 ], + playerid = GetPlayerIDFromName( g_houseData[ houseid ] [ E_OWNER ] ) + ; + + if ( IsPlayerConnected( playerid ) ) + { + SendClientMessage( playerid, -1, ""COL_PINK"[HOUSE]"COL_WHITE" One of your houses has been destroyed."); + p_OwnedHouses[ playerid ] --; + } + + format( query, sizeof( query ), "DELETE FROM HOUSES WHERE ID=%d", houseid ); + mysql_single_query( query ); + destroyAllFurniture( houseid ); + g_houseData[ houseid ] [ E_HOUSE_NAME ] [ 0 ] = '\0'; + g_houseData[ houseid ] [ E_OWNER ] [ 0 ] = '\0'; + DestroyDynamicMapIcon( g_houseData[ houseid ] [ E_MAP_ICON ] ); + DestroyDynamicCP( g_houseData[ houseid ] [ E_CHECKPOINT ] [ 0 ] ); + DestroyDynamicCP( g_houseData[ houseid ] [ E_CHECKPOINT ] [ 1 ] ); + DestroyDynamic3DTextLabel( g_houseData[ houseid ] [ E_LABEL ] [ 0 ] ); + DestroyDynamic3DTextLabel( g_houseData[ houseid ] [ E_LABEL ] [ 1 ] ); + Iter_Remove( houses, houseid ); + return 1; +} + +stock SetHouseForAuction( ID ) +{ + if ( ID == -1 ) + return 0; + + if ( ! Iter_Contains( houses, ID ) ) + return 0; + + new + query[ 128 ], + player = GetPlayerIDFromName( g_houseData[ ID ] [ E_OWNER ] ) + ; + + if ( IsPlayerConnected( player ) ) + { + SendClientMessage( player, -1, ""COL_PINK"[HOUSE]"COL_WHITE" One of your houses has been taken for auction."); + p_OwnedHouses[ player ] --; + } + for( new i; i < MAX_HOUSE_WEAPONS; i++ ) { g_HouseWeapons[ ID ] [ i ] = 0, g_HouseWeaponAmmo[ ID ] [ i ] = -1; } + format( g_houseData[ ID ] [ E_PASSWORD ], 4, "N/A" ); + format( g_houseData[ ID ] [ E_OWNER ], 7, "No-one" ); + format( g_houseData[ ID ] [ E_HOUSE_NAME ], 5, "Home" ); + g_houseData[ ID ] [ E_TX ] = g_houseInteriors[ 0 ] [ E_EX ]; + g_houseData[ ID ] [ E_TY ] = g_houseInteriors[ 0 ] [ E_EY ]; + g_houseData[ ID ] [ E_TZ ] = g_houseInteriors[ 0 ] [ E_EZ ]; + g_houseData[ ID ] [ E_INTERIOR_ID ] = 2; + destroyAllFurniture( ID ); + FillHomeWithFurniture( ID, 0 ); + format( query, sizeof( query ), "UPDATE HOUSES SET OWNER='No-one',PASSWORD='N/A',NAME='Home',TX=%f,TY=%f,TZ=%f,INTERIOR=%d WHERE ID=%d", g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], g_houseData[ ID ] [ E_INTERIOR_ID ], ID ); + mysql_single_query( query ); + format( szBigString, sizeof( szBigString ), ""COL_GOLD"House:"COL_WHITE" Home(%d)\n"COL_GOLD"Owner:"COL_WHITE" No-one\n"COL_GOLD"Price:"COL_WHITE" %s", ID, number_format( g_houseData[ ID ] [ E_COST ] ) ); + UpdateDynamic3DTextLabelText( g_houseData[ ID ] [ E_LABEL ] [ 0 ], COLOR_WHITE, szBigString); + DestroyDynamic3DTextLabel( g_houseData[ ID ] [ E_LABEL ] [ 1 ] ); + g_houseData[ ID ] [ E_LABEL ] [ 1 ] = CreateDynamic3DTextLabel( "[EXIT]", COLOR_GOLD, g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, g_houseData[ ID ] [ E_WORLD ] ); + DestroyDynamicCP( g_houseData[ ID ] [ E_CHECKPOINT ] [ 1 ] ); + g_houseData[ ID ] [ E_CHECKPOINT ] [ 1 ] = CreateDynamicCP( g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], 1.0, g_houseData[ ID ] [ E_WORLD ], g_houseData[ ID ] [ E_INTERIOR_ID ], -1, 50.0 ); + DestroyDynamicMapIcon( g_houseData[ ID ] [ E_MAP_ICON ] ); + g_houseData[ ID ] [ E_MAP_ICON ] = CreateDynamicMapIcon( g_houseData[ ID ] [ E_EX ], g_houseData[ ID ] [ E_EY ], g_houseData[ ID ] [ E_EZ ], 31, 0, -1, -1, -1, HOUSE_MAPICON_RADIUS ); + return 1; +} + +stock SetHouseOwner( houseid, szOwner[ MAX_PLAYER_NAME ] ) +{ + if ( ! Iter_Contains( houses, houseid ) || isnull( szOwner ) ) + return 0; + + new + query[ 128 ] + ; + format( g_houseData[ houseid ] [ E_OWNER ], 24, "%s", szOwner ); + + format( query, sizeof( query ), "UPDATE HOUSES SET OWNER='%s' WHERE ID=%d", mysql_escape( szOwner ), houseid ); + mysql_single_query( query ); + + DestroyDynamicMapIcon( g_houseData[ houseid ] [ E_MAP_ICON ] ); + format( szBigString, sizeof( szBigString ), ""COL_GOLD"House:"COL_WHITE" Home(%d)\n"COL_GOLD"Owner:"COL_WHITE" %s\n"COL_GOLD"Price:"COL_WHITE" %s", houseid, g_houseData[ houseid ] [ E_OWNER ], number_format( g_houseData[ houseid ] [ E_COST ] ) ); + UpdateDynamic3DTextLabelText( g_houseData[ houseid ] [ E_LABEL ] [ 0 ], COLOR_WHITE, szBigString); + return 1; +} + +stock SwitchHouseOwners( ID, playerid, buyerid ) +{ + if ( IsPlayerConnected( playerid ) ) + { + p_OwnedHouses[ playerid ] --; + SetPlayerInterior( playerid, 0 ); + SetPlayerVirtualWorld( playerid, 0 ); + SendServerMessage( playerid, "You have successfully sold your house for "COL_GOLD"%s", number_format( ( g_houseData[ ID ] [ E_COST ] / 2 ) ) ); + SetPlayerPos( playerid, g_houseData[ ID ] [ E_EX ], g_houseData[ ID ] [ E_EY ], g_houseData[ ID ] [ E_EZ ] ); + } + + strcpy( g_houseData[ ID ] [ E_PASSWORD ], "N/A" ); + strcpy( g_houseData[ ID ] [ E_HOUSE_NAME ], "Home" ); + format( g_houseData[ ID ] [ E_OWNER ], 7, "%s", ReturnPlayerName( buyerid ) ); + + format( szBigString, sizeof( szBigString ), "UPDATE HOUSES SET OWNER='%s',PASSWORD='N/A',NAME='Home' WHERE ID=%d", mysql_escape( ReturnPlayerName( buyerid ) ) , ID ); + mysql_single_query( szBigString ); + + format( szBigString, sizeof( szBigString ), ""COL_GOLD"House:"COL_WHITE" Home(%d)\n"COL_GOLD"Owner:"COL_WHITE" No-one\n"COL_GOLD"Price:"COL_WHITE" %s", ID, number_format( g_houseData[ ID ] [ E_COST ] ) ); + UpdateDynamic3DTextLabelText( g_houseData[ ID ] [ E_LABEL ] [ 0 ], COLOR_WHITE, szBigString ); + + DestroyDynamic3DTextLabel( g_houseData[ ID ] [ E_LABEL ] [ 1 ] ); + g_houseData[ ID ] [ E_LABEL ] [ 1 ] = CreateDynamic3DTextLabel( "[EXIT]", COLOR_GOLD, g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, g_houseData[ ID ] [ E_WORLD ] ); + + DestroyDynamicCP( g_houseData[ ID ] [ E_CHECKPOINT ] [ 1 ] ); + g_houseData[ ID ] [ E_CHECKPOINT ] [ 1 ] = CreateDynamicCP( g_houseData[ ID ] [ E_TX ], g_houseData[ ID ] [ E_TY ], g_houseData[ ID ] [ E_TZ ], 1.0, g_houseData[ ID ] [ E_WORLD ], g_houseData[ ID ] [ E_INTERIOR_ID ], -1, 50.0 ); + + DestroyDynamicMapIcon( g_houseData[ ID ] [ E_MAP_ICON ] ); +} + +stock GetPlayerOwnedHouses( playerid ) +{ + new + count = 0; + + foreach ( new i : houses ) if ( IsPlayerHomeOwner( playerid, i ) ) { + count ++; + } + return count; +} + +stock ShowHouseWeaponStorage( playerid ) +{ + if ( !IsPlayerConnected( playerid ) ) + return 0; + + new id = p_InHouse[ playerid ]; + if ( id == -1 ) return SendError( playerid, "You're not inside any house." ); + if ( !strmatch( g_houseData[ id ] [ E_OWNER ], ReturnPlayerName( playerid ) ) ) return SendError( playerid, "You are not the owner of this house." ); + szLargeString[ 0 ] = '\0'; + for( new i = 0; i < MAX_HOUSE_WEAPONS; i++ ) + { + if ( g_HouseWeapons[ id ] [ i ] != 0 ) + format( szLargeString, sizeof( szLargeString ), "%s%s%s(%d)\n", szLargeString, i > 2 ? (""#COL_GOLD"") : ("{FFFFFF}"), ReturnWeaponName( g_HouseWeapons[ id ] [ i ] ), g_HouseWeaponAmmo[ id ] [ i ] ); + else + strcat( szLargeString, i > 2 ? ( ""COL_GOLD"Empty\n" ) : ( ""COL_WHITE"Empty\n" ) ); + + } + ShowPlayerDialog( playerid, DIALOG_HOUSE_WEAPONS, DIALOG_STYLE_LIST, "{FFFFFF}House Weapon Storage", szLargeString, "Withdraw", "Back" ); + return 1; +} + +stock SaveHouseWeaponStorage( houseid ) +{ + new szWeapon[ 21 ], szAmmo[ 50 ]; + for( new i; i < MAX_HOUSE_WEAPONS; i++ ) + { + format( szWeapon, sizeof( szWeapon ), "%s%d.", szWeapon, g_HouseWeapons[ houseid ] [ i ] ); + format( szAmmo, sizeof( szAmmo ), "%s%d.", szAmmo, g_HouseWeaponAmmo[ houseid ] [ i ] ); + } + format( szBigString, sizeof( szBigString ), "UPDATE `HOUSES` SET `WEAPONS`='%s',`AMMO`='%s' WHERE `ID`=%d", szWeapon, szAmmo, houseid ); + mysql_single_query( szBigString ); + return 1; +} + +stock ArePlayersInHouse( houseid, owner ) +{ + foreach ( new i : Player ) if ( i != owner ) + { + if ( p_InHouse[ i ] == houseid ) + { + if ( GetPlayerVirtualWorld( i ) == g_houseData[ houseid ] [ E_WORLD ] ) + return true; + + p_InHouse[ i ] = -1; // They're bugged probably + } + } + return false; +} diff --git a/gamemodes/irresistible/cnr/player.pwn b/gamemodes/irresistible/cnr/player.pwn index 9de2382..727e7ea 100644 --- a/gamemodes/irresistible/cnr/player.pwn +++ b/gamemodes/irresistible/cnr/player.pwn @@ -54,7 +54,6 @@ new bool: p_Spectating [ MAX_PLAYERS char ], bool: p_Muted [ MAX_PLAYERS char ], bool: p_InfectedHIV [ MAX_PLAYERS char ], - p_InHouse [ MAX_PLAYERS ], p_ExperienceHideTimer [ MAX_PLAYERS ], p_AntiTextSpam [ MAX_PLAYERS ], bool: p_BlockedPM [ MAX_PLAYERS ] [ MAX_PLAYERS ], @@ -238,8 +237,6 @@ new p_Fireworks [ MAX_PLAYERS ], p_ExplosiveBullets [ MAX_PLAYERS ], bool: p_AddedEmail [ MAX_PLAYERS char ], - p_SpawningKey [ MAX_PLAYERS ] [ 4 ], - p_SpawningIndex [ MAX_PLAYERS ], p_TazingImmunity [ MAX_PLAYERS ], p_PlayerAltBind [ MAX_PLAYERS ] = { -1, ... }, p_PlayerAltBindTick [ MAX_PLAYERS ]