[Мануал] Аренда машин (new)

  • Автор темы Pawno.INC
  • Обновлено
  • 25, Aug 2014
  • #1
В начало мода:

 #include <GetVehicleColor>


 new arenda[MAX_PLAYERS];
new ARENDCARS;
new ArendCar[100] = INVALID_VEHICLE_ID;
new ArendKey[MAX_PLAYERS] = INVALID_VEHICLE_ID;
new PlayerCar[MAX_PLAYERS];
new PlayerSeat[MAX_PLAYERS];
new player_NoCheckTimeVeh[MAX_PLAYERS];


 enum arInfo
{
 aRentID,
 aID,//ID
 Float:aPos_X,//Кордината X
 Float:aPos_Y,//Кордината Y
 Float:aPos_Z,//Кордината Z
 Float:aPos_A,//Угол поворота
 aColor_1,//Цвет 1
 aColor_2,//Цвет 2,
 aCost, //цена
 aNumber[20]
};


 new ArendInfo[][arInfo] =
{
 {INVALID_PLAYER_ID, 415,-1989.7998,272.5996,35.0000,265.9954,1,0,60000,"Аренда SF"},
 {INVALID_PLAYER_ID, 415,-1990.0996,268.5996,35.0000,265.9954,1,0,60000,"Аренда SF"},
 {INVALID_PLAYER_ID, 560,-1990.3994,264.3994,35.0000,265.9954,1,0,45000,"Аренда SF"},
 {INVALID_PLAYER_ID, 560,-1990.5999,260.2999,35.0000,265.9954,1,0,45000,"Аренда SF"},
 {INVALID_PLAYER_ID, 402,-1990.7999,256.1999,35.0000,265.9954,1,0,50000,"Аренда SF"},
 {INVALID_PLAYER_ID, 402,-1990.9999,252.0999,35.0000,265.9954,1,0,50000,"Аренда SF"},
 {INVALID_PLAYER_ID, 541,-1991.1999,247.9999,35.0000,265.9954,1,0,70000,"Аренда SF"},
 {INVALID_PLAYER_ID, 541,-1991.3999,243.8999,35.0000,265.9954,1,0,70000,"Аренда SF"},
 {INVALID_PLAYER_ID, 541,552.2256,-1263.0308,16.8377,215.0,0,1,80000,"Аренда LS"}, //8
 {INVALID_PLAYER_ID, 541,549.2261,-1265.1127,16.8615,215.0,0,1,80000,"Аренда LS"}, //9
 {INVALID_PLAYER_ID, 411,546.2819,-1267.1350,16.8603,216.0,0,1,80000,"Аренда LS"}, //10
 {INVALID_PLAYER_ID, 411,543.2506,-1269.3328,16.8853,212.0,0,1,80000,"Аренда LS"}, //11
 {INVALID_PLAYER_ID, 560,540.3386,-1271.8612,16.9312,218.0,1,0,45000,"Аренда LS"},
 {INVALID_PLAYER_ID, 560,537.4234,-1274.1729,16.8892,218.0,1,0,45000,"Аренда LS"},
 {INVALID_PLAYER_ID, 560,534.7526,-1276.3138,16.8918,219.0,1,0,45000,"Аренда LS"},
 {INVALID_PLAYER_ID, 560,531.9340,-1278.4873,16.8892,218.0,1,0,45000,"Аренда LS"},
 {INVALID_PLAYER_ID, 402,565.7926,-1283.7555,17.0098,103.0,1,0,50000,"Аренда LS"},
 {INVALID_PLAYER_ID, 402,564.8121,-1279.5139,17.0102,103.0,1,0,50000,"Аренда LS"},
 {INVALID_PLAYER_ID, 402,563.9153,-1275.2931,17.0073,102.0,1,0,50000,"Аренда LS"},
 {INVALID_PLAYER_ID, 415,563.3939,-1271.1617,16.9935,103.0,1,0,60000,"Аренда LS"},
 {INVALID_PLAYER_ID, 415,562.5081,-1267.2034,16.9659,103.0,1,0,60000,"Аренда LS"},
 {INVALID_PLAYER_ID, 415,2285.3000,2042.5000,10.6999,90.0,1,0,60000,"Аренда LV"},
 {INVALID_PLAYER_ID, 415,2285.3000,2046.5999,10.6999,90.0,1,0,60000,"Аренда LV"},
 {INVALID_PLAYER_ID, 415,2285.3000,2038.6999,10.6999,90.0,1,0,60000,"Аренда LV"},
 {INVALID_PLAYER_ID, 402,2246.5000,2046.4000,10.8000,270.0,1,0,50000,"Аренда LV"},
 {INVALID_PLAYER_ID, 402,2246.5000,2042.5999,10.8000,270.0,1,0,50000,"Аренда LV"},
 {INVALID_PLAYER_ID, 402,2246.5000,2038.6999,10.8000,270.0,1,0,50000,"Аренда LV"},
 {INVALID_PLAYER_ID, 560,2270.8999,2064.3999,10.6000,180.0,1,0,45000,"Аренда LV"},
 {INVALID_PLAYER_ID, 560,2266.6999,2064.3999,10.6000,180.0,1,0,45000,"Аренда LV"},
 {INVALID_PLAYER_ID, 560,2262.5000,2064.3999,10.6000,180.0,1,0,45000,"Аренда LV"},
 {INVALID_PLAYER_ID, 560,2275.1000,2064.3999,10.6000,180.0,1,0,45000,"Аренда LV"},
 {INVALID_PLAYER_ID, 541,2215.8000,2055.8999,10.5000,270.0,1,0,70000,"Аренда LV"},
 {INVALID_PLAYER_ID, 541,2215.8000,2059.3000,10.5000,270.0,1,0,70000,"Аренда LV"},
 {INVALID_PLAYER_ID, 541,2215.7998,2052.3990,10.5000,270.0,1,0,70000,"Аренда LV"},
 {INVALID_PLAYER_ID, 541,2215.7998,2048.8994,10.5000,270.0,1,0,70000,"Аренда LV"},
 {INVALID_PLAYER_ID, 487, 1994.5000,-2361.0000,13.8000,90.0,1,0,150000,""},
 {INVALID_PLAYER_ID, 487, 1994.5000,-2373.6999,13.8000,90.0,1,0,150000,""},
 {INVALID_PLAYER_ID, 487, 1994.5000,-2386.5000,13.8000,90.0,1,0,150000,""},
 {INVALID_PLAYER_ID, 487, 1994.5000,-2399.1999,13.8000,90.0,1,0,150000,""},
 {INVALID_PLAYER_ID, 487, 1994.5000,-2348.6999,13.8000,90.0,1,0,150000,""},
 {INVALID_PLAYER_ID, 469, 1996.0000,-2294.3000,13.6000,90.0,1,0,100000,""},
 {INVALID_PLAYER_ID, 469, 1996.0000,-2305.8000,13.6000,90.0,1,0,100000,""},
 {INVALID_PLAYER_ID, 469, 1996.0000,-2317.3000,13.6000,90.0,1,0,100000,""},
 {INVALID_PLAYER_ID, 469, 1996.0000,-2328.8000,13.6000,90.0,1,0,100000,""},
 {INVALID_PLAYER_ID, 469, 1996.0000,-2282.6000,13.6000,90.0,1,0,100000,""},
 {INVALID_PLAYER_ID, 446, 344.11251,-1916.3968505859,0.0,180.0,0,0,250000,""}, //Катера
 {INVALID_PLAYER_ID, 446, 294.88024,-1913.7055664063,0.0,180.0,0,0,250000,""},
 {INVALID_PLAYER_ID, 493, 242.87979,-1909.5093994141,0.0,180.0,0,0,300000,""},
 {INVALID_PLAYER_ID, 493, 195.06362,-1909.5883789063,0.0,180.0,0,0,300000,""},
 {INVALID_PLAYER_ID, 453, 320.46026,-1916.8625488281,0.0,180.0,0,0,350000,""},
 {INVALID_PLAYER_ID, 454, 269.84338,-1911.7650146484,0.0,180.0,0,0,350000,""},
 {INVALID_PLAYER_ID, 484, 217.90313,-1911.5402832031,0.0,180.0,0,0,200000,""},
 {INVALID_PLAYER_ID, 484, 175.50329,-1910.8438720703,0.0,180.0,0,0,200000,""}
};


В - public OnPlayerConnect

 PlayerSeat[playerid] = -1;
 PlayerCar[playerid] = INVALID_VEHICLE_ID;
 ArendKey[playerid] = INVALID_VEHICLE_ID;


К - Диалогам

  case 2027:
 {
 if(response)
 {
 new arid = GetArendCarID(GetPlayerVehicleID(playerid));
 new cost = ArendInfo[arid][aCost];
 if(PlayerInfo[playerid][pCash] >= cost)
 {

 ArendKey[playerid] = arid;
 ArendInfo[arid][aRentID] = playerid;
 //Fuell[GetPlayerVehicleID(playerid)] = 100);
 Fuell[GetPlayerVehicleID(playerid)] = 100;
 SendClientMessage(playerid,-1,"{FFFFFF}Вы арендовали это транспорт. {FF6347}/unrent{FFFFFF} - отказаться от аренды, {FF6347}/findrent{FFFFFF} - найти арендованный транспорт");
 PlayerInfo[playerid][pCash] -= cost;
 ShowPlayerDialog (playerid, 2028, DIALOG_STYLE_LIST, "Цвет транспорта", "[1] Черный\n[2] Белый\n[3] Красный\n[4] Синий\n[5] Зеленый\n[6] Желтый\n[7] Розовый\n[8] Коричниевый", "Выбрать", "");
 }
 else
 {
 SendClientMessage(playerid,-1,"У вас нехватает денег...");
 RemovePlayerFromVehicle(playerid);
 }
 }
 else
 {
 RemovePlayerFromVehicle(playerid);
 }
 return true;
 }
 case 2028:
 {
 if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
 {
 if(response)
 {
 new v = GetPlayerVehicleID(playerid);
 new color1, color2;
 new col;
 switch (listitem)
 {
 case 0: col = 0;
 case 1: col = 1;
 case 2: col = 3;
 case 3: col = 79;
 case 4: col = 86;
 case 5: col = 6;
 case 6: col = 126;
 case 7: col = 66;
 }
 GetVehicleColor(v, color1, color2);
 ChangeVehicleColor(v,col,color2);
 if(IsAArendCar(v))
 {
 new rentid = GetArendCarID(v);
 ArendInfo[rentid][aColor_1] = col;
 ArendInfo[rentid][aColor_2] = color2;
 }
 }
 else ShowPlayerDialog (playerid, 2028, DIALOG_STYLE_LIST, "Цвет транспорта", "[1] Черный\n[2] Белый\n[3] Красный\n[4] Синий\n[5] Зеленый\n[6] Желтыйй\n[7] Розовый\n[8] Коричниевый", "Выбрать", "");
 }
 else SendClientMessage(playerid, 0xFFD700FF, "Вы должны находиться в автомобиле");
 }


В - OnPlayerDisconnect

 if(ArendKey[playerid] != INVALID_VEHICLE_ID)
 {
 new car = ArendKey[playerid];
 ArendKey[playerid] = INVALID_VEHICLE_ID;
 ArendInfo[car][aRentID] = INVALID_PLAYER_ID;
 SetVehicleToRespawn(ArendCar[0] + car);
 }


В - OnPlayerStateChange

  new caridi = GetPlayerVehicleID(playerid);
 if(newstate == PLAYER_STATE_DRIVER)
 {
 GameTextForPlayer(playerid,VehicleNames[GetVehicleModel(caridi)-400],5000,1);
 player_NoCheckTimeVeh[playerid] = 1;
 VehicleSeat[caridi][0] = playerid;
 PlayerSeat[playerid] = 0;
 PlayerCar[playerid] = caridi;
 if(IsAArendCar(caridi))
 {
 if(ArendKey[playerid] == INVALID_VEHICLE_ID)
 {
 new jstr[300];
 if(!IsAArended(caridi))
 {
 new arid = GetArendCarID(caridi);
 new cost = ArendInfo[arid][aCost];
 format(jstr,sizeof(jstr),"{FFFFFF}Транспорт для аренды!\n\n{FF9900}Модель: {FFD700}%s\nСтоимость: %d\n\n{AFAFAF}Чтобы арендовать нажмите 'Аренда'",VehicleNames[GetVehicleModel(caridi)-400], cost);
 ShowPlayerDialog(playerid, 2027, 0, "Аренда", jstr, "Аренда", "Отмена");
 }
 else
 {
 SendClientMessage(playerid,COLOR_GREY,"Этот транспорт уже арендуют");
 RemovePlayerFromVehicle(playerid);
 }
 }
 else
 {
 if(ArendKey[playerid] != GetArendCarID(caridi))
 {
 SendClientMessage(playerid,COLOR_GREY,"Вы уже арендуете транспорт. {FF6347}/unrent{FFFFFF} - чтобы отказаться от аренды");
 RemovePlayerFromVehicle(playerid);
 }
 }
 }
 }


Ко всем командам

  else if(strcmp(cmd, "/unrent", true) == 0)
 {
 if(IsPlayerConnected(playerid))
 {
 if(ArendKey[playerid] != INVALID_VEHICLE_ID)
 {
 new car = ArendKey[playerid];
 new vehid = ArendCar[0] + car;
 ArendInfo[car][aRentID] = INVALID_PLAYER_ID;
 ArendKey[playerid] = INVALID_VEHICLE_ID;
 Engine(vehid,false);
 zavodis[vehid] = 0;
 Lights(vehid,false);
 SetVehicleToRespawn(vehid);
 SendClientMessage(playerid, COLOR_GREY, "Вы отказались от аренды транспорта");
 }
 }
 return true;
 }
 else if(strcmp(cmd, "/findrent", true) == 0)
 {
 if(IsPlayerConnected(playerid))
 {
 if(ArendKey[playerid] != INVALID_VEHICLE_ID)
 {
 new car = ArendKey[playerid];
 new vehid = ArendCar[0] + car;
 new Float:vX, Float:vY, Float:vZ;
 GetVehiclePos(vehid, vX, vY, vZ);
 SetPlayerCheckpoint(playerid, vX, vY, vZ, 8.0);
 CP[playerid] = 999;
 SendClientMessage(playerid, COLOR_WHITE, "Ваш арендованный транспорт помечен на карте красной меткой");

 }
 }
 return true;
 }


В любое свободное место

 stock GetArendCarID(carid) return carid - ArendCar[0];
stock IsAArendCar(carid){ if(carid >= ArendCar[0] && carid <= ArendCar[ARENDCARS-1]) return true; return false;}
stock IsAArended(carid)
{
 if(IsAArendCar(carid))
 {
 new rentid = GetArendCarID(carid);
 if(IsPlayerConnected(ArendInfo[rentid][aRentID]))
 {
 return true;
 }
 }
 return false;
}


Автор идеи: SAMP Pro

Разработка: Pawno.INC

Инклуд (клик)

Если Будут error/warring сообщите ниже

Pawno.INC


Рег
24 Aug, 2014

Тем
69

Постов
214

Баллов
599
Похожие темы Дата
Тем
403,760
Комментарии
400,028
Опыт
2,418,908

Интересно