Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Need help?

    Create a topic in the appropriate section
    Don't write everything in the chat!
  • Take a look at the marketplace

    There you can buy
    everything related to game servers
  • Don't want a ban?

    Please read our rules
    Don't disturb the order!
  • Sell or buy?

    Use services of the guarantor
    We will make your deal safe
  • 0
paranoyk

Вопрос по синтаксису,слотам и машине.

Есть строчка вида
if (slot != "SparkPlug")
Возникла необходимость расширить список исключений.
Строчка должна принять вид
if (slot != "SparkPlug" , "Hood") Так?
И второй вопрос
Слоты для машины у каждой по своему названы,с учётом цвета или как и писал выше достаточно указать "hood", "trunk"..?

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
1 час назад, paranoyk сказал:

Ползу проверять...блин, как хреново после вакцины-не то слово...

 

Да,всё работает. Значит проверка != работает только с одним значением?

 


Просто для общего развития, может пригодиться в будущем

if (slot != "SparkPlug" || slot != "Hood")

(слот НЕ SparkPlug ИЛИ слот НЕ Hood)
&& - И
|| = ИЛИ

например
 

if (slot == "Hood" && slot.color == "White")

если слот Hood И его цвет White
я не знаю как там доставать цвет части машины но тут я чисто суть объяснил

Edited by XenoZD (see edit history)

Share this post


Link to post
Share on other sites



  • 1
6 минут назад, paranoyk сказал:

@123new 
То есть
 

void CarScript() { TStringArray allSlots = new TStringArray(); this.ConfigGetTextArray("attachments", allSlots); foreach (string slot : allSlots) { array <string> CheckTypes = {"SparkPlug" , "Hood"}; lf (CheckTypes.Find(slot)< 0) { m_allSlotIds.Insert(InventorySlots.GetSlotIdFromString(slot)); } } }


    void CarScript()
    {
        TStringArray allSlots = new TStringArray();
        this.ConfigGetTextArray("attachments", allSlots);
        foreach (string slot : allSlots)
        {
            array <string> CheckTypes = {"SparkPlug" , "Hood"};
            lf (CheckTypes.Find(slot)< 0)
            {
                m_allSlotIds.Insert(InventorySlots.GetSlotIdFromString(slot));
            }
        }
    }

верно?

 

угу

Share this post


Link to post
Share on other sites
  • 0

делаешь массив, например

array <string> CheckTypes = {"SparkPlug" , "Hood"};

потом делаешь проверку на вхождение в массив

lf (CheckTypes.Find(slot)< 0)

{


}

функция Find в массиве возвращает -1 если вхождение не найдено, либо значение от 0 и выше если оно найдено (это будет номер элемента в массиве)

Share this post


Link to post
Share on other sites
  • 0

@123new 
То есть
 

    void CarScript()
    {
        TStringArray allSlots = new TStringArray();
        this.ConfigGetTextArray("attachments", allSlots);
        foreach (string slot : allSlots)
        {
            array <string> CheckTypes = {"SparkPlug" , "Hood"};
            lf (CheckTypes.Find(slot)< 0)
            {
                m_allSlotIds.Insert(InventorySlots.GetSlotIdFromString(slot));
            }
        }
    }

верно?

 

Share this post


Link to post
Share on other sites
  • 0

Ползу проверять...блин, как хреново после вакцины-не то слово...

 

Да,всё работает. Значит проверка != работает только с одним значением?

 

Edited by paranoyk (see edit history)

Share this post


Link to post
Share on other sites
  • 0
1 час назад, paranoyk сказал:

Ползу проверять...блин, как хреново после вакцины-не то слово...

 

Да,всё работает. Значит проверка != работает только с одним значением?

 

вакцина она такая, рекоммендуется отдыхать 😉

а так != это логическое НЕ РАВНО. гугл в помощь 😉

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site, you automaticly agree to our Guidelines and Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.