Jump to content
  • 0

How to put item ID in script function


ooGubAoo

Question


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.05
  • Content Count:  43
  • Reputation:   1
  • Joined:  06/08/23
  • Last Seen:  

This my script function

function	script	Test	{
      bonus bMaxHP,100;
end;
}

If i need to add item ID to use this function.

Ex. i want item ID 1101 and 1102 to use this script.

How to add it.

Thank you to help.

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   87
  • Joined:  06/30/18
  • Last Seen:  

You have to put the script in the item you want to use it on in the item_db_equip.yml.
 

  - Id: 1101
    AegisName: Sword
    Name: Sword
    Type: Weapon
    SubType: 1hSword
    Buy: 100
    Weight: 500
    Attack: 25
    Range: 1
    Slots: 3
    Jobs:
      Alchemist: true
      Assassin: true
      Blacksmith: true
      Crusader: true
      Knight: true
      Merchant: true
      Novice: true
      Rogue: true
      SuperNovice: true
      Swordman: true
      Thief: true
    Locations:
      Right_Hand: true
    WeaponLevel: 1
    EquipLevelMin: 2
    Refineable: true
    Script: |
      bonus bMaxHP,100;
  - Id: 1102
    AegisName: Sword_
    Name: Sword
    Type: Weapon
    SubType: 1hSword
    Buy: 100
    Weight: 500
    Attack: 25
    Range: 1
    Slots: 4
    Jobs:
      Alchemist: true
      Assassin: true
      Blacksmith: true
      Crusader: true
      Knight: true
      Merchant: true
      Novice: true
      Rogue: true
      SuperNovice: true
      Swordman: true
      Thief: true
    Locations:
      Right_Hand: true
    WeaponLevel: 1
    EquipLevelMin: 2
    Refineable: true
    Script: |
      bonus bMaxHP,100;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.05
  • Content Count:  43
  • Reputation:   1
  • Joined:  06/08/23
  • Last Seen:  

24 minutes ago, Winterfox said:

You have to put the script in the item you want to use it on in the item_db_equip.yml.
 

  - Id: 1101
    AegisName: Sword
    Name: Sword
    Type: Weapon
    SubType: 1hSword
    Buy: 100
    Weight: 500
    Attack: 25
    Range: 1
    Slots: 3
    Jobs:
      Alchemist: true
      Assassin: true
      Blacksmith: true
      Crusader: true
      Knight: true
      Merchant: true
      Novice: true
      Rogue: true
      SuperNovice: true
      Swordman: true
      Thief: true
    Locations:
      Right_Hand: true
    WeaponLevel: 1
    EquipLevelMin: 2
    Refineable: true
    Script: |
      bonus bMaxHP,100;
  - Id: 1102
    AegisName: Sword_
    Name: Sword
    Type: Weapon
    SubType: 1hSword
    Buy: 100
    Weight: 500
    Attack: 25
    Range: 1
    Slots: 4
    Jobs:
      Alchemist: true
      Assassin: true
      Blacksmith: true
      Crusader: true
      Knight: true
      Merchant: true
      Novice: true
      Rogue: true
      SuperNovice: true
      Swordman: true
      Thief: true
    Locations:
      Right_Hand: true
    WeaponLevel: 1
    EquipLevelMin: 2
    Refineable: true
    Script: |
      bonus bMaxHP,100;

 

Oh i think i will use script too mush item.

If i put script like this.

It will long to finish.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   87
  • Joined:  06/30/18
  • Last Seen:  

Well in this case you will have to use a script to add the itemscript to the items.

setarray(.@itemIds[0], 1101, 1102);

for (.@i; .@i < ; .@i++)
    setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100); }");

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.05
  • Content Count:  43
  • Reputation:   1
  • Joined:  06/08/23
  • Last Seen:  

On 7/29/2023 at 1:20 AM, Winterfox said:

Well in this case you will have to use a script to add the itemscript to the items.

setarray(.@itemIds[0], 1101, 1102);

for (.@i; .@i < ; .@i++)
    setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100); }");

 

Do like this?

// Weapon //
function    script    test    {
    setarray .@itemIds[2], 440008, 480058; // ประกาศอาร์เรย์ itemIds ขนาด 2

    for (.@i = 0; .@i < getarraysize(.@itemIds); .@i++) {
        setitemscript .@itemIds[.@i], "bonus2 bMaxHP, 100000;";
    }
}

When run server dont have error.

But dont get bonus

Edited by ooGubAoo
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   87
  • Joined:  06/30/18
  • Last Seen:  

7 hours ago, ooGubAoo said:

        setitemscript .@itemIds[.@i], "bonus2 bMaxHP, 100000;";

That is wrong. You should take a better look at my example.
 

setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100); }");

You need to add the {} and bonus is enough since you only need 1 value to set the max hp bonus.

Edited by Winterfox
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.05
  • Content Count:  43
  • Reputation:   1
  • Joined:  06/08/23
  • Last Seen:  

