Aller au contenu

Photo

RE: OnClientEnter TakeGoldFromCreature (TakeGold)


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

#1
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
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);
}

#2
Xardex

Xardex
  • Members
  • 217 messages
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 .


#3
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
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 IPB

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 .


#4
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
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 .


#5
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
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 .