• Страница 1 из 1
  • 1
[Мануал] Делаем лифт как на [State 99] [ALL]
Дмитрий Дата: Вторник, 28.05.2013, 15:29 | Сообщение # 1 | Сообщить о нерабочей теме


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

Автор: Sanbody

Сейчас я вам покажу как его сделать.

Цитата
Ко всем includ"am добавляем.


Код
#include <yom_buttons>  


Цитата
После ко всем переменным добавляем.


Код
new ElevButtons[3];   
new ElevObjects[3];   
new ElevStare = 0;   
new ElevState;   
new ElevDoorState;
new ElevDoorTimer;
new ElevArea;
new ElevDoor[3][2];
new Float:ElevCoord[9][3] =
{
      {1786.6712,-1303.4797,14.5834},   
      {1786.6413,-1299.6489,14.5572},   
      {1786.6445,-1299.6483,14.5702},   
      {1786.6413,-1299.3488,14.5572},   
      {1786.6445,-1299.3482,14.5702},   
      {1786.6413,-1299.3488,23.1172},   
      {1786.6445,-1299.3482,23.1302},   
      {1786.6413,-1299.3488,27.3972},
      {1786.6445,-1299.3482,27.4102}
};
new Float:ElevStares[3] = {0.0,8.56,14.00};
enum   
{
      dElevator
}  


Цитата
В public OnGameModeInit() добавляем


Код
//ElevObjects[0] = CreateDynamicObject(18755,1786.6445,-1299.3482,14.5702,0.0000,0.0000,90.0000);
      ElevObjects[0] = CreateDynamicObject(18755,ElevCoord[0][0],ElevCoord[0][1],ElevCoord[0][2],0.0000,0.0000,-90.0000);
      ElevObjects[1] = CreateDynamicObject(18757,ElevCoord[1][0],ElevCoord[1][1],ElevCoord[1][2],0.0000,0.0000,90.0000);//
      ElevObjects[2] = CreateDynamicObject(18756,ElevCoord[2][0],ElevCoord[2][1],ElevCoord[2][2],0.0000,0.0000,90.0000);//
      ElevDoor[0][0] = CreateDynamicObject(18757,ElevCoord[3][0],ElevCoord[3][1],ElevCoord[3][2],0.0000,0.0000,90.0000);//
      ElevDoor[0][1] = CreateDynamicObject(18756,ElevCoord[4][0],ElevCoord[4][1],ElevCoord[4][2],0.0000,0.0000,90.0000);//
      ElevDoor[1][0] = CreateDynamicObject(18757,ElevCoord[3][0],ElevCoord[3][1],ElevCoord[3][2]+ElevStares[1],0.0000,0.0000,90.0000);//
      ElevDoor[1][1] = CreateDynamicObject(18756,ElevCoord[4][0],ElevCoord[4][1],ElevCoord[4][2]+ElevStares[1],0.0000,0.0000,90.0000);//
      ElevDoor[2][0] = CreateDynamicObject(18757,ElevCoord[3][0],ElevCoord[3][1],ElevCoord[3][2]+ElevStares[2],0.0000,0.0000,90.0000);//
      ElevDoor[2][1] = CreateDynamicObject(18756,ElevCoord[4][0],ElevCoord[4][1],ElevCoord[4][2]+ElevStares[2],0.0000,0.0000,90.0000);//
      ElevButtons[0] = CreateButton(1784.12, -1301.11, 14.06, 0.0);
      CreateDynamic3DTextLabel("F",CYELLOW,1784.12, -1301.11, 14.56,3.0);
      ElevButtons[1] = CreateButton(1784.17, -1301.09, 22.84, 0.0);
      CreateDynamic3DTextLabel("F",CYELLOW,1784.17, -1301.09, 23.34,3.0);
      ElevButtons[2] = CreateButton(1784.17, -1301.09, 28.00, 0.0);
      CreateDynamic3DTextLabel("F",CYELLOW,1784.17, -1301.09, 28.00,3.0);
      ElevArea = CreateDynamicRectangle(1785.0951,-1305.0148,1788.1938,-1301.9753);
      CreateDynamic3DTextLabel("Используйте {"#cYELLOW"}/lift",CWHITE,1786.7131,-1304.9666,13.7750,3.0);  


Цитата
Сама команда.


Код
if(!strcmp(cmd,"/lift",true))
      {
          if(!IsPlayerInDynamicArea(playerid, ElevArea)) return 1;
          if(ElevState == 1) return SendClientMessage(playerid,CGRAY,"Лифт уже используется");
          new mes[128];
          if(ElevStare != 0) strcat(mes," 1 Этаж. Выход\n");
          if(ElevStare != 1) strcat(mes," 2 Этаж. Отдел по трудо устройству\n");
          if(ElevStare != 2) strcat(mes," 3 Этаж. Отдел по учету безработицы\n");
          if(!ElevDoorState) strcat(mes," Открыть двери");
          ShowPlayerDialog(playerid,dElevator,2,"Выберите этаж",mes,"OK","Отмена");
          return 1;
      }  


Цитата
В public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) добавим


Код
case dElevator:
          {
              if(!response) return 1;
              if(ElevState == 1 && ElevState == 2) return 0;
              if(!strcmp(inputtext," Открыть двери",true))
              {
                  if(!ElevState && !ElevDoorState)
                  {
                      ElevState = 3;
                      OpenLiftDoors();
                  }
                  return 1;
              }
              new stare;
              if(listitem < ElevStare) stare = listitem;
              else if(listitem >= ElevStare) stare = listitem+1;
              if(ElevState == 3)
              {
                  //print("Point5");
                  ElevState = 1;
                  KillTimer(ElevDoorTimer);
                  CloseLiftDoors();
                  ElevStare = stare;
              }
              else
              {
                  ElevState = 1;
                  ElevStare = stare;
                  MoveDynamicObject(ElevObjects[0],ElevCoord[0][0],ElevCoord[0][1],ElevCoord[0][2]+ElevStares[stare],1.0);
                  MoveDynamicObject(ElevObjects[1],ElevCoord[1][0],ElevCoord[1][1],ElevCoord[1][2]+ElevStares[stare],1.0);
                  MoveDynamicObject(ElevObjects[2],ElevCoord[2][0],ElevCoord[2][1],ElevCoord[2][2]+ElevStares[stare],1.0);
              }
          }  


Цитата
В public OnDynamicObjectMoved(objectid) если его у вас нету то создайте.


Код
if(objectid == ElevObjects[1] && ElevState == 2 && ElevDoorState == 0)   
      {
          SetTimer("OpenLiftDoors",500,false);
      }
      else if(objectid == ElevObjects[1] && ElevState == 2 && ElevDoorState == 3)   
      {
          ElevState = 3; //Iaiyai noaoon
          ElevDoorState = 1;
          ElevDoorTimer = SetTimer("CloseLiftDoors",15000,false);   
      }
      else if(objectid == ElevObjects[1] && ElevState == 3 && ElevDoorState == 2)    
      {
          ElevState = 0; //Aaeaai eeoo naiaiaiui
          ElevDoorState = 0;
      }
      else if(objectid == ElevObjects[1] && ElevState == 1 && ElevDoorState == 2)   
      {
          ElevDoorState = 0;
          MoveDynamicObject(ElevObjects[0],ElevCoord[0][0],ElevCoord[0][1],ElevCoord[0][2]+ElevStares[ElevStare],1.0);
          MoveDynamicObject(ElevObjects[1],ElevCoord[1][0],ElevCoord[1][1],ElevCoord[1][2]+ElevStares[ElevStare],1.0);
          MoveDynamicObject(ElevObjects[2],ElevCoord[2][0],ElevCoord[2][1],ElevCoord[2][2]+ElevStares[ElevStare],1.0);
      }
      else if(objectid == ElevObjects[1] && ElevState == 1 && ElevDoorState == 0)   
      {
          SetTimer("OpenLiftDoors",500,false);
      }
      else if(objectid == ElevObjects[1] && ElevState == 1 && ElevDoorState == 3)   
      {
          ElevState = 3;   
          ElevDoorState = 1;
          ElevDoorTimer = SetTimer("CloseLiftDoors",15000,false);   
      }
      return 1;
}  


Цитата
В конец мода.


Код
forward OpenLiftDoors();
public OpenLiftDoors()
{
      //MoveDynamicObject(ElevObjects[1],1784.9080,-1303.2352,14.6+ElevStare*8.56,0.6);
      //MoveDynamicObject(ElevObjects[2],1788.3576,-1303.3225,14.6+ElevStare*8.56,0.6);
      //MoveDynamicObject(ElevDoor[ElevStare][0],ElevCoord[ElevStare*2 + 3][0]-1.8,ElevCoord[ElevStare*2 + 3][1],ElevCoord[ElevStare*2 + 3][2],0.6);
      //MoveDynamicObject(ElevDoor[ElevStare][1],ElevCoord[ElevStare*2 + 4][0]+1.8,ElevCoord[ElevStare*2 + 4][1],ElevCoord[ElevStare*2 + 4][2],0.6);

      MoveDynamicObject(ElevDoor[ElevStare][0],ElevCoord[3][0]-1.8,ElevCoord[3][1],ElevCoord[3][2]+ElevStares[ElevStare],0.6);
      MoveDynamicObject(ElevDoor[ElevStare][1],ElevCoord[4][0]+1.8,ElevCoord[4][1],ElevCoord[4][2]+ElevStares[ElevStare],0.6);

      MoveDynamicObject(ElevObjects[1],ElevCoord[1][0]-1.8,ElevCoord[1][1],ElevCoord[1][2]+ElevStares[ElevStare],0.6);
      MoveDynamicObject(ElevObjects[2],ElevCoord[2][0]+1.8,ElevCoord[2][1],ElevCoord[2][2]+ElevStares[ElevStare],0.6);
      ElevDoorState = 3;
      return 1;
}

forward CloseLiftDoors();
public CloseLiftDoors()
{
      //MoveDynamicObject(ElevObjects[1],1786.6898,-1303.2569,14.6+ElevStare*8.56,0.6);
      //MoveDynamicObject(ElevObjects[2],1786.6490,-1303.2540,14.6+ElevStare*8.56,0.6);
      //MoveDynamicObject(ElevDoor[ElevStare][0],ElevCoord[ElevStare*2 + 3][0],ElevCoord[ElevStare*2 + 3][1],ElevCoord[ElevStare*2 + 3][2],0.6);
      //MoveDynamicObject(ElevDoor[ElevStare][1],ElevCoord[ElevStare*2 + 4][0],ElevCoord[ElevStare*2 + 4][1],ElevCoord[ElevStare*2 + 4][2],0.6);

      MoveDynamicObject(ElevDoor[ElevStare][0],ElevCoord[3][0],ElevCoord[3][1],ElevCoord[3][2]+ElevStares[ElevStare],0.6);
      MoveDynamicObject(ElevDoor[ElevStare][1],ElevCoord[4][0],ElevCoord[4][1],ElevCoord[4][2]+ElevStares[ElevStare],0.6);

      MoveDynamicObject(ElevObjects[1],ElevCoord[1][0],ElevCoord[1][1],ElevCoord[1][2]+ElevStares[ElevStare],0.6);
      MoveDynamicObject(ElevObjects[2],ElevCoord[2][0],ElevCoord[2][1],ElevCoord[2][2]+ElevStares[ElevStare],0.6);
      ElevDoorState = 2;
      return 1;
}  


Цитата
Тоже в конец мода.


Код
forward OnPlayerPressButton(playerid,buttonid);
public OnPlayerPressButton(playerid,buttonid)
{
      if(buttonid == ElevButtons[0])
      {
          if(ElevState != 0) return SendClientMessage(playerid,CGRAY,"Лифт занят подождите");
          if(ElevStare != 0)
          {
              MoveDynamicObject(ElevObjects[0],ElevCoord[0][0],ElevCoord[0][1],ElevCoord[0][2],1.0);
              MoveDynamicObject(ElevObjects[1],ElevCoord[1][0],ElevCoord[1][1],ElevCoord[1][2],1.0);
              MoveDynamicObject(ElevObjects[2],ElevCoord[2][0],ElevCoord[2][1],ElevCoord[2][2],1.0);
              /*MoveDynamicObject(ElevObjects[1],1786.6898,-1303.2569,14.6,0.6);
              MoveDynamicObject(ElevObjects[2],1786.6490,-1303.2540,14.6,0.6);            */
          }
          else SetTimer("OpenLiftDoors",500,false);
          ElevState = 2;
          ElevStare = 0;
      }
      if(buttonid == ElevButtons[1])
      {
          if(ElevState != 0) return SendClientMessage(playerid,CGRAY,"Лифт занят подождите");
          if(ElevStare != 1)
          {
              MoveDynamicObject(ElevObjects[0],ElevCoord[0][0],ElevCoord[0][1],ElevCoord[0][2]+ElevStares[1],1.0);
              MoveDynamicObject(ElevObjects[1],ElevCoord[1][0],ElevCoord[1][1],ElevCoord[1][2]+ElevStares[1],1.0);
              MoveDynamicObject(ElevObjects[2],ElevCoord[2][0],ElevCoord[2][1],ElevCoord[2][2]+ElevStares[1],1.0);
          }
          else SetTimer("OpenLiftDoors",500,false);
          ElevState = 2;
          ElevStare = 1;
      }
      if(buttonid == ElevButtons[2])
      {
          if(ElevState != 0) return SendClientMessage(playerid,CGRAY,"Лифт занят подождите");
          if(ElevStare != 2)
          {
              MoveDynamicObject(ElevObjects[0],ElevCoord[0][0],ElevCoord[0][1],ElevCoord[0][2]+ElevStares[2],1.0);
              MoveDynamicObject(ElevObjects[1],ElevCoord[1][0],ElevCoord[1][1],ElevCoord[1][2]+ElevStares[2],1.0);
              MoveDynamicObject(ElevObjects[2],ElevCoord[2][0],ElevCoord[2][1],ElevCoord[2][2]+ElevStares[2],1.0);
          }
          else SetTimer("OpenLiftDoors",500,false);
          ElevState = 2;
          ElevStare = 2;
      }
      return 1;
}  


Качаем [FS] и Inclund: Скачать

Лифт без FS не работает !!!

[spoiler="Скрины:"][/spoiler]
Прикрепления: 6948416.jpg (17.0 Kb) · 8372962.jpg (52.0 Kb) · 2671986.jpg (36.2 Kb)


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