Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- HOUSE SYSTEM 1.00
- LAST UPDATE: 22/05/2017
- [>] Script made by - Filip.
- Contacts: @filip2000 (TELEGRAM)
- filip.jurewicz11 (SKYPE)
- */
- #define MAX_HOUSES 500
- #define PICKUP_HOUSE_SALE 1272
- #define PICKUP_HOUSE_SOLD 1273
- #define PICKUP_HOUSE_TYPE 23
- #define HOUSE_AREA_RANGE 2.0
- enum E_HOUSE_INFO
- {
- ID,
- hOwner[MAX_PLAYER_NAME],
- Float: hX,
- Float: hY,
- Float: hZ,
- Float: hAngle,
- hInterior,
- hInt,
- hVW,
- hPrice,
- hOwned,
- hDoor,
- hSafe,
- hPickup,
- Text3D: hLabel,
- hCreatedAt[12]
- };
- enum E_HOUSE_INTERIOR_INFO
- {
- Float: iX,
- Float: iY,
- Float: iZ,
- ID
- };
- new HouseInteriors[][E_HOUSE_INTERIOR_INFO] =
- {
- {2233.4900, -1114.4435, 1050.8828, 5},
- {2196.3943, -1204.1359, 1049.0234, 6},
- {2318.1616, -1026.3762, 1050.2109, 9},
- {421.8333, 2536.9814, 10.0000, 10},
- {225.5707, 1240.0643, 1082.1406, 2},
- {2496.2087, -1692.3149, 1014.7422, 3},
- {226.7545, 1114.4180, 1080.9952, 5},
- {2269.9636, -1210.3275, 1047.5625, 10}
- };
- new
- HouseInfo[MAX_HOUSES][E_HOUSE_INFO],
- Iterator: HouseIter<MAX_HOUSES>;
- #define HOUSE_MAGIC 1000
- #define _house_included
- new houseArea[MAX_HOUSES];
- new PlayerText: houseText[MAX_PLAYERS][1];
- new playerHouseArea[MAX_PLAYERS];
- new playerInsideHouse[MAX_PLAYERS];
- public OnGameModeInit()
- {
- House_Load();
- #if defined h_OnGameModeInit
- h_OnGameModeInit();
- #endif
- return 1;
- }
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit h_OnGameModeInit
- #if defined h_OnGameModeInit
- forward h_OnGameModeInit();
- #endif
- public OnPlayerConnect(playerid)
- {
- House_CreateTD(playerid);
- House_ResetStats(playerid);
- #if defined h_OnPlayerConnect
- h_OnPlayerConnect(playerid);
- #endif
- return 1;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect h_OnPlayerConnect
- #if defined h_OnPlayerConnect
- forward h_OnPlayerConnect(playerid);
- #endif
- public OnPlayerEnterDynamicArea(playerid, areaid)
- {
- new houseid = Streamer_GetIntData(STREAMER_TYPE_AREA, areaid, E_STREAMER_EXTRA_ID) - HOUSE_MAGIC;
- if(0 <= houseid < MAX_HOUSES)
- {
- playerHouseArea[playerid] = houseid;
- if(HouseInfo[houseid][hOwned])
- {
- PlayerTextDrawSetString(playerid, houseText[playerid][0], sprintf("~w~Press_~y~/henter~w~_to_enter_inside_this_house."));
- PlayerTextDrawShow(playerid, houseText[playerid][0]);
- }
- else
- {
- PlayerTextDrawSetString(playerid, houseText[playerid][0], sprintf("~w~Press_~y~/henter~w~_to_enter_inside_this_house.~n~Press_~y~/buyhouse~w~_to_buy_this_house.~n~Price:_~y~%i~w~$", HouseInfo[houseid][hPrice]));
- PlayerTextDrawShow(playerid, houseText[playerid][0]);
- }
- }
- #if defined h_OnPlayerEnterDynamicArea
- return h_OnPlayerEnterDynamicArea(playerid, areaid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerEnterDynamicArea
- #undef OnPlayerEnterDynamicArea
- #else
- #define _ALS_OnPlayerEnterDynamicArea
- #endif
- #define OnPlayerEnterDynamicArea h_OnPlayerEnterDynamicArea
- #if defined h_OnPlayerEnterDynamicArea
- forward h_OnPlayerEnterDynamicArea(playerid, areaid);
- #endif
- public OnPlayerLeaveDynamicArea(playerid, areaid)
- {
- if(playerHouseArea[playerid] >= 0)
- {
- playerHouseArea[playerid] = -1;
- PlayerTextDrawHide(playerid, houseText[playerid][0]);
- }
- #if defined h_OnPlayerLeaveDynamicArea
- return h_OnPlayerLeaveDynamicArea(playerid, areaid);
- #else
- return 1;
- #endif
- }
- #if defined _ALS_OnPlayerLeaveDynamicArea
- #undef OnPlayerLeaveDynamicArea
- #else
- #define _ALS_OnPlayerLeaveDynamicArea
- #endif
- #define OnPlayerLeaveDynamicArea h_OnPlayerLeaveDynamicArea
- #if defined h_OnPlayerLeaveDynamicArea
- forward h_OnPlayerLeaveDynamicArea(playerid, areaid);
- #endif
- House_Load() return mysql_tquery(handlesql, "SELECT * FROM `houses` ORDER BY `ID`", "House_OnLoad", "");
- House_OnLoad(); public House_OnLoad()
- {
- new rows = cache_num_rows();
- if(rows)
- {
- for(new i; i < rows; i++)
- {
- new id = Iter_Free(HouseIter);
- if(id != -1)
- {
- cache_get_value_int(i, "ID", HouseInfo[id][ID]);
- cache_get_value(i, "h_Owner", HouseInfo[id][hOwner], MAX_PLAYER_NAME);
- cache_get_value(i, "h_CreatedAt", HouseInfo[id][hCreatedAt], 12);
- cache_get_value_float(i, "h_X", HouseInfo[id][hX]);
- cache_get_value_float(i, "h_Y", HouseInfo[id][hZ]);
- cache_get_value_float(i, "h_Z", HouseInfo[id][hY]);
- cache_get_value_float(i, "h_Angle", HouseInfo[id][hAngle]);
- cache_get_value_int(i, "h_Interior", HouseInfo[id][hInterior]);
- cache_get_value_int(i, "h_Int", HouseInfo[id][hInt]);
- cache_get_value_int(i, "h_VW", HouseInfo[id][hVW]);
- cache_get_value_int(i, "h_Price", HouseInfo[id][hPrice]);
- cache_get_value_int(i, "h_Owned", HouseInfo[id][hOwned]);
- cache_get_value_int(i, "h_Door", HouseInfo[id][hDoor]);
- cache_get_value_int(i, "h_Safe", HouseInfo[id][hSafe]);
- Iter_Add(HouseIter, id);
- }
- }
- }
- printf("[House] %i houses was loaded.", rows);
- }
- House_Created(houseid); public House_Created(houseid)
- {
- HouseInfo[houseid][ID] = cache_insert_id();
- return House_Save(houseid);
- }
- House_Create(Float: X, Float: Y, Float: Z, Float: Angle, Interior, Int, Virtualworld, Price)
- {
- new id = Iter_Free(HouseIter);
- if(id != -1)
- {
- new mounths, days, years;
- House_SetInterior(id, Interior);
- format(HouseInfo[id][hOwner], MAX_PLAYER_NAME, "n/a");
- HouseInfo[id][hOwned] = 0;
- HouseInfo[id][hPrice] = Price;
- HouseInfo[id][hVW] = Virtualworld;
- HouseInfo[id][hInt] = Int;
- HouseInfo[id][hX] = X;
- HouseInfo[id][hY] = Y;
- HouseInfo[id][hZ] = Z;
- HouseInfo[id][hAngle] = Angle;
- getdate(years, mounths, days);
- format(HouseInfo[id][hCreatedAt], 12, "%i/%i/%i", days, mounths, years);
- Iter_Add(HouseIter, id);
- mysql_tquery(handlesql, "INSERT INTO `houses` (`h_X`) VALUES (0)", "House_Created", "i", id);
- }
- return id;
- }
- House_Save(houseid)
- {
- new query[256];
- mysql_format(handlesql, query, sizeof query, "UPDATE `houses` SET `h_X` = '%f', `h_Y` = '%f', `h_Z` = '%f', `h_Angle` = '%f', `h_VW` = '%i', `h_Interior` = '%i', `h_Price` = '%i', `h_Owner` = '%e', `h_CreatedAt` = '%e', `h_Safe` = '%i', `h_Int` = '%i', `h_Owned` = '%i' WHERE `ID` = '%i'",
- HouseInfo[houseid][hX],
- HouseInfo[houseid][hY],
- HouseInfo[houseid][hZ],
- HouseInfo[houseid][hAngle],
- HouseInfo[houseid][hVW],
- HouseInfo[houseid][hInterior],
- HouseInfo[houseid][hPrice],
- HouseInfo[houseid][hOwner],
- HouseInfo[houseid][hCreatedAt],
- HouseInfo[houseid][hSafe],
- HouseInfo[houseid][hInt],
- HouseInfo[houseid][hOwned],
- HouseInfo[houseid][ID]);
- mysql_tquery(handlesql, query);
- House_Refresh(houseid);
- return 1;
- }
- House_Delete(houseid)
- {
- new query[128];
- mysql_format(handlesql, query, sizeof query, "DELETE FROM `houses` WHERE `ID` = '%i'", HouseInfo[houseid][ID]);
- mysql_query(handlesql, query);
- HouseInfo[houseid][hOwner] = EOS;
- HouseInfo[houseid][hCreatedAt] = EOS;
- HouseInfo[houseid][hPrice] = HouseInfo[houseid][hVW] =
- HouseInfo[houseid][hInterior] = HouseInfo[houseid][hInt] =
- HouseInfo[houseid][hOwned] = HouseInfo[houseid][hSafe] =
- HouseInfo[houseid][hDoor] = HouseInfo[houseid][ID] = -1;
- HouseInfo[houseid][hX] = HouseInfo[houseid][hY] =
- HouseInfo[houseid][hZ] = HouseInfo[houseid][hAngle] = 0.0;
- DestroyDynamicPickup(HouseInfo[houseid][hPickup]);
- DestroyDynamicArea(houseArea[houseid]);
- DestroyDynamic3DTextLabel(HouseInfo[houseid][hLabel]);
- Iter_Remove(HouseIter, houseid);
- return 1;
- }
- House_Refresh(houseid)
- {
- DestroyDynamicPickup(HouseInfo[houseid][hPickup]);
- DestroyDynamicArea(houseArea[houseid]);
- DestroyDynamic3DTextLabel(HouseInfo[houseid][hLabel]);
- House_CreatePickup(houseid);
- House_CreateSphere(houseid);
- House_Create3DText(houseid);
- return 1;
- }
- House_CreatePickup(houseid)
- {
- HouseInfo[houseid][hPickup] = CreateDynamicPickup(HouseInfo[houseid][hOwned] ? PICKUP_HOUSE_SOLD : PICKUP_HOUSE_SALE,
- PICKUP_HOUSE_TYPE,
- HouseInfo[houseid][hX],
- HouseInfo[houseid][hY],
- HouseInfo[houseid][hZ],
- HouseInfo[houseid][hVW],
- HouseInfo[houseid][hInt]);
- return HouseInfo[houseid][hPickup];
- }
- House_CreateSphere(houseid)
- {
- houseArea[houseid] = CreateDynamicSphere(
- HouseInfo[houseid][hX],
- HouseInfo[houseid][hY],
- HouseInfo[houseid][hZ],
- HOUSE_AREA_RANGE,
- HouseInfo[houseid][hVW],
- HouseInfo[houseid][hInt]);
- Streamer_SetIntData(STREAMER_TYPE_AREA, houseArea[houseid], E_STREAMER_EXTRA_ID, houseid + HOUSE_MAGIC);
- return houseArea[houseid];
- }
- House_Create3DText(houseid)
- {
- new str[128];
- if(HouseInfo[houseid][hOwned] == 0)
- format(str, sizeof str, "House [%i]\nPrice: %i$", houseid, HouseInfo[houseid][hPrice]);
- else
- format(str, sizeof str, "House [%i]\nOwner: %s", houseid, HouseInfo[houseid][hOwner]);
- HouseInfo[houseid][hLabel] = CreateDynamic3DTextLabel(str, -1,
- HouseInfo[houseid][hX], HouseInfo[houseid][hY], HouseInfo[houseid][hZ], 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, HouseInfo[houseid][hVW], HouseInfo[houseid][hInt]);
- return 1;
- }
- House_SetInterior(id, int) return HouseInfo[id][hInterior] = HouseInteriors[int][ID];
- House_Sell(houseid)
- {
- HouseInfo[houseid][hOwner] = EOS;
- HouseInfo[houseid][hDoor] = HouseInfo[houseid][hSafe] = HouseInfo[houseid][hOwned] = 0;
- House_Save(houseid);
- return 1;
- }
- House_ResetStats(playerid)
- {
- playerHouseArea[playerid] = playerInsideHouse[playerid] = -1;
- return 1;
- }
- House_CreateTD(playerid)
- {
- houseText[playerid][0] = CreatePlayerTextDraw(playerid, 21.555515, 116.826690, "Press_/henter_to_enter_inside_this_house.~n~Press_/buyhouse_to_buy_this_house.~n~Price:_0000$");
- PlayerTextDrawLetterSize(playerid, houseText[playerid][0], 0.186222, 1.052444);
- PlayerTextDrawTextSize(playerid, houseText[playerid][0], 154.000000, 0.000000);
- PlayerTextDrawAlignment(playerid, houseText[playerid][0], 1);
- PlayerTextDrawColor(playerid, houseText[playerid][0], -1);
- PlayerTextDrawUseBox(playerid, houseText[playerid][0], 1);
- PlayerTextDrawBoxColor(playerid, houseText[playerid][0], 150);
- PlayerTextDrawSetShadow(playerid, houseText[playerid][0], 0);
- PlayerTextDrawSetOutline(playerid, houseText[playerid][0], 1);
- PlayerTextDrawBackgroundColor(playerid, houseText[playerid][0], 255);
- PlayerTextDrawFont(playerid, houseText[playerid][0], 1);
- PlayerTextDrawSetProportional(playerid, houseText[playerid][0], 1);
- PlayerTextDrawSetShadow(playerid, houseText[playerid][0], 0);
- return 1;
- }
- CMD:ahouse(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF6347FF, "You are not authorized to use this command.");
- new
- cmd[32], value_1, value_2;
- if(sscanf(params, "s[32]D(-1)D(-1)", cmd, value_1, value_2))
- {
- SendClientMessage(playerid, 0xFF6347FF, "SYNTAX{FFFFFF}: /ahouse [cmd]");
- SendClientMessage(playerid, 0xFF6347FF, ">{FFFFFF} create | save | delete");
- SendClientMessage(playerid, 0xFF6347FF, ">{FFFFFF} stats | near | sell | createdat");
- return 1;
- }
- if(!strcmp(cmd, "create", false))
- {
- if(value_1 == -1) return SendClientMessage(playerid, 0xFF6347FF, "SYNTAX{FFFFFF}: /ahouse create [interior] [price]");
- if(value_1 < 0 || value_1 > sizeof HouseInteriors) return SendClientMessage(playerid, 0xFF6347FF, "ERROR: {FFFFFF}Invalid interior ID. (0, 7)");
- if(value_2 == -1) return SendClientMessage(playerid, 0xFF6347FF, "SYNTAX{FFFFFF}: /ahouse create [interior] [price]");
- new Float: X, Float: Y, Float: Z, Float: Angle;
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(playerid, Angle);
- new id = House_Create(X, Y, Z, Angle, value_1, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid), value_2);
- if(id == -1) return SendClientMessage(playerid, 0xFF6347FF, "ERROR: {FFFFFF}Can't create more houses.");
- SendClientMessage(playerid, 0xFF6347FF, "AdmCmd{FFFFFF}: House has been created.");
- return 1;
- }
- if(!strcmp(cmd, "save", false))
- {
- if(!Iter_Contains(HouseIter, value_1)) return SendClientMessage(playerid, 0xFF6347FF, "ERROR: {FFFFFF}Invalid house ID.");
- SendClientMessage(playerid, 0xFF6347FF, sprintf("AdmCmd: {FFFFFF}House #%i has been updated.", value_1));
- House_Save(value_1);
- return 1;
- }
- if(!strcmp(cmd, "delete", false))
- {
- if(!Iter_Contains(HouseIter, value_1)) return SendClientMessage(playerid, 0xFF6347FF, "ERROR: {FFFFFF}Invalid house ID.");
- SendClientMessage(playerid, 0xFF6347FF, sprintf("AdmCmd: {FFFFFF}House #%i has been deleted.", value_1));
- House_Delete(value_1);
- return 1;
- }
- if(!strcmp(cmd, "near", false))
- {
- new str[128];
- if(playerHouseArea[playerid] >= 0) format(str, sizeof str, "AdmCmd: {FFFFFF}You are near house #%i.", playerHouseArea[playerid]);
- else format(str, sizeof str, "AdmCmd: {FFFFFF}You are not near house.");
- return SendClientMessage(playerid, 0xFF6347FF, str);
- }
- if(!strcmp(cmd, "sell", false))
- {
- if(!Iter_Contains(HouseIter, value_1)) return SendClientMessage(playerid, 0xFF6347FF, "ERROR: {FFFFFF}Invalid house ID.");
- if(!HouseInfo[value_1][hOwned]) return SendClientMessage(playerid, 0xFF6347FF, "ERROR: {FFFFFF}This house is already set for sale.");
- SendClientMessage(playerid, 0xFF6347FF, sprintf("AdmCmd: {FFFFFF}House #%i has been setup for sale.", value_1));
- House_Sell(value_1);
- }
- if(!strcmp(cmd, "createdat", false))
- {
- if(!Iter_Contains(HouseIter, value_1)) return SendClientMessage(playerid, 0xFF6347FF, "ERROR: {FFFFFF}Invalid house ID.");
- SendClientMessage(playerid, 0xFF6347FF, sprintf("AdmCmd: {FFFFFF}House #%i was created at %s.", HouseInfo[value_1][hCreatedAt]));
- return 1;
- }
- if(!strcmp(cmd, "stats", false))
- {
- if(!Iter_Contains(HouseIter, value_1)) return SendClientMessage(playerid, 0xFF6347FF, "ERROR: {FFFFFF}Invalid house ID.");
- new str[28];
- if(HouseInfo[value_1][hDoor])
- str = "Locked";
- else
- str = "Unlocked";
- SendClientMessage(playerid, 0xFF6347FF, "House Information:");
- SendClientMessage(playerid, -1, sprintf("** ID: %i Database ID: %i - Owner: %s - Door: %s**", value_1, HouseInfo[value_1][ID], HouseInfo[value_1][hOwner], str));
- SendClientMessage(playerid, -1, sprintf("** Safe: %i$ - Interior: %i - Price: %i$ **", HouseInfo[value_1][hSafe], HouseInfo[value_1][hInterior], HouseInfo[value_1][hPrice]));
- return 1;
- }
- return 1;
- }
- CMD:house(playerid, params[])
- {
- new
- cmd[32], value_1, value_2;
- if(sscanf(params, "s[32]D(-1)D(-1)", cmd, value_1, value_2))
- {
- SendClientMessage(playerid, 0xFF6347FF, "SYNTAX{FFFFFF}: /house [cmd]");
- SendClientMessage(playerid, 0xFF6347FF, ">{FFFFFF} door | withdraw | deposit | balance");
- return 1;
- }
- if(!strcmp(cmd, "door", false))
- {
- if(playerHouseArea[playerid] >= 0 || playerInsideHouse[playerid] >= 0)
- {
- new houseid, name_str[MAX_PLAYER_NAME];
- if(playerHouseArea[playerid] != -1)
- houseid = playerHouseArea[playerid];
- else if(playerInsideHouse[playerid] != -1)
- houseid = playerInsideHouse[playerid];
- GetPlayerName(playerid, name_str, MAX_PLAYER_NAME);
- if(!strcmp(name_str, HouseInfo[houseid][hOwner], false))
- {
- if(HouseInfo[houseid][hDoor])
- HouseInfo[houseid][hDoor] = 0, SendClientMessage(playerid, -1, "Door unlocked.");
- else
- HouseInfo[houseid][hDoor] = 1, SendClientMessage(playerid, -1, "Door locked.");
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near your own house.");
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near house.");
- }
- if(!strcmp(cmd, "withdraw", false))
- {
- if(playerInsideHouse[playerid] >= 0)
- {
- new houseid = playerInsideHouse[playerid], name_str[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name_str, MAX_PLAYER_NAME);
- if(!strcmp(name_str, HouseInfo[houseid][hOwner], false))
- {
- if(value_1 == -1 || value_1 < 0) return SendClientMessage(playerid, 0xFF6347FF, "SYNTAX{FFFFFF}: /house withdraw [amount]");
- if(value_1 > HouseInfo[houseid][hSafe]) return SendClientMessage(playerid, 0xFF6347FF, "Your house haven't this amount.");
- GivePlayerMoney(playerid, value_1);
- House_Save(houseid);
- return 1;
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near your own house.");
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near house.");
- }
- if(!strcmp(cmd, "deposit", false))
- {
- if(playerInsideHouse[playerid] >= 0)
- {
- new houseid = playerInsideHouse[playerid], name_str[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name_str, MAX_PLAYER_NAME);
- if(!strcmp(name_str, HouseInfo[houseid][hOwner], false))
- {
- if(value_1 == -1 || value_1 < 0) return SendClientMessage(playerid, 0xFF6347FF, "SYNTAX{FFFFFF}: /house deposit [amount]");
- if(value_1 > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xFF6347FF, "You haven't this amount.");
- GivePlayerMoney(playerid, -value_1);
- HouseInfo[houseid][hSafe] += value_1;
- House_Save(houseid);
- return 1;
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near your own house.");
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near house.");
- }
- if(!strcmp(cmd, "balance", false))
- {
- if(playerInsideHouse[playerid] >= 0)
- {
- new houseid = playerInsideHouse[playerid], name_str[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name_str, MAX_PLAYER_NAME);
- if(!strcmp(name_str, HouseInfo[houseid][hOwner], false))
- {
- new str[128];
- format(str, sizeof str, "House Safe{FFFFFF}: %i$.", HouseInfo[houseid][hSafe]);
- SendClientMessage(playerid, 0xFF6347FF, str);
- return 1;
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near your own house.");
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near house.");
- }
- return 1;
- }
- CMD:henter(playerid, params[])
- {
- if(playerHouseArea[playerid] >= 0)
- {
- new houseid = playerHouseArea[playerid];
- if(!HouseInfo[houseid][hDoor])
- {
- new name_str[MAX_PLAYER_NAME];
- playerInsideHouse[playerid] = houseid;
- SetPlayerInterior(playerid, HouseInteriors[HouseInfo[houseid][hInterior]][ID]);
- SetPlayerVirtualWorld(playerid, HouseInfo[houseid][ID]);
- SetPlayerPos(playerid, HouseInteriors[HouseInfo[houseid][hInterior]][iX], HouseInteriors[HouseInfo[houseid][hInterior]][iY], HouseInteriors[HouseInfo[houseid][hInterior]][iZ]);
- GetPlayerName(playerid, name_str, MAX_PLAYER_NAME);
- if(!strcmp(name_str, HouseInfo[houseid][hOwner], false))
- {
- SendClientMessage(playerid, 0x9EC73DFF, sprintf("Welcome to your house %s!", name_str));
- SendClientMessage(playerid, -1, "Use /house to see all avaible commands.");
- }
- return 1;
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "Door is locked.");
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near house.");
- }
- CMD:hexit(playerid, params[])
- {
- if(playerInsideHouse[playerid] >= 0)
- {
- new houseid = playerInsideHouse[playerid];
- if(!HouseInfo[houseid][hDoor])
- {
- SetPlayerInterior(playerid, HouseInfo[houseid][hInt]);
- SetPlayerVirtualWorld(playerid, HouseInfo[houseid][hVW]);
- SetPlayerPos(playerid, HouseInfo[houseid][hX], HouseInfo[houseid][hY], HouseInfo[houseid][hZ]);
- SetPlayerFacingAngle(playerid, HouseInfo[houseid][hAngle]);
- playerInsideHouse[playerid] = -1;
- return 1;
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "Door is locked.");
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not inside house.");
- }
- CMD:buyhouse(playerid, params[])
- {
- if(playerHouseArea[playerid] >= 0)
- {
- new houseid = playerHouseArea[playerid];
- if(!HouseInfo[houseid][hOwned])
- {
- if(GetPlayerMoney(playerid < HouseInfo[houseid][hPrice])) return SendClientMessage(playerid, 0xFF6347FF, "You not have enought money to buy this house.");
- new name_str[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name_str, MAX_PLAYER_NAME);
- GivePlayerMoney(playerid, -HouseInfo[houseid][hPrice]);
- HouseInfo[houseid][hOwned] = 1;
- format(HouseInfo[houseid][hOwner], MAX_PLAYER_NAME, "%s", name_str);
- House_Save(houseid);
- SendClientMessage(playerid, 0xFF6347FF, sprintf("> {FFFFFF}You have bought this house for %i$.", HouseInfo[houseid][hPrice]));
- return 1;
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "This house is already sold.");
- }
- else return SendClientMessage(playerid, 0xFF6347FF, "You are not near house.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement