Author Topic: Giving PC the whole stack of items, not just one  (Read 331 times)

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Giving PC the whole stack of items, not just one
« on: February 17, 2012, 03:52:48 pm »


               A noob's problem, I don't know how such script should look like.
For example, I'd like the PC to be given a whole stack of darts , not only one (and take some gold from PC as well).
 
void main()
{

object oPC = GetPCSpeaker();

AssignCommand(oPC, TakeGoldFromCreature(2, oPC, TRUE));

CreateItemOnObject("nw_wthdt001", oPC);

}
 


How should such script as this be changed to give PC the whole stack, which is 50 darts?
Thanks '<img'>
               
               

               


                     Modifié par Grani, 17 février 2012 - 03:53 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Giving PC the whole stack of items, not just one
« Reply #1 on: February 17, 2012, 04:20:04 pm »


               If you click on the scripting function in the function list in the script editor, it'll pop up help text. Here's the help text for that function:


// Create an item with the template sItemTemplate in oTarget's inventory.
// - nStackSize: This is the stack size of the item to be created
// - sNewTag: If this string is not empty, it will replace the default tag from the template
// * Return value: The object that has been created.  On error, this returns
//   OBJECT_INVALID.
// If the item created was merged into an existing stack of similar items,
// the function will return the merged stack object. If the merged stack
// overflowed, the function will return the overflowed stack that was created.
object CreateItemOnObject(string sItemTemplate, object oTarget=OBJECT_SELF, int nStackSize=1, string sNewTag="")

The parameters with values already specified in the function declaration (oTarget, set to OBJECT_SELF, and nStackSize, set to 1, and sNewTag, set to a blank string) are known as default parameters - values the function will default to if you, the scripter, don't specify different ones, in your use of the function. All you have to do is specify a different stack size:

CreateItemOnObject("nw_wthdt001", oPC, 50);

Funky
               
               

               


                     Modifié par FunkySwerve, 17 février 2012 - 04:20 .
                     
                  


            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Giving PC the whole stack of items, not just one
« Reply #2 on: February 17, 2012, 04:43:09 pm »


               Thanks a lot '<img'>