• Страница 1 из 1
  • 1
Система кухни
Дмитрий Дата: Понедельник, 06.08.2012, 22:46 | Сообщение # 1 | Сообщить о нерабочей теме


Аватар для Дмитрий

Система кухни.

Автор: [Jim_L]

Описание системы:

Система довольно проста. В каждом доме есть кухня, соответственно есть и холодильник, в нем то и будут
храниться все продукты. Сама "система" кухни продуманна.

Например: Вы купили: Колбасу, тесто, сыр, помидоры, огурцы и т.д, соответсвенно
если у Вас имеются только эти продукты, Вы можете приготовить пиццу.

Так же Вы можете посмотреть, что у Вас в холодильнике, для этого есть определенная
команда, после ввода которой, игроку открывается диалоговое окно. Через него то и
будет все управление холодильником: Проверить продукты, скушать что-либо,
приготовление еды и т.д.

В Enum pInfo добавим:

Code
pProducts[9],
pHeat[4],


В public OnPlayerconnect добавим:

Code
PlayerInfo[playerid][pProducts] = 0;
PlayerInfo[playerid][pHeat] = 0;  


В Public On DialogResponse

Code
               case 12323:
                 {
                     if(response)
                     {
                         switch(listitem)
                         {
                             case 0:
                             {
                    if(PlayerInfo[playerid][pProducts][1] != 1 && PlayerInfo[playerid][pProducts][2] != 1 && PlayerInfo[playerid][pProducts][3] != 1 && PlayerInfo[playerid][pProducts][4] != 1 && PlayerInfo[playerid][pProducts][5] != 1) return SendClientMessage(playerid, COLOR_GREY, "- Недостаточно продуктов.");
                    PlayerInfo[playerid][pProducts][1] = 0, PlayerInfo[playerid][pProducts][2] = 0, PlayerInfo[playerid][pProducts][3] = 0, PlayerInfo[playerid][pProducts][4] = 0, PlayerInfo[playerid][pProducts][5] = 0;
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы приготовили пиццу. (( Введите /heat, чтобы скушать пиццу ))");
                    PlayerInfo[playerid][pHeat][0] = 1;
                    ApplyAnimation(playerid,"DEALER","DRUGS_BUY",4.0,1,0,0,1,1,1);
                             }
                             case 1:
                             {
                    if(PlayerInfo[playerid][pProducts][0] != 1) return SendClientMessage(playerid, COLOR_GREY, "- Недостаточно продуктов.");
                    PlayerInfo[playerid][pProducts][0] = 0;
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы сварили пельмени. (( Введите /heat, чтобы их скушать ))");
                    PlayerInfo[playerid][pHeat][1] = 1;
                    ApplyAnimation(playerid,"DEALER","DRUGS_BUY",4.0,1,0,0,1,1,1);
                             }
                             case 2:
                             {
                    if(PlayerInfo[playerid][pProducts][1] != 1 && PlayerInfo[playerid][pProducts][2] != 1 && PlayerInfo[playerid][pProducts][4] != 1 && PlayerInfo[playerid][pProducts][5] != 1) return SendClientMessage(playerid, COLOR_GREY, "- Недостаточно продуктов.");
                    PlayerInfo[playerid][pProducts][1] = 0, PlayerInfo[playerid][pProducts][2] = 0, PlayerInfo[playerid][pProducts][4] = 0, PlayerInfo[playerid][pProducts][5] = 0;
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы сделали бутерброды. (( Введите /heat, чтобы их скушать ))");
                    PlayerInfo[playerid][pHeat][2] = 1;
                    ApplyAnimation(playerid,"DEALER","DRUGS_BUY",4.0,1,0,0,1,1,1);
                             }
                    case 3:
                             {
                    if(PlayerInfo[playerid][pProducts][1] != 1 && PlayerInfo[playerid][pProducts][4] != 1 && PlayerInfo[playerid][pProducts][5] != 1) return SendClientMessage(playerid, COLOR_GREY, "- Недостаточно продуктов.");
                    PlayerInfo[playerid][pProducts][1] = 0, PlayerInfo[playerid][pProducts][4] = 0, PlayerInfo[playerid][pProducts][5] = 0;
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы приготовили салат. (( Введите /heat, чтобы его скушать ))");
                    PlayerInfo[playerid][pHeat][3] = 1;
                    ApplyAnimation(playerid,"DEALER","DRUGS_BUY",4.0,1,0,0,1,1,1);
                             }
                         }
                     }
                 }
                 case 12322:
                 {
                     if(response)
                     {
                         switch(listitem)
                         {
                             case 0:
                             {
                    if(PlayerInfo[playerid][pProducts][0] != 1) return SendClientMessage(playerid, COLOR_GREY, "- Недостаточно продуктов.");
                    PlayerInfo[playerid][pProducts][0] = 0;
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы сварили пельмени. (( Введите /heat, чтобы их скушать ))");
                    PlayerInfo[playerid][pHeat][1] = 1;
                    ApplyAnimation(playerid,"DEALER","DRUGS_BUY",4.0,1,0,0,1,1,1);
                             }
                             case 1:
                             {
                    new Float:health;
                    GetPlayerHealth(playerid, health);
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы скушали кусочек колбасы.");
                    PlayerInfo[playerid][pProducts][1] = 0;
                    SetPlayerHealthAC(playerid, health + 20.0);
                    PlayerInfo[playerid][ pHP ] += 20;
                             }
                             case 2:
                             {
                    new Float:health;
                    GetPlayerHealth(playerid, health);
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы скушали кусочек сыра.");
                    PlayerInfo[playerid][pProducts][2] = 0;
                    SetPlayerHealthAC(playerid, health + 20.0);
                    PlayerInfo[playerid][ pHP ] += 20;
                             }
                    case 4:
                    {
                    new Float:health;
                    GetPlayerHealth(playerid, health);
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы скушали огурец.");
                    PlayerInfo[playerid][pProducts][4] = 0;
                    SetPlayerHealthAC(playerid, health + 20.0);
                    PlayerInfo[playerid][ pHP ] += 20;
                    }
                    case 5:
                    {
                    new Float:health;
                    GetPlayerHealth(playerid, health);
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы скушали помидор.");
                    PlayerInfo[playerid][pProducts][5] = 0;
                    SetPlayerHealthAC(playerid, health + 30.0);
                    PlayerInfo[playerid][ pHP ] += 30;
                    }
                             case 6:
                             {
                    new Float:health;
                    GetPlayerHealth(playerid, health);
                    SendClientMessage(playerid, COLOR_WHITE, "- Вы выпили стакан молока.");
                    PlayerInfo[playerid][pProducts][6] = 0;
                    SetPlayerHealthAC(playerid, health + 20.0);
                    PlayerInfo[playerid][ pHP ] += 20;
                             }
                             case 7:
                             {
                    new Float:health;
                    GetPlayerHealth(playerid, health);
                    SendClientMessage(playerid, COLOR_WHITE, "- Вы выпили стакан яблочного сока.");
                    PlayerInfo[playerid][pProducts][7] = 0;
                    SetPlayerHealthAC(playerid, health + 15.0);
                    PlayerInfo[playerid][ pHP ] += 15;
                             }
                    case 8:
                    {
                    new Float:health;
                    GetPlayerHealth(playerid, health);
                    SendClientMessage(playerid, COLOR_WHITE, "- Вы выпили стакан апельсинового сока.");
                    PlayerInfo[playerid][pProducts][8] = 0;
                    SetPlayerHealthAC(playerid, health + 15.0);
                    PlayerInfo[playerid][ pHP ] += 15;
                             }
                    case 9: SPD(playerid,12323,DIALOG_STYLE_LIST,"{FFFFFF} Приготовление еды","{FFFFFF}- Приготовить пиццу\n- Сварить пельмени.\n- Сделать бутерброды.\n- Приготовить салат","Выбор","Отмена");
                         }
                     }
                     else
                     {
                         return true;
                     }
                 }
                 case 12321:
                 {
                     if(response)
                     {
                         switch(listitem)
                         {
                             case 0:
                             {
                    if(PlayerInfo[playerid][pCash] < 80) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили пачку пельменей. (( /refr ))");
                    PlayerInfo[playerid][pProducts][0] = 1;
                    PlayerInfo[playerid][pCash] -= 80;
                             }
                             case 1:
                             {
                    if(PlayerInfo[playerid][pCash] < 38) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили колбасу. (( /refr ))");
                    PlayerInfo[playerid][pProducts][1] = 1;
                    PlayerInfo[playerid][pCash] -= 38;
                             }
                             case 2:
                             {
                    if(PlayerInfo[playerid][pCash] < 30) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили сыр. (( /refr ))");
                    PlayerInfo[playerid][pProducts][2] = 1;
                    PlayerInfo[playerid][pCash] -= 30;
                             }
                             case 3:
                             {
                    if(PlayerInfo[playerid][pCash] < 50) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили тесто. (( /refr ))");
                    PlayerInfo[playerid][pProducts][3] = 1;
                    PlayerInfo[playerid][pCash] -= 50;
                             }
                    case 4:
                    {
                    if(PlayerInfo[playerid][pCash] < 60) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили огурцы. (( /refr ))");
                    PlayerInfo[playerid][pProducts][4] = 1;
                    PlayerInfo[playerid][pCash] -= 60;
                    }
                    case 5:
                    {
                    if(PlayerInfo[playerid][pCash] < 60) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили помидоры. (( /refr ))");
                    PlayerInfo[playerid][pProducts][5] = 1;
                    PlayerInfo[playerid][pCash] -= 60;
                    }
                    case 6:
                    {
                    if(PlayerInfo[playerid][pCash] < 45) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили бутылку молока. (( /refr ))");
                    PlayerInfo[playerid][pProducts][6] = 1;
                    PlayerInfo[playerid][pCash] -= 45;
                    }
                    case 7:
                    {
                    if(PlayerInfo[playerid][pCash] < 45) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили бутылку сока яблочного. (( /refr ))");
                    PlayerInfo[playerid][pProducts][7] = 1;
                    PlayerInfo[playerid][pCash] -= 45;
                    }
                             case 8:
                             {
                    if(PlayerInfo[playerid][pCash] < 45) return SendClientMessage(playerid, COLOR_GREY, "- У Вас нет столько денег.");
                    SendClientMessage(playerid, COLOR_LIGHTGREEN, "- Вы купили бутылку сока апельсинового. (( /refr ))");
                    PlayerInfo[playerid][pProducts][8] = 1;
                    PlayerInfo[playerid][pCash] -= 45;
                             }
                         }
                     }
                      else
                      {
                          return true;
                      }
                 }  


