Гость stibs

Спидометр

В теме 5 сообщений

Спойлер

b896baa12061.png

При желании спидометр можно будет перевести на русский язык, однако при этом обязательно использование плагина CRP, иначе русские буквы просто не появятся! 

Перейдем к установке текстдрава и самого спидометра. 


Ко всем new: 

Спойлер

new Text:SBox;
new Text:SBox1;
new PlayerText:CarSpeed[MAX_PLAYERS];
new PlayerText:CarFuel[MAX_PLAYERS];
new PlayerText:CarMilliage[MAX_PLAYERS];
new PlayerText:CarLights[MAX_PLAYERS];
new PlayerText:CarEngine[MAX_PLAYERS];
new SpeedTimer[MAX_PLAYERS]; // таймер для спидометра
num vInfo
{
        vEngine,
        Float:vFuel,
        Float:vMilliage,
        vLights,
        Float:vPosx,Float:vPosy,Float:vPosz
};
new VehicleInfo[MAX_VEHICLES][vInfo];

 

В OnGameModeInit: 
 

Спойлер

SBox = TextDrawCreate(626.000000, 384.540008, "usebox");
TextDrawLetterSize(SBox, 0.000000, 5.905555);
TextDrawTextSize(SBox, 430.799987, 0.000000);
TextDrawAlignment(SBox, 1);
TextDrawColor(SBox, 0);
TextDrawUseBox(SBox, true);
TextDrawBoxColor(SBox, 102);
TextDrawSetShadow(SBox, 0);
TextDrawSetOutline(SBox, 0);
TextDrawFont(SBox, 0);

SBox1 = TextDrawCreate(601.875000, 383.250061, "LD_SPAC:white");
TextDrawLetterSize(SBox1, 0.000000, 0.000000);
TextDrawTextSize(SBox1, 21.250000, 57.166625);
TextDrawAlignment(SBox1, 1);
TextDrawColor(SBox1, 255);
TextDrawSetShadow(SBox1, 0);
TextDrawSetOutline(SBox1, 0);
TextDrawFont(SBox1, 4);

 

В OnPlayerConnect: 
 

Спойлер

CarSpeed[playerid] = CreatePlayerTextDraw(playerid, 442.399963, 386.026580, "SPEED: 100");
PlayerTextDrawLetterSize(playerid, CarSpeed[playerid], 0.401249, 1.430832);
PlayerTextDrawAlignment(playerid, CarSpeed[playerid], 1);
PlayerTextDrawColor(playerid, CarSpeed[playerid], -1);
PlayerTextDrawSetShadow(playerid, CarSpeed[playerid], 0);
PlayerTextDrawSetOutline(playerid, CarSpeed[playerid], 1);
PlayerTextDrawBackgroundColor(playerid, CarSpeed[playerid], 51);
PlayerTextDrawFont(playerid, CarSpeed[playerid], 1);
PlayerTextDrawSetProportional(playerid, CarSpeed[playerid], 1);

CarFuel[playerid] = CreatePlayerTextDraw(playerid, 442.149963, 401.026672, "FUEL: 1000");
PlayerTextDrawLetterSize(playerid, CarFuel[playerid], 0.401249, 1.430832);
PlayerTextDrawAlignment(playerid, CarFuel[playerid], 1);
PlayerTextDrawColor(playerid, CarFuel[playerid], -1);
PlayerTextDrawSetShadow(playerid, CarFuel[playerid], 0);
PlayerTextDrawSetOutline(playerid, CarFuel[playerid], 1);
PlayerTextDrawBackgroundColor(playerid, CarFuel[playerid], 51);
PlayerTextDrawFont(playerid, CarFuel[playerid], 1);
PlayerTextDrawSetProportional(playerid, CarFuel[playerid], 1);

CarMilliage[playerid] = CreatePlayerTextDraw(playerid, 441.899963, 416.610015, "MILLIAGE: 10000");
PlayerTextDrawLetterSize(playerid, CarMilliage[playerid], 0.401249, 1.430832);
PlayerTextDrawAlignment(playerid, CarMilliage[playerid], 1);
PlayerTextDrawColor(playerid, CarMilliage[playerid], -1);
PlayerTextDrawSetShadow(playerid, CarMilliage[playerid], 0);
PlayerTextDrawSetOutline(playerid, CarMilliage[playerid], 1);
PlayerTextDrawBackgroundColor(playerid, CarMilliage[playerid], 51);
PlayerTextDrawFont(playerid, CarMilliage[playerid], 1);
PlayerTextDrawSetProportional(playerid, CarMilliage[playerid], 1);

CarLights[playerid] = CreatePlayerTextDraw(playerid, 608.125000, 386.166625, "L");
PlayerTextDrawLetterSize(playerid, CarLights[playerid], 0.449999, 1.600000);
PlayerTextDrawAlignment(playerid, CarLights[playerid], 1);
PlayerTextDrawColor(playerid, CarLights[playerid], -1);
PlayerTextDrawSetShadow(playerid, CarLights[playerid], 0);
PlayerTextDrawSetOutline(playerid, CarLights[playerid], 1);
PlayerTextDrawBackgroundColor(playerid, CarLights[playerid], 51);
PlayerTextDrawFont(playerid, CarLights[playerid], 1);
PlayerTextDrawSetProportional(playerid, CarLights[playerid], 1);

CarEngine[playerid] = CreatePlayerTextDraw(playerid, 609.125000, 413.416778, "E");
PlayerTextDrawLetterSize(playerid, CarEngine[playerid], 0.449999, 1.600000);
PlayerTextDrawAlignment(playerid, CarEngine[playerid], 1);
PlayerTextDrawColor(playerid, CarEngine[playerid], -1);
PlayerTextDrawSetShadow(playerid, CarEngine[playerid], 0);
PlayerTextDrawSetOutline(playerid, CarEngine[playerid], 1);
PlayerTextDrawBackgroundColor(playerid, CarEngine[playerid], 51);
PlayerTextDrawFont(playerid, CarEngine[playerid], 1);
PlayerTextDrawSetProportional(playerid, CarEngine[playerid], 1);

 

В OnPlayerStateChange: 

Спойлер

if(newstate == PLAYER_STATE_DRIVER)
{
    if(!noeng(GetPlayerVehicleID(playerid)))
    {
        new v = GetPlayerVehicleID(playerid);
        VehicleInfo[v][vFuel] = 50.0;
        GetPlayerPos(playerid, VehicleInfo[v][vPosx],VehicleInfo[v][vPosy],VehicleInfo[v][vPosz]);
        TextDrawShowForPlayer(playerid, SBox);
        TextDrawShowForPlayer(playerid, SBox1);
        PlayerTextDrawShow(playerid, CarSpeed[playerid]);
        PlayerTextDrawShow(playerid, CarFuel[playerid]);
        PlayerTextDrawShow(playerid, CarMilliage[playerid]);
        PlayerTextDrawShow(playerid, CarLights[playerid]);
        PlayerTextDrawShow(playerid, CarEngine[playerid]);
        SpeedTimer[playerid] = SetTimerEx("UpdateSpeed",200,1,"d",playerid);
        return 1;
    }
}
if(oldstate == PLAYER_STATE_DRIVER)
{
    TextDrawHideForPlayer(playerid, SBox);
    TextDrawHideForPlayer(playerid, SBox1);
    PlayerTextDrawHide(playerid, CarSpeed[playerid]);
    PlayerTextDrawHide(playerid, CarFuel[playerid]);
    PlayerTextDrawHide(playerid, CarMilliage[playerid]);
    PlayerTextDrawHide(playerid, CarLights[playerid]);
    PlayerTextDrawHide(playerid, CarEngine[playerid]);
    KillTimer(SpeedTimer[playerid]);
    return 1;
}

 

В конец / середину мода создаем паблик: 

Спойлер

forward UpdateSpeed(playerid);
public UpdateSpeed(playerid)
{
        new string[256];
        new v = GetPlayerVehicleID(playerid);
        format(string,sizeof(string),"SPEED: %d",SpeedVehicle(playerid));
        PlayerTextDrawSetString(playerid, CarSpeed[playerid], string);
        format(string,sizeof(string),"FUEL: %d",floatround(VehicleInfo[v][vFuel]));
        PlayerTextDrawSetString(playerid, CarFuel[playerid], string);
        format(string,sizeof(string),"MILLIAGE: %d",floatround(VehicleInfo[v][vMilliage]));
        PlayerTextDrawSetString(playerid, CarMilliage[playerid], string);
        switch(VehicleInfo[v][vLights])
        {
            case 0: PlayerTextDrawSetString(playerid, CarLights[playerid], "~w~L");
            case 1: PlayerTextDrawSetString(playerid, CarLights[playerid], "~b~L");
        }
        if(VehicleInfo[v][vEngine]) PlayerTextDrawSetString(playerid, CarEngine[playerid], "~b~E");
        else PlayerTextDrawSetString(playerid, CarEngine[playerid],"~w~E");
        if(VehicleInfo[v][vFuel] <= 0)
        {
            VehicleInfo[v][vEngine] = 0;
            VehicleInfo[v][vFuel] = 0.0;
            SetVehicleParamsEx(v, VehicleInfo[v][vEngine], VehicleInfo[v][vLights],0,0,0,0,0);
        }
        if(GetPlayerDistanceFromPoint(playerid, VehicleInfo[v][vPosx], VehicleInfo[v][vPosy], VehicleInfo[v][vPosz]) > 50.0)
        {
            VehicleInfo[v][vMilliage] += 0.1;
            VehicleInfo[v][vFuel] -= 0.05;
            GetPlayerPos(playerid, VehicleInfo[v][vPosx],VehicleInfo[v][vPosy],VehicleInfo[v][
vPosz]);
        }
        return 1;
}

 

В OnPlayerKeyStateChange: 

Спойлер

if(newkeys & KEY_ACTION)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new v = GetPlayerVehicleID(playerid);
        if(!noeng(v))
        {
            if(!VehicleInfo[v][vFuel]) return 1;
            if(!VehicleInfo[v][vEngine]) VehicleInfo[v][vEngine] = 1;
            else VehicleInfo[v][vEngine] = 0;
            SetVehicleParamsEx(v, VehicleInfo[v][vEngine], VehicleInfo[v][vLights], 0, 0, 0, 0, 0);
            return 1;
        }
    }
}

 

В конец мода / ко всем стокам: 

Спойлер

stock noeng(carid)
{
        new model = GetVehicleModel(carid);
        if(model == 462||model == 448||model == 509|| model == 510||model == 481||model==468||model == 471 ||
        model == 511 || model == 512||model == 593||model == 520||model == 577||model == 476||model == 519 ||
        model == 460 || model == 513||model == 472||model==473||model == 493||model == 595 || model == 484 ||
        model == 430 || model == 453||model == 452||model == 446||model == 454 ||model == 548 ||model == 425||
        model == 417||model == 487||model == 488||model == 497||model == 563||model == 447||model == 469||model == 553) return 1;
        return 0;
}
stock SpeedVehicle(playerid)
{
    new Float:ST[4];
    if(IsPlayerInAnyVehicle(playerid))
        GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
        else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 100.3;
    return floatround(ST[3]);
}

 

Автор: wAx

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

взял себе

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Ранее такого не видел, простенький и оригинальный

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты
19 минут назад, Гость Гость сказал:

2013 год pawn-wiki.Мда.

ты бы ещё через 30 лет ответил

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!


Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.


Войти

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

  • Похожий контент

    • Aleksey98
      От Aleksey98
      Необходим человек: который сможет написать систему тюнинга!
      как на крупных проектах типа: Arizona и Radmir
      И еще требуется Мапперы на новый топовый проект!
      Связь : https://vk.com/id289498732
    • Mister Odin
      От Mister Odin
       
      new
       g_teleport_list[39][E_TELEPORT_LIST] = {  {"Спавн пгт.Батырево", 1802.3612, 2508.4824, 15.8887},  {"Спавн г.Арзамас", -113.5887, 977.7222, 12.0346},     {"Спавн г.Южный", 2744.2770, -2446.7246, 21.8988},     {"Центральный банк", 1852.020385,2040.791381,15.892713},  {"Рублёвка", -837.7783, 888.6161, 12.7232},  {"Казино", 1332.4252, 2358.7014, 17.6641},  {"Битва за контейнеры", 614.5167, 1722.3566, 12.0709},  {"Автосалон низкого класса", 2493.9616, -722.9544, 12.3315},  {"Автосалон среднего класса", 1407.7449, 455.4801, 13.1630},  {"Автосалон высокого класса", -14.0637, 2614.5664, 10.9892},   {"Мотосалон Harley Davidson", 785.720153, 750.465087, 12.000024},  {"Автошкола", 1909.174438,2227.679687,15.708162},  {"Военкомат", 1916.778564,2302.411376,15.574637},  {"Правительство области", -139.140975,593.789611,12.145712},  {"Отдел полиции №1 (ГИБДД)", 1906.805786,-2234.382812,11.257631},  {"Отдел полиции №2 (УМВД)", 2581.309326,-2416.139892,21.960090},  {"Отдел ФСБ", 1823.904663,2095.636718,15.848405},  {"Городская больница г.Арзамас", -285.797210,581.851562,12.120290},   {"СМИ", -317.708038,821.221679,13.051450},  {"Воинская часть", 1703.197265,1678.025878,15.279437},  {"Арзамасская ОПГ", 438.705322,1046.505126,12.002637},  {"Батыревская ОПГ", 1941.203857,2161.006591,15.705187},  {"Лыткаринская ОПГ", -2346.002441,75.257041,21.002962},  {"Шахта", 2381.5727, 1726.4451, -2.1506},  {"Завод", -1062.6697, 2204.1894, 38.0964},  {"Инкосация", 1864.1374, 2011.7136, 15.8546},  {"Транспортная Компания", 2362.1115, 1972.5627, 15.5530},  {"База механиков", 1840.918090,-118.025146,15.695312},  {"Курьерская служба доставки", 2764.509765,-2396.882568,21.890625},  {"Аренда автобуса(Южный)", 2771.041992,-2454.780761,21.845964},  {"Аренда автобуса(Арзамас)", -127.487670,943.652648,12.142824},   {"Аренда автобуса(Батырево)", 1798.986328,2529.591552,15.664262},  {"Гоночная трасса", -1568.7784, 1611.8305, 36.3971},  {"Дом на горе", -789.5397, -456.7479, 741.1422},  {"СТО и тюнинг-ателье", 1856.1375, -122.3266, 15.6888},  {"Аренда транспорта пгт.Батырево", 1763.641723,2255.673339,15.865348},  {"Аренда транспорта г.Арзамас", -36.923530,1360.673583,12.002090},  {"Аренда транспорта г.Южный", 1966.599975,-2603.943603,10.820312},  {"Тайный интерьер в Лыткарино", -2424.5818, 2846.3291, 40.7908} };