Author Topic: NO GOLD NAME,TAG,RES  (Read 379 times)

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« on: March 14, 2011, 11:41:47 pm »


               voidmain()
{
object oPC = GetModuleItemAcquiredBy();

object oItem = GetModuleItemAcquired();
//DEBUG INFO
string sItemN = GetName(oItem);
string sItemT = GetTag(GetModuleItemAcquired());
string sItemR = GetResRef(oItem);
FloatingTextStringOnCreature(" you found NAME:..."+sItemN+"...",oPC,FALSE);
FloatingTextStringOnCreature(" you found TAG:..."+sItemT+"...",oPC,FALSE);
FloatingTextStringOnCreature(" you found RESREF..."+sItemR+"...",oPC,FALSE);

int iPC_Gold=GetGold(oPC);

if( ! GetIsPC(oPC) ){return;}

if(GetIsObjectValid(oItem)==FALSE){return;}
if(GetIsObjectValid(oItem)==TRUE)
{
//::----------------------------------------------------------------------------
//::---------------------------[ aquire gold ]----------------------------------
//::----------------------------------------------------------------------------
}

}

When I run this script it will not give me any info on the gold no name no tag no res ref, did I use the wrong function to get item aquired? not sure why this is happening. could some one tell me im scratchn my head at it.

this is a script ran in the module event item aquired script

Thanks all Greyfort
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #1 on: March 14, 2011, 11:51:08 pm »


               Worked fine for me once I put a space between void and main(). (Otherwise it doesn't even compile.)

-420
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #2 on: March 15, 2011, 12:09:36 am »


               No, You did not do anything wrong. The problem is that gold in HardCoded. It is an item when it is on the ground or in a containers inventory. But as soon as you pick it up the Gold Item is destroyed before the module event fires. By the time the module Event fires the gold has been added to the players amount of gold. This is nothing more then a number on the creatures object structure. The gold item is gone, Therefore you get no name/tag/resref.

EDIT: You will also get an invalid item from your check.
               
               

               


                     Modifié par Lightfoot8, 15 mars 2011 - 12:11 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #3 on: March 15, 2011, 12:15:35 am »


               

Lightfoot8 wrote...

No, You did not do anything wrong. The problem is that gold in HardCoded. It is an item when it is on the ground or in a containers inventory. But as soon as you pick it up the Gold Item is destroyed before the module event fires. By the time the module Event fires the gold has been added to the players amount of gold. This is nothing more then a number on the creatures object structure. The gold item is gone, Therefore you get no name/tag/resref.

EDIT: You will also get an invalid item from your check.

yes but you will get valid GetModuleItemAcquiredStackSize(), so

if(GetModuleItemAcquired() == OBJECT_INVALID && GetModuleItemAcquiredStackSize() > 0)

then you catched gold
               
               

               


                     Modifié par ShaDoOoW, 15 mars 2011 - 12:16 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #4 on: March 15, 2011, 12:39:21 am »


               

ShaDoOoW wrote...

yes but you will get valid GetModuleItemAcquiredStackSize(), so

if(GetModuleItemAcquired() == OBJECT_INVALID && GetModuleItemAcquiredStackSize() > 0)

then you catched gold



That is good to know,  I did not know that one. 'Image
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #5 on: March 15, 2011, 12:41:23 am »


               Whoops, I should have read more closely. Very interesting information about the "gold" item.

-420
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #6 on: March 15, 2011, 01:00:07 am »


               ok... 1 I tried what you said shadow and it worked to aquire gold Thanks, but now issue with unaquir Gold any Ideas there?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #7 on: March 15, 2011, 01:26:29 am »


               There you may have a problem. Gold does not fire the event when you drop it.

What are you tring to do?

EDIT:  I would also guess that gold is only going to fire the onAcquire event when you get it by picking up an item.  and not every time it is created on the player.  I have not tested it so I my be wrong.
               
               

               


                     Modifié par Lightfoot8, 15 mars 2011 - 01:28 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #8 on: March 15, 2011, 01:47:03 am »


               I dont know if it will fire with other stacked items, I think not because they often are valid Objects.
so far No fire with other items, it works only when I pick up gold piece and it fires because the object item is invalid and stack size function:

if(GetModuleItemAcquired() == OBJECT_INVALID && GetModuleItemAcquiredStackSize() > 0)
{
//::----------------------------------------------------------------------------
//::---------------------------[ aquire gold ]----------------------------------
//::----------------------------------------------------------------------------
}

works firing my aquire gold script.

I thought about a simalr approuch for unaquire gold but I need a var that keeps track of players gold and any change of it.
ie: if( curnt_gold_amount < db_Gold amount ){ runs unaquire gold script}
I thought about doing this on heart beat but that could get laggy

Note: the shadow function will only fire on aquire. not just any change in your gold. ie if you drop etc. 
Hence the need for a script on heart beat to check pc gold for loss
               
               

               


                     Modifié par Greyfort, 15 mars 2011 - 01:49 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #9 on: March 15, 2011, 02:00:23 am »


               

Greyfort wrote...

I dont know if it will fire with other stacked items, I think not because they often are valid Objects.
so far No fire with other items, it works only when I pick up gold piece and it fires because the object item is invalid and stack size function:

if(GetModuleItemAcquired() == OBJECT_INVALID && GetModuleItemAcquiredStackSize() > 0)
{
//::----------------------------------------------------------------------------
//::---------------------------[ aquire gold ]----------------------------------
//::----------------------------------------------------------------------------
}

works firing my aquire gold script.

I thought about a simalr approuch for unaquire gold but I need a var that keeps track of players gold and any change of it.
ie: if( curnt_gold_amount < db_Gold amount ){ runs unaquire gold script}
I thought about doing this on heart beat but that could get laggy

its reliable, there may be cases in which the acquired object is not valid, but there is only one case where the acquired object is invalid. Its not the same.

Unacquire do not fire however, so if you want to control the gold somehow, you must make a serious workaround.

Just an idea:
1) some pursue for gold, able to store gold with variable, using unique power for convo which will have the ability to put the gold into players inventory again (and when you use it you know how much).
2) when gold is acquired via OnAcquire, take this gold from creature and then store it into pursue.
3) all gold reewards through scripting should save the gold into pursue directly (it would work probably cos still firing OnAcquire, but would be better)

Or no convo but setting OnChat listenning immediately.:innocent:
               
               

               


                     Modifié par ShaDoOoW, 15 mars 2011 - 02:01 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #10 on: March 15, 2011, 02:16:40 am »


               There are other problems with tring to track all gold gained via OnAquire.  The conversation is easie to get around. Like shadoOow stated you just add it to you scripts to modify what you need in the script.  But you will also have to script something for gold aquired from shops.  When the PC sells something to a shop he it will not fire the OnAquire Event, simply because an item never exsisted to aquire.  all that happens is that the players gold gets updated. To compound the problem with shops, if the shop has the item sold as unlimited Get Item Lost will return an invalid item.  But if he Unaquires an item to a shop at least you know that the gold amount changed.  


I also do not know if gold traded between PC's will fire the event or not.  

I do not really see any way to track gold lost outside of a HB.  At that point you need to start asking if what you are tring to do is worth it.  

If it is not critical when and where they gained/lost it. I would think about just adding it to all the OnEnter/LeaveArea events.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #11 on: March 15, 2011, 03:52:57 am »


               yeah i like your idea Light foot.  What I did was make A item that when player uses.. it adjust and acuratly creating the effect I wanted.  It was for gold encumbrance problem solved.  I will post a link to the vault ware all others can use it.  The only down side but not to bad really is if you loose gold you have to rem to use the item so you wont be encumbered ie:[ if you have alot of gold and then none ]
Other wise it creates the effect of gold being heavy and wieghting your char down.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
NO GOLD NAME,TAG,RES
« Reply #12 on: April 14, 2011, 08:39:31 pm »


               I was hoping if anyone can think of anything else that might unaquire or aquire gold.  This would help me to finalize script.