Author Topic: best way to do this...  (Read 448 times)

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
best way to do this...
« on: November 10, 2010, 06:29:51 am »


               so i've been doing some thinking about how to make a script set for creating an item in a container. I need certain requirements to be met in order for the items to appear in the chest, need the same requirements for when they take the item, this will give a journal update, and need something for the OnClose to match the other two scripts. so far, this is what i have:
OnOpen:
#include "pqj_inc"
void main()
{
   object oPC = GetLastOpenedBy();
      if(!GetIsPC(oPC))
         {
         return;
         }
   object oNPC = OBJECT_SELF;
      if(GetLocalInt(oPC,GetTag(oNPC)))
         {
         return;
         }
   int nInt = RetrieveQuestState("q_ezra",GetLastOpenedBy());
       if (nInt != 10)
       {
       return;
       }
   CreateItemOnObject("ezra_book", OBJECT_SELF);
}

OnDisturbed:
#include "pqj_inc"
void main()
{
    int iType =  GetInventoryDisturbType();
    object oPC = GetLastDisturbed();
    object oItem = GetInventoryDisturbItem();
    if (!GetIsPC(oPC)) return;
    if(iType == INVENTORY_DISTURB_TYPE_REMOVED && GetTag(oItem) == "ezra_book")
        {
        FloatingTextStringOnCreature("** Your Journal Has Been Updated **", oPC);
        AddPersistentJournalQuestEntry("q_ezra",20,oPC,FALSE);
        }
}

and OnClosed:
**script goes here**

i have also been told this way:
place the item in the chest in the toolset, then in the OnDisturbed slot, ad this:
#include "pqj_inc"  
  
void main()  
{  
    int iType =  GetInventoryDisturbType();  
    object oPC = GetLastDisturbed();  
    object oItem = GetInventoryDisturbItem();      
 
 if(RetrieveQuestState("q_ezra",oPC) == 10)
 {
 CopyItem(oItem,OBJECT_SELF);
 DestroyObject(oItem);
 return;
 }
 
    if(iType == INVENTORY_DISTURB_TYPE_REMOVED && GetTag(oItem) == "ezra_book")  
        {  
        FloatingTextStringOnCreature("** Your Journal Has Been Updated **", oPC);  
        AddPersistentJournalQuestEntry("q_ezra",10,oPC,FALSE);  
       DestroyObject(OBJECT_SELF,5.0);
        }  
}

... so if theres a better way, one that won't allow exploits, i'd appreciate the help.

thanks.
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
best way to do this...
« Reply #1 on: November 10, 2010, 04:20:34 pm »


               This may not have the kind of appeal that you would like, but a really easy way would be to have the item automatically put into the PC inventory when the PC touches the chest.  Add a little SpeakString or something to notify them that it happens.  That way you would only do the test once and nobody has any way of intercepting and grabbing the item.   What you lose is that the player doesn't actually look into the chest, take the item and then close the chest.
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
best way to do this...
« Reply #2 on: November 10, 2010, 05:56:27 pm »


               The way I do it on my server is I create an invisible object blueprint with the portrait of the container (or you can use SetPortrait). When the PC uses the visible container I spawn the invisible object then have the PC open the invisible object's inventory. This way every PC gets their own personal container.



It's probably the best solution for any multiplayer action. Works good for forges too, the PC opens their own personal forge (invisible object) and places the item to be enhanced inside and no other PCs can come up and steal that item.



-420
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
best way to do this...
« Reply #3 on: November 10, 2010, 06:15:42 pm »


               That's really clever!
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
best way to do this...
« Reply #4 on: November 10, 2010, 07:42:44 pm »


               Very clever indeed.
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
best way to do this...
« Reply #5 on: November 11, 2010, 01:19:33 am »


               i like that idea (420).. how would one go about doing that.... a beginning scripter that is?

i can figure out the placeables, how to spawn a new placeable, and other such easy stuff, but the part about opening another objects inventory is whats throwing me off.

thanks
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
best way to do this...
« Reply #6 on: November 11, 2010, 06:12:46 pm »


               I can post a more detailed description when I have more time if you'd like but the function I think you're looking for is this one:



AssignCommand(oPC, ActionInteractObject(oObject));



-420
               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
best way to do this...
« Reply #7 on: November 12, 2010, 12:25:42 am »


               cool, i'll play with it and see what happens, but yes, i would appreciate something more if you could.



thanks
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
best way to do this...
« Reply #8 on: November 12, 2010, 06:31:47 am »


               

420 wrote...

I can post a more detailed description when I have more time if you'd like but the function I think you're looking for is this one:

AssignCommand(oPC, ActionInteractObject(oObject));

-420

But that invisible object must be useable in order to have inventory, that is item inside. How you make it invisible then? I don't think you can spawn it under player, as player must be able to interact with it. Do you apply some invisibility VFX?
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
best way to do this...
« Reply #9 on: November 12, 2010, 05:54:06 pm »


               

ShaDoOoW wrote...

420 wrote...

I can post a more detailed description when I have more time if you'd like but the function I think you're looking for is this one:

AssignCommand(oPC, ActionInteractObject(oObject));

-420

But that invisible object must be useable in order to have inventory, that is item inside. How you make it invisible then? I don't think you can spawn it under player, as player must be able to interact with it. Do you apply some invisibility VFX?

I use the Invisible Object placeable located under Miscellaneous. It's small enough that you can just spawn it in the same location as the visible container without the PC being able to see/select it.  I just change the name/description/portrait and check the Useable and Has Inventory boxes.

-420
               
               

               


                     Modifié par 420, 12 novembre 2010 - 05:54 .