Для начала ко всем enum:
[code]enum hInfo {
hID,
Float:hiX,
Float:hiY,
Float:hiZ,
Float:hvX,
Float:hvY,
Float:hvZ,
hOwner[MAX_PLAYER_NAME],
hPrice,
hInt,
hWorld,
hLock,
hDate,
hLevel,
hvWorld,
hvInt,
hPic,
hPic2,
hMap,
hRoom,
hRent,
hNick1[MAX_PLAYER_NAME],
hNick2[MAX_PLAYER_NAME],
hNick3[MAX_PLAYER_NAME],
hNick4[MAX_PLAYER_NAME],
hNick5[MAX_PLAYER_NAME],
hBank
};
new House[1000][hInfo];
new AllHouse = 0;[/code]

new House[1000][hInfo]; 1000 это кол-во домов на сервере
в public OnGameModeInit():
[code]LoadHouse();[/code]
Дальше создадим стоки loadhouse , savehouse и т.д.
[code]stock LoadHouse() {
new ids[32],str[64];
new iniOpens = ini_openFile(«house/house.cfg»);
ini_getInteger(iniOpens, «AllHouse», AllHouse);
ini_closeFile(iniOpens);
if(AllHouse != 0) {
for(new house = 1; house <= AllHouse; house++) { format(ids,sizeof(ids),"house/%d.ini",house); new inihOpen = ini_openFile(ids); ini_getFloat(inihOpen, "hiX", House[house][hiX]); ini_getFloat(inihOpen, "hiY", House[house][hiY]); ini_getFloat(inihOpen, "hiZ", House[house][hiZ]); ini_getFloat(inihOpen, "hvX", House[house][hvX]); ini_getFloat(inihOpen, "hvY", House[house][hvY]); ini_getFloat(inihOpen, "hvZ", House[house][hvZ]); ini_getString(inihOpen, "hOwner", str); format(House[house][hOwner],24,"%s",str); ini_getInteger(inihOpen, "hPrice", House[house][hPrice]); ini_getInteger(inihOpen, "hInt", House[house][hInt]); ini_getInteger(inihOpen, "hLock", House[house][hLock]); ini_getInteger(inihOpen, "hDate", House[house][hDate]); ini_getInteger(inihOpen, "hLevel", House[house][hLevel]); ini_getInteger(inihOpen, "hvWorld", House[house][hvWorld]); ini_getInteger(inihOpen, "hvInt", House[house][hvInt]); ini_getInteger(inihOpen, "hRoom", House[house][hRoom]); ini_getInteger(inihOpen, "hRent", House[house][hRent]); ini_getString(inihOpen, "hNick1", str); format(House[house][hNick1],24,"%s",str); ini_getString(inihOpen, "hNick2", str); format(House[house][hNick2],24,"%s",str); ini_getString(inihOpen, "hNick3", str); format(House[house][hNick3],24,"%s",str); ini_getString(inihOpen, "hNick4", str); format(House[house][hNick4],24,"%s",str); ini_getString(inihOpen, "hNick5", str); format(House[house][hNick5],24,"%s",str); ini_getInteger(inihOpen, "hBank", House[house][hBank]); ini_closeFile(inihOpen); if(!strcmp(House[house][hOwner],"Nones",false)) { House[house][hPic] = CreateDynamicPickup(1273, 1, House[house][hvX], House[house][hvY], House[house][hvZ],House[house][hvWorld],House[house][hvInt]); House[house][hMap] = CreateDynamicMapIcon(House[house][hvX], House[house][hvY], House[house][hvZ], 31, -1,House[house][hvWorld],House[house][hvInt]); House[house][hPic2] = CreateDynamicPickup(1318, 1, House[house][hiX], House[house][hiY], House[house][hiZ], house, House[house][hInt]); } else { House[house][hPic] = CreateDynamicPickup(1272, 1, House[house][hvX], House[house][hvY], House[house][hvZ],House[house][hvWorld],House[house][hvInt]); // vxod House[house][hMap] = CreateDynamicMapIcon(House[house][hvX], House[house][hvY], House[house][hvZ], 32, -1,House[house][hvWorld],House[house][hvInt]); House[house][hPic2] = CreateDynamicPickup(1318, 1, House[house][hiX], House[house][hiY], House[house][hiZ], house, House[house][hInt]); // int } } printf("Домов загружено: %d",AllHouse); } return 1; } stock SaveHouse(house) { new ids[32]; format(ids,sizeof(ids),"house/%d.ini",house); new inihhhOpen; inihhhOpen = ini_openFile(ids); if(inihhhOpen == -1 || inihhhOpen == -2) inihhhOpen = ini_createFile(ids); ini_setFloat(inihhhOpen, "hiX", House[house][hiX]); ini_setFloat(inihhhOpen, "hiY", House[house][hiY]); ini_setFloat(inihhhOpen, "hiZ", House[house][hiZ]); ini_setFloat(inihhhOpen, "hvX", House[house][hvX]); ini_setFloat(inihhhOpen, "hvY", House[house][hvY]); ini_setFloat(inihhhOpen, "hvZ", House[house][hvZ]); ini_setString(inihhhOpen, "hOwner", House[house][hOwner]); ini_setInteger(inihhhOpen, "hPrice", House[house][hPrice]); ini_setInteger(inihhhOpen, "hInt", House[house][hInt]); ini_setInteger(inihhhOpen, "hLock", House[house][hLock]); ini_setInteger(inihhhOpen, "hDate", House[house][hDate]); ini_setInteger(inihhhOpen, "hLevel", House[house][hLevel]); ini_setInteger(inihhhOpen, "hvWorld", House[house][hvWorld]); ini_setInteger(inihhhOpen, "hvInt", House[house][hvInt]); ini_setInteger(inihhhOpen, "hRoom", House[house][hRoom]); ini_setInteger(inihhhOpen, "hRent", House[house][hRent]); ini_setString(inihhhOpen, "hNick1", House[house][hNick1]); ini_setString(inihhhOpen, "hNick2", House[house][hNick2]); ini_setString(inihhhOpen, "hNick3", House[house][hNick3]); ini_setString(inihhhOpen, "hNick4", House[house][hNick4]); ini_setString(inihhhOpen, "hNick5", House[house][hNick5]); ini_setInteger(inihhhOpen, "hBank", House[house][hBank]); ini_closeFile(inihhhOpen); return 1; } stock UpdateHouse(house) { DestroyDynamicMapIcon(House[house][hMap]); DestroyDynamicPickup(House[house][hPic]); DestroyDynamicPickup(House[house][hPic2]); if(!strcmp(House[house][hOwner],"Nones",false)) { House[house][hPic] = CreateDynamicPickup(1273, 1, House[house][hvX], House[house][hvY], House[house][hvZ],House[house][hvWorld],House[house][hvInt]); House[house][hMap] = CreateDynamicMapIcon(House[house][hvX], House[house][hvY], House[house][hvZ], 31, -1,House[house][hvWorld],House[house][hvInt]); House[house][hPic2] = CreateDynamicPickup(1318, 1, House[house][hiX], House[house][hiY], House[house][hiZ], house, House[house][hInt]); } else { House[house][hPic] = CreateDynamicPickup(1239, 1, House[house][hvX], House[house][hvY], House[house][hvZ],House[house][hvWorld],House[house][hvInt]); // vxod House[house][hMap] = CreateDynamicMapIcon(House[house][hvX], House[house][hvY], House[house][hvZ], 32, -1,House[house][hvWorld],House[house][hvInt]); House[house][hPic2] = CreateDynamicPickup(1318, 1, House[house][hiX], House[house][hiY], House[house][hiZ], house, House[house][hInt]); // int } return 1; }[/code]

и так у нас уже есть загрузка сохранение и обновление домов
Дальше добавим команду /addhouse
[code]if(strcmp(cmd, «/addhouse», true) == 0) {
if(Player[playerid][pAdmin] <= 8) return SendClientMessage(playerid, -1, "У вас нет прав!"); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "Подсказка: /addhouse [Сумма] [Уровень]"); new money = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "Подсказка: /addhouse [Сумма] [Уровень]"); new level = strval(tmp); AllHouse++; GetPlayerPos(playerid, House[AllHouse][hvX],House[AllHouse][hvY],House[AllHouse][hvZ]); format(House[AllHouse][hOwner],24,"Nones"); House[AllHouse][hDate] = gettime(); House[AllHouse][hiX] = -2284.279296; House[AllHouse][hiY] = 90.921600; House[AllHouse][hiZ] = -82.634101; House[AllHouse][hPrice] = money; House[AllHouse][hInt] = 3; House[AllHouse][hLock] = 1; House[AllHouse][hLevel] = level; House[AllHouse][hvWorld] = GetPlayerVirtualWorld(playerid); House[AllHouse][hvInt] = GetPlayerInterior(playerid); format(House[AllHouse][hNick1],24,"Nones"); format(House[AllHouse][hNick2],24,"Nones"); format(House[AllHouse][hNick3],24,"Nones"); format(House[AllHouse][hNick4],24,"Nones"); format(House[AllHouse][hNick5],24,"Nones"); House[AllHouse][hRent] = 0; House[AllHouse][hRoom] = 0; House[AllHouse][hBank] = 0; new inihhOpen = ini_openFile("house/house.cfg"); ini_setInteger(inihhOpen, "AllHouse", AllHouse); ini_closeFile(inihhOpen); SaveHouse(AllHouse); House[AllHouse][hPic] = CreateDynamicPickup(1273, 1, House[AllHouse][hvX], House[AllHouse][hvY], House[AllHouse][hvZ],House[AllHouse][hvWorld],House[AllHouse][hvInt]); House[AllHouse][hMap] = CreateDynamicMapIcon(House[AllHouse][hvX], House[AllHouse][hvY], House[AllHouse][hvZ], 31, -1,House[AllHouse][hvWorld],House[AllHouse][hvInt]); House[AllHouse][hPic2] = CreateDynamicPickup(1318, 1, House[AllHouse][hiX], House[AllHouse][hiY], House[AllHouse][hiZ], AllHouse, House[AllHouse][hInt]); SendClientMessage(playerid, COLOR_GRAD2, "Дом успешно создан"); if(Player[playerid][pAdmin] >=10) {
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), «Администратор: %s[ID%d] создал дом»,sendername,playerid);
ABroadCast(COLOR_LIGHTRED,string,1);
}
return 1;
}[/code]