From Russia With Love!
Дмитрий Дата: Понедельник, 06.08.2012, 22:47 | Сообщение # 2 | Сообщить о нерабочей теме


Аватар для Дмитрий

В public OnPlayerCommandText

Code
        if(strcmp(cmd, "/heat", true) == 0)
         {
             if(gPlayerLogged[playerid] == 1)
                 {
                     if(PlayerInfo[playerid][ pHP ] > 95) return SendClientMessage(playerid, COLOR_GREY, "- Вы не голодны.");
                     switch(PlayerInfo[playerid][pHeat])
                     {
                         case 1: { new Float:health; GetPlayerHealth(playerid, health); PlayerInfo[playerid][pHeat][1] = 0, SetPlayerHealthAC(playerid, health + 50.0), PlayerInfo[playerid][ pHP ] += 50, SendClientMessage(playerid, COLOR_GREY, "- Вы скушали пельмени."); }
                         case 0:
                         {
                             new Float:health;
                             GetPlayerHealth(playerid, health);
                             SendClientMessage(playerid, COLOR_GREY, "- Вы скушали пиццу.");
                             ApplyAnimation(playerid,"BAR","dnk_stndF_loop",4.1,0,0,0,0,0,1);
                    PlayerInfo[playerid][pHeat][0] = 0;
                    SetPlayerHealthAC(playerid, health + 40.0);
                    PlayerInfo[playerid][ pHP ] += 40;
                         }
                           case 2:
                           {
                             new Float:health;
                             GetPlayerHealth(playerid, health);
                             SendClientMessage(playerid, COLOR_GREY, "- Вы скушали бутерброды.");
                             ApplyAnimation(playerid,"BAR","dnk_stndF_loop",4.1,0,0,0,0,0,1);
                    PlayerInfo[playerid][pHeat][2] = 0;
                    SetPlayerHealthAC(playerid, health + 20.0);
                    PlayerInfo[playerid][ pHP ] += 20;
                           }
                         case 3:
                           {
                             new Float:health;
                             GetPlayerHealth(playerid, health);
                             SendClientMessage(playerid, COLOR_GREY, "- Вы скушали салат.");
                             ApplyAnimation(playerid,"BAR","dnk_stndF_loop",4.1,0,0,0,0,0,1);
                    PlayerInfo[playerid][pHeat][3] = 0;
                    SetPlayerHealthAC(playerid, health + 25.0);
                    PlayerInfo[playerid][ pHP ] += 25;
                           }
                      }
                 }
             }
         if(strcmp(cmd, "/refr", true) == 0)
         {
             if(gPlayerLogged[playerid] == 1)
                 {
                      new refrr[1000];
                     format(refrr,sizeof(refrr),"{FFFFFF}- Пельмени.\n- Колбаса.\n- Сыр.\n- Тесто.\n- Огурцы.\n- Помидоры.\n- Молоко.\n- Сок яблочный.\n- Сок апельсиновый.\n{40BFBF}- Приготовление еды.");
                     SPD(playerid, 12322, DIALOG_STYLE_LIST,"{FFFFFF} Холодильник",refrr,"Выбор", "Закрыть");
                     }
             return true;
         }
         if(strcmp(cmd, "/buyprod", true) == 0)
         {
             if(gPlayerLogged[playerid] == 1)
                 {
                     SPD(playerid, 12321, DIALOG_STYLE_LIST, "{FFFFFF} Магазин продуктов", "{FFFFFF}- Пельмени.\n- Колбаса.\n- Сыр.\n- Тесто.\n- Огурцы.\n- Помидоры.\n- Молоко.\n- Сок яблочный.\n- Сок апельсиновый.", "Купить", "Закрыть");
                 }
             return true;
         }  


В Public OnPlayerRegister

Code
ini_setInteger(File,"Продукты",PlayerInfo[playerid][pProducts]);
ini_setInteger(File,"Еда",PlayerInfo[playerid][pHeat]);  


В Public OnPlayerLogin

Code
ini_getInteger(File,"Продукты",PlayerInfo[playerid][pProducts]);
ini_getInteger(File,"Еда",PlayerInfo[playerid][pHeat]);  


В Public OnPlayerUpdateEx

Code
ini_setInteger(File,"Продукты",PlayerInfo[playerid][pProducts]);
ini_setInteger(File,"Еда",PlayerInfo[playerid][pHeat]);  


Вот и все. Код не сложный, для RP сервер, думаю, подойдет. Думаю, проверки на "кухню" и "Магазин продуктов" сами сделаете.

[spoiler="Скриншоты:"]



[/spoiler]


From Russia With Love!
  • Страница 1 из 1
  • 1
Поиск: