Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Перевод с mxini на mysql r39-6

Авг
48
2
Пользователь
Нашел систему личного авто в интернете, но она на mxini, можно как нибудь ее перевести на mysql?

команда:
CMD:editprice(playerid, params[])//Команда для изменения цены автомобиля в автосалоне
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"Ты не админ.");//Проверка является ли игрок Rcon админом
    if(sscanf(params,"i",params[0])) return SendClientMessage(playerid,0xFF0000FF,"Используй: /editprice [цена]");//Если игрок неправильно написал команду
    if(PlayerInShop[playerid] == false) return SendClientMessage(playerid, 0xFF0000FF, "Ты не в автосалоне.");//Если игрок не находится автосалоне
    new string[64];
    new iniFile = ini_openFile("CarPrice.ini");// Открываем файл по тому пути который указали.
    format(string, sizeof(string), "%d", CarInfo[playerid][cCarId]);// Добавляем имя игрока
    ini_setInteger(iniFile,string,params[0]);//Меняем цену автомобиля
    ini_closeFile(iniFile);// Закрываем файл
    SendClientMessage(playerid,-1,"Цена изменена и сохранена");//Выводим сообщние о том, что цена сохранена
    format(string,sizeof(string),"Price: %d",params[0]);//Форматируем string
    PlayerTextDrawSetString(playerid, ASalon[playerid][3], string);//Сразу же меняем текстдрав с ценой
    return 1;
}

стоки:
GetPriceCar(playerid)//функция получаения цены автомобиля
{
    new string[64];
    new iniFile = ini_openFile("CarPrice.ini");// Открываем файл по тому пути который указали.
    format(string, sizeof(string), "%d", CarInfo[playerid][cCarId]);// получаем номер строки, равный id модели транспорта
    ini_getInteger(iniFile,string,CarInfo[playerid][cPrice]);//получаем стоимость машины
    ini_closeFile(iniFile);// Закрываем файл
}


BuyCar(playerid)//Функция покупки автомобиля
{
        new string[64];// Масив с путём для файла
        new PlayerName[MAX_PLAYER_NAME];//Переменная для хранения имени
        GetPlayerName(playerid, PlayerName,sizeof(PlayerName));
        format(string,sizeof(string), "cars/%s.ini", PlayerName);// Добавляем имя игрока, в путь с машинами
        if(!fexist(string))
        {
                new iniFile = ini_createFile(string);// Создаём файл с именем игрока в папке cars
                if(iniFile < 0)// Если файл не открыт
                {
                        iniFile = ini_openFile(string);// Открываем
                }
                if(iniFile >= 0)// Если файл открыт
                {
                        ini_setInteger(iniFile,"CarId",0);// Записываем id машины игрока
                        ini_closeFile(iniFile);// Закрываем файл
                }
        }
        GetPriceCar(playerid);//Вызываем функцию получаения цены автомобиля
        OwnCar[playerid] = CreateVehicle(CarInfo[playerid][cCarId],550.2451,-1280.0016,16.9753,43.9849,0,0,-1);//Создаем авто
        SetVehicleVirtualWorld(OwnCar[playerid], playerid+1);//Переносим автомобиль в виртуальный мир равный id игрока + 1 (+1 чтобы авто не спавнилось в 0 вм когда id игрока = 0)
        ASalon[playerid][0] = CreatePlayerTextDraw(playerid, 410.333343, 370.444732, "Next");//создаем текстдрав next
        PlayerTextDrawLetterSize(playerid, ASalon[playerid][0], 0.510665, 1.829999);
        PlayerTextDrawTextSize(playerid, ASalon[playerid][0], 20.000000, 61.000000);
        PlayerTextDrawAlignment(playerid, ASalon[playerid][0], 2);
        PlayerTextDrawColor(playerid, ASalon[playerid][0], -1);
        PlayerTextDrawUseBox(playerid, ASalon[playerid][0], 1);
        PlayerTextDrawBoxColor(playerid, ASalon[playerid][0], 255);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][0], 0);
        PlayerTextDrawSetOutline(playerid, ASalon[playerid][0], 1);
        PlayerTextDrawBackgroundColor(playerid, ASalon[playerid][0], 255);
        PlayerTextDrawFont(playerid, ASalon[playerid][0], 2);
        PlayerTextDrawSetProportional(playerid, ASalon[playerid][0], 0);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][0], 0);
        PlayerTextDrawSetSelectable(playerid, ASalon[playerid][0], true);
        PlayerTextDrawShow(playerid,ASalon[playerid][0]);

        ASalon[playerid][1] = CreatePlayerTextDraw(playerid, 237.000000, 369.200317, "Back");//создаем текстдрав back
        PlayerTextDrawLetterSize(playerid, ASalon[playerid][1], 0.510665, 1.829999);
        PlayerTextDrawTextSize(playerid, ASalon[playerid][1], 20.000000, 61.000000);
        PlayerTextDrawAlignment(playerid, ASalon[playerid][1], 2);
        PlayerTextDrawColor(playerid, ASalon[playerid][1], -1);
        PlayerTextDrawUseBox(playerid, ASalon[playerid][1], 1);
        PlayerTextDrawBoxColor(playerid, ASalon[playerid][1], 255);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][1], 0);
        PlayerTextDrawSetOutline(playerid, ASalon[playerid][1], 1);
        PlayerTextDrawBackgroundColor(playerid, ASalon[playerid][1], 255);
        PlayerTextDrawFont(playerid, ASalon[playerid][1], 2);
        PlayerTextDrawSetProportional(playerid, ASalon[playerid][1], 0);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][1], 0);
        PlayerTextDrawSetSelectable(playerid, ASalon[playerid][1], true);
        PlayerTextDrawShow(playerid,ASalon[playerid][1]);

        format(string,sizeof(string),"Model: %s",VehicleNames[CarInfo[playerid][cCarId] - 400]);//создаем текстдрав Model
        ASalon[playerid][2] = CreatePlayerTextDraw(playerid, 25.666702, 231.481582, string);//создаем текстдрав Model
        PlayerTextDrawLetterSize(playerid, ASalon[playerid][2], 0.400333, 1.600000);
        PlayerTextDrawAlignment(playerid, ASalon[playerid][2], 1);
        PlayerTextDrawColor(playerid, ASalon[playerid][2], -1);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][2], 16);
        PlayerTextDrawSetOutline(playerid, ASalon[playerid][2], 1);
        PlayerTextDrawBackgroundColor(playerid, ASalon[playerid][2], 255);
        PlayerTextDrawFont(playerid, ASalon[playerid][2], 1);
        PlayerTextDrawSetProportional(playerid, ASalon[playerid][2], 1);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][2], 16);
        PlayerTextDrawShow(playerid,ASalon[playerid][2]);

        format(string,sizeof(string),"Price: %d",CarInfo[playerid][cPrice]);//создаем текстдрав Price
        ASalon[playerid][3] = CreatePlayerTextDraw(playerid, 26.333368, 253.881561, string);
        PlayerTextDrawLetterSize(playerid, ASalon[playerid][3], 0.400333, 1.600000);
        PlayerTextDrawAlignment(playerid, ASalon[playerid][3], 1);
        PlayerTextDrawColor(playerid, ASalon[playerid][3], -1);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][3], 16);
        PlayerTextDrawSetOutline(playerid, ASalon[playerid][3], 1);
        PlayerTextDrawBackgroundColor(playerid, ASalon[playerid][3], 255);
        PlayerTextDrawFont(playerid, ASalon[playerid][3], 1);
        PlayerTextDrawSetProportional(playerid, ASalon[playerid][3], 1);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][3], 16);
        PlayerTextDrawShow(playerid, ASalon[playerid][3]);
        

        ASalon[playerid][4] = CreatePlayerTextDraw(playerid, 543.333618, 221.526046, "Buy");//создаем текстдрав Buy
        PlayerTextDrawLetterSize(playerid, ASalon[playerid][4], 0.427333, 1.649777);
        PlayerTextDrawTextSize(playerid, ASalon[playerid][4], 640.000000, 15.000000);
        PlayerTextDrawAlignment(playerid, ASalon[playerid][4], 1);
        PlayerTextDrawColor(playerid, ASalon[playerid][4], 2147418367);
        PlayerTextDrawUseBox(playerid, ASalon[playerid][4], 1);
        PlayerTextDrawBoxColor(playerid, ASalon[playerid][4], 255);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][4], 0);
        PlayerTextDrawSetOutline(playerid, ASalon[playerid][4], 1);
        PlayerTextDrawBackgroundColor(playerid, ASalon[playerid][4], 255);
        PlayerTextDrawFont(playerid, ASalon[playerid][4], 1);
        PlayerTextDrawSetProportional(playerid, ASalon[playerid][4], 1);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][4], 0);
        PlayerTextDrawSetSelectable(playerid, ASalon[playerid][4], true);
        PlayerTextDrawShow(playerid, ASalon[playerid][4]);

        ASalon[playerid][5] = CreatePlayerTextDraw(playerid, 543.667053, 246.829727, "Exit");//создаем текстдрав Exit
        PlayerTextDrawLetterSize(playerid, ASalon[playerid][5], 0.427333, 1.649777);
        PlayerTextDrawTextSize(playerid, ASalon[playerid][5], 642.000000, 15.000000);
        PlayerTextDrawAlignment(playerid, ASalon[playerid][5], 1);
        PlayerTextDrawColor(playerid, ASalon[playerid][5], -16764161);
        PlayerTextDrawUseBox(playerid, ASalon[playerid][5], 1);
        PlayerTextDrawBoxColor(playerid, ASalon[playerid][5], 255);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][5], 0);
        PlayerTextDrawSetOutline(playerid, ASalon[playerid][5], 1);
        PlayerTextDrawBackgroundColor(playerid, ASalon[playerid][5], 255);
        PlayerTextDrawFont(playerid, ASalon[playerid][5], 1);
        PlayerTextDrawSetProportional(playerid, ASalon[playerid][5], 1);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][5], 0);
        PlayerTextDrawSetSelectable(playerid, ASalon[playerid][5], true);
        PlayerTextDrawShow(playerid, ASalon[playerid][5]);
        
        format(string,sizeof(string),"Model Id: %d",CarInfo[playerid][cCarId]);
        ASalon[playerid][6] = CreatePlayerTextDraw(playerid, 26.333368, 274.622467, string);//создаем текстдрав Id
        PlayerTextDrawLetterSize(playerid, ASalon[playerid][6], 0.400332, 1.600000);
        PlayerTextDrawAlignment(playerid, ASalon[playerid][6], 1);
        PlayerTextDrawColor(playerid, ASalon[playerid][6], -1);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][6], 16);
        PlayerTextDrawSetOutline(playerid, ASalon[playerid][6], 1);
        PlayerTextDrawBackgroundColor(playerid, ASalon[playerid][6], 255);
        PlayerTextDrawFont(playerid, ASalon[playerid][6], 1);
        PlayerTextDrawSetProportional(playerid, ASalon[playerid][6], 1);
        PlayerTextDrawSetShadow(playerid, ASalon[playerid][6], 16);
        PlayerTextDrawShow(playerid, ASalon[playerid][6]);

        SelectTextDraw(playerid,0xFF0000FF);//Вызываем курсор, чтобы игрок мог выбрать текстдрав
}




NextCar(playerid)//Функция вызова следующей машины
{
    if(CarInfo[playerid][cCarId] == 605) CarInfo[playerid][cCarId] = 400;// проверка, если предыдущая машины была последней, то перекидывает к первой машине
    else CarInfo[playerid][cCarId] ++;// если нет, то просто переменная плюсуется
    ///////////////////////////Проверка нету ли данного авто в списке запрещенных для автосалона машине/////////////////////////////////////////////
    for(new i =0; i<sizeof(nBuyVehicleIds); i++)
    {
        if(CarInfo[playerid][cCarId] == nBuyVehicleIds[i]) return NextCar(playerid);
    }
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CreateShopCar(playerid);//Вызываем функцию создания машины в автосалоне
    return true;
}

BackCar(playerid)//Функция вызова предыдущей машины, тут все аналогично NextCar(playerid) только все наоборот
{
    if(CarInfo[playerid][cCarId] == 400) CarInfo[playerid][cCarId] = 605;
    else CarInfo[playerid][cCarId] --;
    for(new i =0; i<sizeof(nBuyVehicleIds); i++)
    {
        if(CarInfo[playerid][cCarId] == nBuyVehicleIds[i]) return BackCar(playerid);
    }
    CreateShopCar(playerid);
    return true;
}

