7 posts in this topic

Для начала ко всем enum

Спойлер

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;

 

В паблик OnGameModeInit

Спойлер

LoadHouse();

 

Создем сток LoadHouse (в конец мода):

Спойлер

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;
}

 

После LoadHouse вставить SaveHouse:
 

Спойлер

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;
}

 

После SaveHouse вставляем UpdateHouse:

Спойлер

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;
}

 

В OnPlayerCommandText вставляем команду создания дома:

Спойлер

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;
}

 

В паблик OnPlayerPickupPickUp вставляем:

Спойлер

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;
  }
}

 

В паблик OnPlayerKeyStateChange:

Спойлер

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}Продаётся дом\n\n\
Цена: %d руб (%s)\n\
Требуемый уровень: %d (%s)\n\
\n\
Если хотите купить нажмите \"Купить\"\n\
Если не хотите нажмите \"Закрыть\""
               ,House[house][hPrice],(GetPlayerMoney(playerid) < House[house][hPrice]?("Недостаточно"):("Достаточно" ))
               ,House[house][hLevel],(Player[playerid][pLevel] < House[house][hLevel]?("Недостаточный"):("Достаточный") ));
        if(Player[playerid][pLevel] < House[house][hLevel] || GetPlayerMoney(playerid) < House[house][hPrice])
        {
          return ShowPlayerDialog(playerid, 20,0,"Продажа Владения",str,"Закрыть","");
        }
        else
        {
          SetPVarInt(playerid,"house_active",house);
          return ShowPlayerDialog(playerid, 21,0,"Продажа Владения",str,"Купить","Закрыть");
        }
      }
      else
      {
        new arend[32];
        if(House[house][hRent] > 0) format(arend,32,"%d руб в час",House[house][hRent]);
        else if(House[house][hRent] <= 0) format(arend,32,"Нет",House[house][hRent]);
        format(str,sizeof(str),"\
{ffffff}Дом\n\n\
Владелец: %s\n\
Статус: %s\n\
Аренда: %s\n\
\n\
Если хотите войти нажмите \"Войти\"\n\
Если не хотите нажмите \"Закрыть\""
               ,House[house][hOwner]
               ,((House[house][hLock] == 0) ? ("Открыт"):("Закрыт" )),
               arend);
        if(House[house][hLock] == 1)
        {
          return ShowPlayerDialog(playerid, 20,0,"Дом",str,"Закрыть","");
        }
        else
        {
          SetPVarInt(playerid,"house_active",house);
          return ShowPlayerDialog(playerid, 22,0,"Дом",str,"Войти","Закрыть");
        }
      }
    }
    else if(IsPlayerInRangeOfPoint(playerid,1.0,House[house][hiX],House[house][hiY],House[house][hiZ]) && GetPlayerVirtualWorld(playerid) == house)
    {
      SetPlayerPos(playerid,House[house][hvX],House[house][hvY],House[house][hvZ]);
      SetPlayerVirtualWorld(playerid,0);
      SetPlayerInterior(playerid,0);
      return 1;
    }
  }
}

 

В паблик OnDialogResponse:

Спойлер

if(dialogid == 21) // покупка дома
{
  if(response)
  {
    new house = GetPVarInt(playerid,"house_active");
    DeletePVar(playerid,"house_active");
    new housenum = 0;
    for(new house2 = 1; house2 <= AllHouse; house2++)
    {
      if(!strcmp(House[house2][hOwner],GN(playerid),false)) housenum++;
    }
    if(Player[playerid][pAdmin] >= 9) // домов для админов 9 уровня и больше
    {
      if(housenum >= 2) return SendClientMessage(playerid,-1,"Достигнуто максимальное количество домов");
    }
    else  // для обычных игроков
    {
      if(housenum >= 1) return SendClientMessage(playerid,-1,"Достигнуто максимальное количество домов");
    }
    if(!IsPlayerInRangeOfPoint(playerid,3.0,House[house][hvX],House[house][hvY],House[house][hvZ] ))
    {
      return SendClientMessage(playerid,-1,"Вы отошли от дома");
    }
    if(GetPlayerMoney(playerid) < House[house][hPrice])
    {
      return SendClientMessage(playerid,-1,"У вас не хватает денег");
    }
    else GivePlayerMoney(playerid, -House[house][hPrice]);
    Player[playerid][pMoney] -=House[house][hPrice];
    SetPlayerPos(playerid,House[house][hiX],House[house][hiY],House[house][hiZ]);
    SetPlayerVirtualWorld(playerid,house);
    SetPlayerInterior(playerid,House[house][hInt]);
    format(House[house][hOwner],24,GN(playerid));
    House[house][hDate] = gettime();
    format(House[house][hNick1],24,"Nones");
    format(House[house][hNick2],24,"Nones");
    format(House[house][hNick3],24,"Nones");
    format(House[house][hNick4],24,"Nones");
    format(House[house][hNick5],24,"Nones");
    House[AllHouse][hRent] = 0;
    House[AllHouse][hRoom] = 0;
    House[AllHouse][hBank] = 0;
    UpdateHouse(house);
    SaveHouse(house);
    return SendClientMessage(playerid,-1,"Вы успешно купили себе дом");
  }
  else return 1;
}
//==============================================================================
if(dialogid == 22) // вход в дом
{
  if(response)
  {
    new house = GetPVarInt(playerid,"house_active");
    DeletePVar(playerid,"house_active");
    if(!IsPlayerInRangeOfPoint(playerid,3.0,House[house][hvX],House[house][hvY],House[house][hvZ] ))
    {
      return SendClientMessage(playerid,-1,"Вы отошли от дома");
    }
    SetPlayerPos(playerid,House[house][hiX],House[house][hiY],House[house][hiZ]);
    SetPlayerVirtualWorld(playerid,house);
    SetPlayerInterior(playerid,House[house][hInt]);
    return 1;
  }
  else return 1;
}

 

