Author Topic: Gold for multiple items  (Read 640 times)

Legacy_Bazilbrush

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Gold for multiple items
« on: January 05, 2011, 08:03:39 pm »


               I am a scripting newbie and I need some advice. I have a sewer keeper in my module who will give 15gp for each rat whisker the player gives him. The problem I am having is coming up with a script that will take all of the whiskers in theplayers inventory and give 15gp for each one. Can anyone help?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Gold for multiple items
« Reply #1 on: January 05, 2011, 08:28:34 pm »


               "nw_i0_plot" has two useful functions in it for you.

GetNumItems

and

TakeNumItems
               
               

               
            

Legacy_Bazilbrush

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Gold for multiple items
« Reply #2 on: January 05, 2011, 08:41:00 pm »


               Thank you for taking the trouble to reply, Lightfoot. However, I am very new to scripting and wouldn't have a clue what to do with the functions. I was rather hoping that a generous soul would write a script for me lol. Hope someone can help!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Gold for multiple items
« Reply #3 on: January 06, 2011, 01:18:35 am »


               

#include "nw_i0_plot"
const string  sRatWhisker = "Replace this with the tag of the rat wiskers";

void main()
{
  object oPC = GetPCSpeaker();
  int nNumWhiskers = GetNumItems(oPC,sRatWhisker);

  TakeNumItems(oPC,sRatWhisker,nNumWhiskers);
  GiveGoldToCreature(oPC,nNumWhiskers * 15);
}

Just place you tag for the whiskers in place of the string up top.

ex.
const string  sRatWhisker = "RatWhisker";

I also assumed that you wanted it wtitten for an 'Action Taken' script from a conversation node.
               
               

               
            

Legacy_Bazilbrush

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
Gold for multiple items
« Reply #4 on: January 06, 2011, 01:41:42 am »


               That works brilliantly, thank you so much Lightfoot.