в public OnPlayerPickUpPickup(playerid, pickupid)
[code]for(new house = 1; house <= AllHouse; house++) { if(IsPlayerInRangeOfPoint(playerid,2.0,House[house][hvX],House[house][hvY],House[house][hvZ])) { GameTextForPlayer(playerid,"~w~ìA„–…E ~r~~k~~PED_SPRINT~",5000,1); return 1; } else if(IsPlayerInRangeOfPoint(playerid,2.0,House[house][hiX],House[house][hiY],House[house][hiZ])) { GameTextForPlayer(playerid,"~w~ìA„–…E ~r~~k~~PED_SPRINT~",5000,1); return 1; } }[/code]
в public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
[code]if(newkeys & KEY_SPRINT)

{
for(new house = 1; house <= AllHouse; house++) { if(IsPlayerInRangeOfPoint(playerid,1.0,House[house][hvX],House[house][hvY],House[house][hvZ]) && GetPlayerVirtualWorld(playerid) == House[house][hvWorld]) { if(!strcmp(House[house][hOwner],"Nones",false)) { format(str,sizeof(str)," {ffffff}Продаётся дом Цена: %d руб (%s) Требуемый уровень: %d (%s) Если хотите купить нажмите "Купить"" Если не хотите нажмите ""Закрыть""""

От danilasar

Это я

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *