Добро пожаловать на Pro Pawn - Портал о PAWN-скриптинге.
Показано с 1 по 2 из 2
  1. #1
    Аватар для Vasya_Pupkin
    Пользователь

    Статус
    Оффлайн
    Регистрация
    13.02.2016
    Сообщений
    77
    Репутация:
    0 ±

    Как оптимизировать

    Всем Добрый день.
    У меня вопрос
    Как нибудь можно оптимизировать код ниже?
    сократить количество строк?
    Код:
     if(weaponid == 0)
            {
                switch(armour)
                {
                    case 0:
                    {
                        switch(bodypart)
                        {
                            case 3: SetPlayerHealth(playerid, health - 5); // Torso.
                            case 4: SetPlayerHealth(playerid, health - 5); // Groin.
                            case 5: SetPlayerHealth(playerid, health - 5);  // Left Arm.
                            case 6: SetPlayerHealth(playerid, health - 5); // Right Arm.
                            case 7: SetPlayerHealth(playerid, health - 5);  // Left Leg.
                            case 8: SetPlayerHealth(playerid, health - 5); // Right Leg.
                            case 9: SetPlayerHealth(playerid, health - 5); // Head.
                        }
                    }
                    default:
                    {
                        switch(bodypart)
                        {
                            case 3: SetPlayerHealth(playerid, health - 5); // Torso.
                            case 4: SetPlayerHealth(playerid, health - 5); // Groin.
                            case 5: SetPlayerHealth(playerid, health - 5);  // Left Arm.
                            case 6: SetPlayerHealth(playerid, health - 5); // Right Arm.
                            case 7: SetPlayerHealth(playerid, health - 5);  // Left Leg.
                            case 8: SetPlayerHealth(playerid, health - 5); // Right Leg.
                            case 9: SetPlayerHealth(playerid, health - 5); // Head.
                        }
                    }
                }
            }
    Если возможно то покажите на этом примере.

    - - - Добавлено - - -

    Все разобрался тему можно закрыть .

  2. #2
    Аватар для vovandolg
    Пользователь

    Статус
    Оффлайн
    Регистрация
    17.11.2015
    Адрес
    Stavropol
    Сообщений
    1,369
    Репутация:
    113 ±
    PHP код:
    if(weaponid == 0)
    {
        if(
    armour == 0
        {
            if(
    bodypart 10SetPlayerHealth(playeridhealth 5);
        }
        else
        {
            if(
    bodypart 10SetPlayerHealth(playeridhealth 5);
        }

    [Anticheat]___Invisible Fly Hack
    [Anticheat]____Weapon/Ammo Hack
    [Function]______ResetPlayerWeaponSlot
    [Function]_______FIX_SetPlayerAmmo
    [ServerMod]______TDM | Zombie Apokalypse

 

 

Информация о теме

Пользователи, просматривающие эту тему

Эту тему просматривают: 1 (пользователей: 0 , гостей: 1)

Ваши права

  • Вы не можете создавать новые темы
  • Вы не можете отвечать в темах
  • Вы не можете прикреплять вложения
  • Вы не можете редактировать свои сообщения
  •