Aller au contenu

Photo

Giving PC the whole stack of items, not just one


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

#1
Grani

Grani
  • Members
  • 557 messages
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 :)

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


#2
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
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 .


#3
Grani

Grani
  • Members
  • 557 messages
Thanks a lot :)