Был чу чуть изменён от стандартного Gamer
Player[playerid][pAdmin] замените на свою функцию администратора
Ид диалогов меняйте на свои
Иероглифы сами поменяются когда вставите в мод
Будут ошибки пишите сюда

Share this post


Link to post
Share on other sites

Автор вырезки и переделки: Basis

 

Share this post


Link to post
Share on other sites
format(str,sizeof(str),"\{ffffff}Дом\n\n\Владелец: %s\n\Статус: %s\n\Аренда: %s\n\\n\Если хотите войти нажмите \"Войти\"\n\Если не хотите нажмите \"Закрыть\"",House[house][hOwner],((House[house][hLock] == 0) ? ("Открыт"):("Закрыт" )),arend);


format(str,sizeof(str),"\{ffffff}Продаётся дом\n\n\Цена: %d руб (%s)\n\Требуемый уровень: %d (%s)\n\\n\Если хотите купить нажмите \"Купить\"\n\Если не хотите нажмите \"Закрыть\"",House[house][hPrice],(GetPlayerMoney(playerid) < House[house][hPrice] ? ("Недостаточно"):("Достаточно" )),House[house][hLevel],(PlayerInfo[playerid][pLevel] < House[house][hLevel] ? ("Недостаточный"):("Достаточный") ));

У меня в этих строчках это 



error 027: invalid character constant
error 027: invalid character constant
error 027: invalid character constant
error 027: invalid character constant

Share this post


Link to post
Share on other sites

@drabinka обратный слэш в начале строки убери

Share this post


Link to post
Share on other sites
 if(!strcmp(House[house2][hOwner],GN(playerid),false)) housenum++

что мне делать? - ошибка в GN!

Share this post


Link to post
Share on other sites

@ewrewrw заменить эту строку на следующий участок кода:

new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME); 
if(!strcmp(House[house2][hOwner],playername,false)) housenum++

 

Если это находится в цикле (for, while), то строку new playername[MAX_PLAYER_NAME]; разместите перед входом в цикл. 

Share this post


Link to post
Share on other sites

Помогите!! 

C:\Users\Administrator\Desktop\!\Âñå äëÿ ñåðâåðà\Ðåëèç 1\gamemodes\SaumRP.pwn(1750) : error 017: undefined symbol "str"
C:\Users\Administrator\Desktop\!\Âñå äëÿ ñåðâåðà\Ðåëèç 1\gamemodes\SaumRP.pwn(1750) : error 017: undefined symbol "str"
C:\Users\Administrator\Desktop\!\Âñå äëÿ ñåðâåðà\Ðåëèç 1\gamemodes\SaumRP.pwn(1752) : loose indentation
C:\Users\Administrator\Desktop\!\Âñå äëÿ ñåðâåðà\Ðåëèç 1\gamemodes\SaumRP.pwn(1752) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Desktop\!\Âñå äëÿ ñåðâåðà\Ðåëèç 1\gamemodes\SaumRP.pwn(1752) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Desktop\!\Âñå äëÿ ñåðâåðà\Ðåëèç 1\gamemodes\SaumRP.pwn(1752) : warning 215: expression has no effect
C:\Users\Administrator\Desktop\!\Âñå äëÿ ñåðâåðà\Ðåëèç 1\gamemodes\SaumRP.pwn(1752) : error 001: expected token: ";", but found "]"
C:\Users\Administrator\Desktop\!\Âñå äëÿ ñåðâåðà\Ðåëèç 1\gamemodes\SaumRP.pwn(1752) : fatal error 107: too many error messages on one line 

 

 

Вот сама строка где ошибки

 

            format(str,sizeof(str),"\
    {ffffff}????????? ???\n\n\
    ????: %d ??? (%s)\n\
    ????????? ???????: %d (%s)\n\
    \n\
    ???? ?????? ?????? ??????? \"??????\"\n\
    ???? ?? ?????? ??????? \"???????\""
                   ,House[house][hPrice],(GetPlayerMoney(playerid) < House[house][hPrice]?("????????????"):("??????????" ))
                   ,House[house][hLevel],(Player[playerid][pLevel] < House[house][hLevel]?("?????????????"):("???????????") ));

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   You have pasted content with formatting.   Remove formatting

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

Loading...
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • warrion4ik
      By warrion4ik
      При телепорте по метке она тепает под текстуры и приходится перетелепортироваться, как это можно исправить?
      Видео: https://youtu.be/FLjer8lfGc0