Доступ к готовым решениям

Переход в группу "Пользователь"

300.00
Одноразовый платёж
Быстрый переход в группу "Пользователи", без надобности написания постов и ожидания.

Покупка дает возможность:
Быть полноправным участником форума
Нормальное копирование кода
Создавать темы
Скачивать файлы
Доступ к архиву Pawno-Info

Мануал Удержать равновесие на транспорте (Сёрфинг)

Salery

Изучающий
Пользователь
Регистрация
27 Ноя 2016
Сообщения
542
Лучшие ответы
0
Репутация
243
Награды
2
Добрый день, обычно мы видим такую картину, игрок запрыгивает на крышу машины и его сбрасывает,
и мне пришла идея, почему бы не сделать сёрфинг на крыше машине (Saints Row ?)

Т.к систему тестить одному практически невозможно, в ней возможны мелкие баги или недоработки.
Система тестировалась, но возможно мы что-то упустили.
Информация:

  • Сёрфинг не доступен на лодках
  • Игрок будет начинать сёрфить если машина в движении и ее скорость больше 30км
  • При падении игрок теряет жизни
  • Игрок может спрыгнуть с авто нажав клавишу прыжка
Приступим к мануалу.

К дефайнам

PHP:
#define cell_click 42
К переменным

PHP:
new Text:s_box[5],
    PlayerText:s_min[MAX_PLAYERS],
    PlayerText:s_key[MAX_PLAYERS],
    s_timer[MAX_PLAYERS],
    y_sec[MAX_PLAYERS];
    
const     Float:s_plus = 2.1,
        Float:s_max = 255.218139;
        
@_y_surf(playerid);
@_y_c(playerid);

enum s_surf
{
    s_progress,
    Float:s_size,
    s_key_state,
}
new s_info[MAX_PLAYERS][s_surf];
В низ мода

PHP:
stock s_clear_info(playerid)
{
    s_info[playerid][s_progress] = 21;
    s_info[playerid][s_size] = 299.318139;
    s_info[playerid][s_key_state] = -1;
    SetPVarInt(playerid, "y_ok", 0);
    for(new s = 0; s < sizeof(s_box); s ++) {    TextDrawHideForPlayer(playerid, s_box[s]);  }
    PlayerTextDrawHide(playerid, s_min[playerid]);
    PlayerTextDrawHide(playerid, s_key[playerid]);
    y_sec[playerid] = 0;
    SetTimerEx("@_y_c", 2000, false, "i", playerid);
    SetPVarInt(playerid, "y_i", 0);
}
@_y_c(playerid) return ClearAnimations(playerid);
stock t_td_static()
{
    s_box[0] = TextDrawCreate(255.001464, 383.000000, "usebox");
    TextDrawLetterSize(s_box[0], 0.000000, 2.535187);
    TextDrawTextSize(s_box[0], 372.816955, 0.000000);
    TextDrawAlignment(s_box[0], 1);
    TextDrawColor(s_box[0], 0);
    TextDrawUseBox(s_box[0], true);
    TextDrawBoxColor(s_box[0], -1893806000);
    TextDrawSetShadow(s_box[0], 0);
    TextDrawSetOutline(s_box[0], 0);
    TextDrawFont(s_box[0], 0);


    s_box[1] = TextDrawCreate(256.875549, 384.750000, "usebox");
    TextDrawLetterSize(s_box[1], 0.000000, 2.081479);
    TextDrawTextSize(s_box[1], 371.411407, 0.000000);
    TextDrawAlignment(s_box[1], 1);
    TextDrawColor(s_box[1], 0);
    TextDrawUseBox(s_box[1], true);
    TextDrawBoxColor(s_box[1], 102);
    TextDrawSetShadow(s_box[1], 0);
    TextDrawSetOutline(s_box[1], 0);
    TextDrawFont(s_box[1], 0);


    s_box[2] = TextDrawCreate(348.236785, 385.916687, "s_max");
    TextDrawLetterSize(s_box[2], 0.000000, 1.869074);
    TextDrawTextSize(s_box[2], 254.749633, 0.000000);
    TextDrawAlignment(s_box[2], 1);
    TextDrawColor(s_box[2], 0);
    TextDrawUseBox(s_box[2], true);
    TextDrawBoxColor(s_box[2], 102);
    TextDrawSetShadow(s_box[2], 0);
    TextDrawSetOutline(s_box[2], 0);
    TextDrawFont(s_box[2], 0);


    s_box[3] = TextDrawCreate(373.537322, 385.916656, "usebox");
    TextDrawLetterSize(s_box[3], 0.000000, 1.944811);
    TextDrawTextSize(s_box[3], 345.174194, 0.000000);
    TextDrawAlignment(s_box[3], 1);
    TextDrawColor(s_box[3], 0);
    TextDrawUseBox(s_box[3], true);
    TextDrawBoxColor(s_box[3], 102);
    TextDrawSetShadow(s_box[3], 0);
    TextDrawSetOutline(s_box[3], 0);
    TextDrawFont(s_box[3], 0);


    s_box[4] = TextDrawCreate(291.420471, 371.583404, "SURFING");
    TextDrawLetterSize(s_box[4], 0.233542, 0.940832);
    TextDrawAlignment(s_box[4], 1);
    TextDrawColor(s_box[4], -1);
    TextDrawSetShadow(s_box[4], 0);
    TextDrawSetOutline(s_box[4], 1);
    TextDrawBackgroundColor(s_box[4], 51);
    TextDrawFont(s_box[4], 2);
    TextDrawSetProportional(s_box[4], 1);
}
stock y_td_player(playerid)
{
    s_min[playerid] = CreatePlayerTextDraw(playerid, 259.686676, 386.500000, "s_min");
    PlayerTextDrawLetterSize(playerid, s_min[playerid], 0.000000, 1.692590);
    PlayerTextDrawTextSize(playerid, s_min[playerid], 255.218139, 0.000000);
    PlayerTextDrawAlignment(playerid, s_min[playerid], 1);
    PlayerTextDrawColor(playerid, s_min[playerid], 0);
    PlayerTextDrawUseBox(playerid, s_min[playerid], true);
    PlayerTextDrawBoxColor(playerid, s_min[playerid], 102);
    PlayerTextDrawSetShadow(playerid, s_min[playerid], 0);
    PlayerTextDrawSetOutline(playerid, s_min[playerid], 0);
    PlayerTextDrawFont(playerid, s_min[playerid], 0);


    s_key[playerid] = CreatePlayerTextDraw(playerid, 356.544708, 386.750030, "Y");
    PlayerTextDrawLetterSize(playerid, s_key[playerid], 0.231200, 1.547499);
    PlayerTextDrawAlignment(playerid, s_key[playerid], 1);
    PlayerTextDrawColor(playerid, s_key[playerid], -1);
    PlayerTextDrawSetShadow(playerid, s_key[playerid], 0);
    PlayerTextDrawSetOutline(playerid, s_key[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, s_key[playerid], 51);
    PlayerTextDrawFont(playerid, s_key[playerid], 2);
    PlayerTextDrawSetProportional(playerid, s_key[playerid], 1);
}
stock GetVehicleSpeed(vehicleid)
{
    new Float:Px,Float:Py,Float:Pz;
    GetVehicleVelocity(vehicleid,Px,Py,Pz);
    return floatround(floatsqroot(Px*Px+Py*Py+Pz*Pz) * 100.0);
}
stock y_back_box(playerid)
{
    if(0!=s_info[playerid][s_progress])
    {
        new Float:si = s_info[playerid][s_size] - s_plus;
        s_info[playerid][s_size] = si;
        PlayerTextDrawTextSize(playerid, s_min[playerid], s_info[playerid][s_size], 0.000000);
        s_info[playerid][s_progress] --;
        switch(random(2))
        {
            case 0:
            {
                s_info[playerid][s_key_state] = 0; // Y
                PlayerTextDrawSetString(playerid, s_key[playerid], "Y");
                PlayerTextDrawShow(playerid, s_key[playerid]);
            }
            case 1:
            {
                s_info[playerid][s_key_state] = 1; // N
                PlayerTextDrawSetString(playerid, s_key[playerid], "N");
                PlayerTextDrawShow(playerid, s_key[playerid]);
            }
        }
    }
}
stock y_update_box(playerid)
{
    if(cell_click!=s_info[playerid][s_progress])
    {
        new Float:si = s_info[playerid][s_size] + s_plus;
        s_info[playerid][s_size] = si;
        PlayerTextDrawTextSize(playerid, s_min[playerid], s_info[playerid][s_size], 0.000000);
        s_info[playerid][s_progress] ++;
        switch(random(2))
        {
            case 0:
            {
                s_info[playerid][s_key_state] = 0; // Y
                PlayerTextDrawSetString(playerid, s_key[playerid], "Y");
                PlayerTextDrawShow(playerid, s_key[playerid]);
            }
            case 1:
            {
                s_info[playerid][s_key_state] = 1; // N
                PlayerTextDrawSetString(playerid, s_key[playerid], "N");
                PlayerTextDrawShow(playerid, s_key[playerid]);
            }
        }
    }
    return true;
}
Так же в низ мода добавим таймер

PHP:
@_y_surf(playerid)
{
    if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID)
    {
        new carid = GetPlayerSurfingVehicleID(playerid),
            Float:y_speed = GetVehicleSpeed(carid);
        switch(GetVehicleModel(carid))
        {
            case 430,446,452,453,454,472,473,484,493,595: { return true; }
            default:{}
        }
        if(y_speed > 30)
        {
            //------------------- [ 200 ms ] --------------------
            ApplyAnimation(playerid,"BSKTBALL","BBALL_def_loop",4.0,1,0,0,0,0);
            if(GetPVarInt(playerid, "y_i") == 0)
            {
                SendClientMessage(playerid, -1, "Что бы спрыгнуть с машины нажмите клавишу прыжка");
                SetPVarInt(playerid, "y_i", 1);
            }
            //------------------- [ 1200 ms ] -----------------
            if(y_sec[playerid] >= 12)
            {
                if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID)
                {
                    for(new s = 0; s < sizeof(s_box); s ++) {    TextDrawShowForPlayer(playerid, s_box[s]);  }
                    PlayerTextDrawShow(playerid, s_min[playerid]);
                    PlayerTextDrawShow(playerid, s_key[playerid]);
                    ApplyAnimation(playerid,"BSKTBALL","BBALL_def_loop",4.0,1,0,0,0,0);
                    SetPVarInt(playerid, "y_ok", 1);
                    if(s_info[playerid][s_progress] != 0)
                    {
                        y_back_box(playerid);
                    } else {
                    new Float: p[3];
                    GetPlayerPos(playerid, p[0], p[1], p[2]);
                    SetPlayerPos(playerid, p[0] + 1, p[1] + 1, p[2] + 1);
                    new Float:hp; GetPlayerHealth(playerid, hp);
                    new Float:m_hp = hp - 10;
                    SetPlayerHealth(playerid, m_hp);
                    s_clear_info(playerid);
                    return SendClientMessage(playerid, -1, "Вы не смогли удержаться на машине");
                    }
                }
                y_sec[playerid] = 0;
            }
            y_sec[playerid]++;
        }
    }
    return true;
}
В OnPlayerKeyStateChange