CreateShopCar(playerid)//Функцию создания машины в автосалоне
{
        new string[64];
        DestroyVehicle(OwnCar[playerid]);//Удаляем предыдущую машину
        OwnCar[playerid] = CreateVehicle(CarInfo[playerid][cCarId],550.2451,-1280.0016,16.9753,43.9849,0,0,-1);//Создаем новую машину
        SetVehicleVirtualWorld(OwnCar[playerid], playerid+1);//Устанавливаем этой машине виртуальный мир id игрока +1
        GetPriceCar(playerid);//получем цену машины
        format(string,sizeof(string),"Model: %s",VehicleNames[CarInfo[playerid][cCarId] - 400]);
        PlayerTextDrawSetString (playerid, ASalon[playerid][2] , string);//Выводим на текстдрав модель машины
        format(string,sizeof(string),"Price: %d",CarInfo[playerid][cPrice]);
        PlayerTextDrawSetString(playerid, ASalon[playerid][3], string);//Выводим на текстдрав цену машины
        format(string,sizeof(string),"Model Id: %d",CarInfo[playerid][cCarId]);
        PlayerTextDrawSetString(playerid, ASalon[playerid][6], string);//Выводим на текстдрав id машины
        return 1;
}



SaveCar(playerid)//Функцию сохранения машины
{
                new string[64];
                new PlayerName[MAX_PLAYER_NAME];//Переменная для имени
                GetPlayerName(playerid, PlayerName,sizeof(PlayerName));//берем имя игрока
                format(string, sizeof(string), "cars/%s.ini", PlayerName);// Добавляем имя игрока, в путь для сохранения
                new iniFile = ini_openFile(string);// Открываем файл по тому пути который указали.
                ini_setInteger(iniFile,"CarId",CarInfo[playerid][cCarId]);//Сохраняем id модели транспортая игрока
                ini_setInteger(iniFile,"Price",CarInfo[playerid][cPrice]);//Сохраняем цену автомобиля
                ini_setInteger(iniFile,"Color1",CarInfo[playerid][cColor1]);//Сохраняем цвет авто 1
            ini_setInteger(iniFile,"Color2",CarInfo[playerid][cColor2]);//Сохраняем цвет авто 2
                ini_setInteger(iniFile,"FrontBumper",CarInfo[playerid][cFrontBumper]);//Сохраняем передний бампер
            ini_setInteger(iniFile,"RearBumper",CarInfo[playerid][cRearBumper]);//Сохраняем задний бампер
                ini_setInteger(iniFile,"Hydraulics",CarInfo[playerid][cHydraulics]);//Сохраняем гидравлику
            ini_setInteger(iniFile,"Sideskirt",CarInfo[playerid][cSideskirt]);//Сохраняем пороги
                ini_setInteger(iniFile,"VentRight",CarInfo[playerid][cVentRight]);//ну внатуре хз что это такое
            ini_setInteger(iniFile,"VentLeft",CarInfo[playerid][cVentLeft]);//и это тоже
                ini_setInteger(iniFile,"Spoiler",CarInfo[playerid][cSpoiler]);//Сохраняем спойлер
            ini_setInteger(iniFile,"Exhaust",CarInfo[playerid][cExhaust]);//Сохраняем выхлоп
                ini_setInteger(iniFile,"Wheels",CarInfo[playerid][cWheels]);//Сохраняем колеса
            ini_setInteger(iniFile,"Stereo",CarInfo[playerid][cStereo]);//Сохраняем стерео
                ini_setInteger(iniFile,"Nitro",CarInfo[playerid][cNitro]);//Сохраняем нитро
            ini_setInteger(iniFile,"Lamps",CarInfo[playerid][cLamps]);//Сохраняем фары
            ini_setInteger(iniFile,"Hood",CarInfo[playerid][cHood]);//Сохраняем капот
                ini_setInteger(iniFile,"Roof",CarInfo[playerid][cRoof]);//Сохраняем крышу
            ini_setInteger(iniFile,"Bumper",CarInfo[playerid][cBumper]);//Сохраняем накладки на бампер/решетку радиатора
                ini_closeFile(iniFile);// Закрываем файл
}


GetCar(playerid)//функция загрузки машины ( Тут то же самое что и с сохранением, только все наоборот )
{
    new string[64];
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName,sizeof(PlayerName));
    format(string, sizeof(string), "cars/%s.ini", PlayerName);// Добавляем имя игрока, в путь для загрузки
    new iniFile = ini_openFile(string);// Открываем файл по тому пути который указали.
    ini_getInteger(iniFile,"CarId",CarInfo[playerid][cCarId]);//
    ini_getInteger(iniFile,"Price",CarInfo[playerid][cPrice]);//
    ini_getInteger(iniFile,"Color1",CarInfo[playerid][cColor1]);//
    ini_getInteger(iniFile,"Color2",CarInfo[playerid][cColor2]);//
    ini_getInteger(iniFile,"FrontBumper",CarInfo[playerid][cFrontBumper]);//
    ini_getInteger(iniFile,"RearBumper",CarInfo[playerid][cRearBumper]);//
    ini_getInteger(iniFile,"Hydraulics",CarInfo[playerid][cHydraulics]);//
    ini_getInteger(iniFile,"Sideskirt",CarInfo[playerid][cSideskirt]);//
    ini_getInteger(iniFile,"VentRight",CarInfo[playerid][cVentRight]);//
    ini_getInteger(iniFile,"VentLeft",CarInfo[playerid][cVentLeft]);//
    ini_getInteger(iniFile,"Spoiler",CarInfo[playerid][cSpoiler]);//
    ini_getInteger(iniFile,"Exhaust",CarInfo[playerid][cExhaust]);//
    ini_getInteger(iniFile,"Wheels",CarInfo[playerid][cWheels]);//
    ini_getInteger(iniFile,"Stereo",CarInfo[playerid][cStereo]);//
    ini_getInteger(iniFile,"Nitro",CarInfo[playerid][cNitro]);//
    ini_getInteger(iniFile,"Lamps",CarInfo[playerid][cLamps]);//
    ini_getInteger(iniFile,"Hood",CarInfo[playerid][cHood]);//
    ini_getInteger(iniFile,"Roof",CarInfo[playerid][cRoof]);//
    ini_getInteger(iniFile,"Bumper",CarInfo[playerid][cBumper]);//
    ini_closeFile(iniFile);// Закрываем файл
}


OnGameModeInit:
    new string[64];// Масив с путём для файла
    new PlayerName[MAX_PLAYER_NAME];//Переменная для записи имени
    GetPlayerName(playerid, PlayerName,sizeof(PlayerName));//Получаем имя игрока
    format(string,sizeof(string), "cars/%s.ini", PlayerName);//Форматируем
    if(fexist(string))//Если файл игрока в папке cars существует, загружаем его машину на сервер
    {
        GetCar(playerid);//функция загрузки машины
    }
 
Сверху