16 minutes ago, Winterfox said:

That is wrong. You should take a better look at my example.
 

setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100); }");

You need to add the {} and bonus is enough since you only need 1 value to set the max hp bonus.

i read in doc to use setarray.

i do like this T^T

But dont work

// Weapon //
prontera,160,190,3    script    TestBonus    847,{
    setarray(.@itemIds[0], 440008, 1102); // ประกาศอาร์เรย์ itemIds ขนาด 2

    for (.@i = 0; .@i < getarraysize(.@itemIds); .@i++) {
        setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); }");
    }
}

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   87
  • Joined:  06/30/18
  • Last Seen:  

16 minutes ago, ooGubAoo said:

i read in doc to use setarray.

i do like this T^T

But dont work

// Weapon //
prontera,160,190,3    script    TestBonus    847,{
    setarray(.@itemIds[0], 440008, 1102); // ประกาศอาร์เรย์ itemIds ขนาด 2

    for (.@i = 0; .@i < getarraysize(.@itemIds); .@i++) {
        setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); }");
    }
}

You can use a floting npc. The npc doesn't need to be visible. You als should call the code using the OnInit label, so you don't have to call it manually.
 

-    script    TestBonus    FAKE_NPC,{
    OnInit:
      setarray(.@itemIds[0], 440008, 1102); // ประกาศอาร์เรย์ itemIds ขนาด 2

      for (.@i = 0; .@i < getarraysize(.@itemIds); .@i++)
          setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); }");
}

 

Edited by Winterfox
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.05
  • Content Count:  43
  • Reputation:   1
  • Joined:  06/08/23
  • Last Seen:  

21 minutes ago, Winterfox said:

You can use a floting npc. The npc doesn't need to be visible. You als should call the code using the OnInit label, so you don't have to call it manually.
 

-    script    TestBonus    FAKE_NPC,{
    OnInit:
      setarray(.@itemIds[0], 440008, 1102); // ประกาศอาร์เรย์ itemIds ขนาด 2

      for (.@i = 0; .@i < getarraysize(.@itemIds); .@i++)
          setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); }");
}

 

It Work

Thank You very much

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.05
  • Content Count:  43
  • Reputation:   1
  • Joined:  06/08/23
  • Last Seen:  

28 minutes ago, Winterfox said:

You can use a floting npc. The npc doesn't need to be visible. You als should call the code using the OnInit label, so you don't have to call it manually.
 

-    script    TestBonus    FAKE_NPC,{
    OnInit:
      setarray(.@itemIds[0], 440008, 1102); // ประกาศอาร์เรย์ itemIds ขนาด 2

      for (.@i = 0; .@i < getarraysize(.@itemIds); .@i++)
          setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); }");
}

 

And 1 Qution

If i need 2 bonus. i can put like this ?

setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000),bonus(bCritical, 100); }");
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   87
  • Joined:  06/30/18
  • Last Seen:  

4 minutes ago, ooGubAoo said:

And 1 Qution

If i need 2 bonus. i can put like this ?

setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000),bonus(bCritical, 100); }");

It needs to be ";" instead of ",".
 

setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); bonus(bCritical, 100); }");

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.05
  • Content Count:  43
  • Reputation:   1
  • Joined:  06/08/23
  • Last Seen:  

setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); bonus(bCritical, 100); }");

i can use bonus4 in this script?

ex

bonus4 bAutoSpellOnSkill,"MG_FIREBOLT","MG_FIREBOLT",5,400

to

bonus4(bAutoSpellOnSkill,"MG_FIREBOLT","MG_FIREBOLT",5,400)

like this

setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); bonus(bCritical, 100); bonus4(bAutoSpellOnSkill,"MG_FIREBOLT","MG_FIREBOLT",5,400); }");

Edited by ooGubAoo
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   87
  • Joined:  06/30/18
  • Last Seen:  

42 minutes ago, ooGubAoo said:
setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); bonus(bCritical, 100); }");

i can use bonus4 in this script?

ex

bonus4 bAutoSpellOnSkill,"MG_FIREBOLT","MG_FIREBOLT",5,400

to

bonus4(bAutoSpellOnSkill,"MG_FIREBOLT","MG_FIREBOLT",5,400)

like this

setitemscript(.@itemIds[.@i], "{ bonus(bMaxHP, 100000); bonus(bCritical, 100); bonus4(bAutoSpellOnSkill,"MG_FIREBOLT","MG_FIREBOLT",5,400); }");

Why don't you simply try it before asking if it works?

Everything inside the {} works like in any other script. So of course you can simply chain commands after each other.

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.05
  • Content Count:  43
  • Reputation:   1
  • Joined:  06/08/23
  • Last Seen:  

40 minutes ago, Winterfox said:

Why don't you simply try it before asking if it works?

Everything inside the {} works like in any other script. So of course you can simply chain commands after each other.

Thank you to help every time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...