PHP:
    if(newkeys == KEY_JUMP && GetPVarInt(playerid, "y_ok") == 1)
    {
        ApplyAnimation( playerid, "PED", "KO_SKID_FRONT", 4.1, 1, 1, 1, 1, 1 );
        new Float: p[3];
        GetPlayerPos(playerid, p[0], p[1], p[2]);
        SetPlayerPos(playerid, p[0] + 1, p[1] + 1, p[2] + 1);
        s_clear_info(playerid);
    }
    if(newkeys == KEY_YES)
    {
        if(GetPVarInt(playerid, "y_ok") == 1)
        {
            if(s_info[playerid][s_key_state] == 0)
            {
                y_update_box(playerid);
            }
            else {    y_back_box(playerid);   }
        }
    }
    if(newkeys == KEY_NO)
    {
        if(GetPVarInt(playerid, "y_ok") == 1)
        {
            if(s_info[playerid][s_key_state] == 1)
            {
                y_update_box(playerid);
            }
            else { y_back_box(playerid); }
        }
    }
В OnPlayerConnect

PHP:
    s_info[playerid][s_size] = s_max;
    y_td_player(playerid);
    s_clear_info(playerid);
    KillTimer(s_timer[playerid]);
    s_timer[playerid] = SetTimerEx("@_y_surf", 200, true, "i", playerid);
В OnGameModeInit

PHP:
t_td_static();



Скриншот

Скрин сделан в дебаг режиме, у вас не будет флуда в чат

Система писалась на основе мода bare
Версия с дебаг режимом
 
Последнее редактирование:
Сверху Снизу