Aller au contenu

Photo

Removing duplicates of an item from a container


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
Jsmith0730

Jsmith0730
  • Members
  • 346 messages
So I finally got my little mod working, except now there's one problem:

                        object oArmor = CreateItemOnObject(R"gen_im_arm_cht_lgt_rlr.uti",GetObjectByTag("bhn200ip_chest_pc"));                        object oBoots = CreateItemOnObject(R"gen_im_arm_bot_lgt_rlr.uti",GetObjectByTag("bhn200ip_chest_pc"));                        object oGloves = CreateItemOnObject(R"gen_im_arm_glv_lgt_ltr.uti",GetObjectByTag("bhn200ip_chest_pc"));                        object oBow = CreateItemOnObject(R"gen_im_wep_rng_lbw_lbw.uti",GetObjectByTag("bhn200ip_chest_pc"));                        object oDagger1 = CreateItemOnObject(R"gen_im_wep_mel_dag_dag.uti",GetObjectByTag("bhn200ip_chest_pc"));


Not sure why, but when I go to loot the chest, I have five of every item inside. It doesn't increase the amount if I reload, it's just always five. I tried doing ),1); at the end but that didn't work. 

How can I get it to spawn only one of each item?

#2
Magic

Magic
  • Members
  • 187 messages
Where are these lines of code? Are they tied to the spawn event of the container? Maybe they are executed for several events. The error does not seem to be in these lines themselves.

If you like to improve the code, you could declare the object variable first, then use it later on:
object oChest = GetObjectByTag("bhn200ip_chest_pc");
object oArmor = CreateItemOnObject(R"gen_im_arm_cht_lgt_rlr.uti",oChest);
object oGloves = CreateItemOnObject(R"gen_im_arm_glv_lgt_ltr.uti",oChest);

Similar lines for the other items (oChest line only once). It reduces potential problems if you change the code later on. Just a suggestion though.

Modifié par Magic, 23 décembre 2009 - 02:58 .


#3
Phaenan

Phaenan
  • Members
  • 315 messages

Magic wrote...
Where are these lines of code? Are they tied to the spawn event of the container? Maybe they are executed for several events. The error does not seem to be in these lines themselves.


The lines are indeed fine, and are most likely simply  executed several times.
That being said, we folks will need a more complete code excerpt before we're able to actually point the mistake out. :blush: