Author Topic: RE: OnClientEnter TakeGoldFromCreature (TakeGold)  (Read 308 times)

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: OnClientEnter TakeGoldFromCreature (TakeGold)
« on: July 17, 2011, 08:11:02 pm »


               According to the Lexicon TakeGoldFromCreature and TakeGold both fail if run from an area or module event - This function will fail if called from an area or module event (like an area's OnEnter). However, it works on triggers, so you can just paint a trigger around the arrival area to get the same effect.

You can correctly execute these functions from area and module events - I have only tested the OnClientEnter and OnAreaEnter events, using ExecuteScript like so:

//Place this in the OnClientEnter or OnAreaEnter event
void main()
{
      object oTarget = GetEnteringObject();    
      ExecuteScript("takegold", oTarget);
}

You must also create a script (in this case named "Takegold") to house the function you are using...

//Takegold.nss
void main()
{
      //Take all gold and destroy it.  
     TakeGoldFromCreature(GetGold(OBJECT_SELF), OBJECT_SELF, TRUE);
}
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
RE: OnClientEnter TakeGoldFromCreature (TakeGold)
« Reply #1 on: July 17, 2011, 09:16:16 pm »


               TakeGoldFromCreature works directly in OnClientEnter.. ':?'

Lexicon is known to have numerous mistakes in it. (or otherwise outdated information)
               
               

               


                     Modifié par Xardex, 17 juillet 2011 - 08:20 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: OnClientEnter TakeGoldFromCreature (TakeGold)
« Reply #2 on: July 18, 2011, 12:07:37 pm »


               Tested it yesterday at length. Just checked again in an empty test script with only those two functions. Neither one works - so if you've got soemthing that does I'd love to see the block of code.  'Image

I know the Lexicon has errors or outdated info, but the updated version not so so much.
               
               

               


                     Modifié par Pstemarie, 18 juillet 2011 - 11:09 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
RE: OnClientEnter TakeGoldFromCreature (TakeGold)
« Reply #3 on: July 18, 2011, 03:35:20 pm »


               You have to assign an object to take the gold in order to make it work. I'm not sure why, it's just one of those oddities with nwscript.

int nGold = GetGold(oTarget);
AssignCommand (oTarget, TakeGoldFromCreature(nGold, oTarget, TRUE));

Oddly enough, you have have the character take the gold from themselves, and it'll still work as long as you're destroying it.

edit:  switched it to oTarget since that's what you used.
               
               

               


                     Modifié par Failed.Bard, 18 juillet 2011 - 02:36 .
                     
                  


            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: OnClientEnter TakeGoldFromCreature (TakeGold)
« Reply #4 on: July 18, 2011, 05:05:33 pm »


               Ty - hadn't thought of that route.

EDIT - that method does indeed work, but because of timing issues I wound up removing the gold and equipment stripping function to its own script anyway. 
               
               

               


                     Modifié par Pstemarie, 18 juillet 2011 - 04:43 .