Aller au contenu

Photo

compiles, but not working properly....


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

#1
zero-feeling

zero-feeling
  • Members
  • 144 messages

so the following script compiles fine and gives the first update but doesn't give the next 6 updates like i need it to. can someone please tell me if i missed something?

 

#include "pqj_inc"  // journal include
#include "nw_i0_tool"
void main()
{
    object oPC = GetLastUsedBy();
    object oBox = GetItemPossessedBy(oPC, "memorybox");  // item created on PC when entering the world
    string sName = GetName(OBJECT_SELF);
    int nBug = 1;//change to 0 once testing is done
    int nCheck = GetLocalInt(oBox, sName);
 
    if(nBug == 1)
    {  //if debugging the script
     SpeakString("Plant Name: "+sName, TALKVOLUME_SHOUT);
     //speak the plant name
     if(!GetIsObjectValid(oBox))
     {  //if the box is NOT VALID
      SpeakString("The character does not have a valid memorybox.", TALKVOLUME_SHOUT);
     }
     if(nCheck == 1)
     {//if the pc has used this named thing before
      SpeakString(sName+" is marked as used.", TALKVOLUME_SHOUT);
     }
     else
     {  //if the pc has not used this named thing before
      SpeakString(sName+" is marked as NOT USED.", TALKVOLUME_SHOUT);
     }
    }
 
    if (!GetIsPC(oPC)) return;//if not a pc stop
    if(nCheck == 1)return;//if the pc has used this thing
 
 
    SetLocalInt(oBox,sName,1);  //set plant name as int ref on box
    ExportSingleCharacter(oPC);  //save pc thereby saving box info
    if(nBug == 1)
    {  //if debugging == 1
     SpeakString("PlantName: "+sName+" SetTo: "+IntToString(GetLocalInt(oBox,
     sName)), TALKVOLUME_SHOUT);
    }
    int nInt = RetrieveQuestState("q_plants",oPC);
    if (nInt >= 10 && nInt < 80)
        {
        AddPersistentJournalQuestEntry("q_plants",nInt+10, oPC,FALSE);
        FloatingTextStringOnCreature("** Your Journal Has Been Updated **", oPC);
        DelayCommand(2.0, FloatingTextStringOnCreature("** Charactor Saved **", oPC));
        GiveXPToCreature(oPC, 1000);
        }
}
 
thanks in advance.


#2
BelowTheBelt

BelowTheBelt
  • Members
  • 394 messages
What do you mean by 'updates'?  The journal entry?
 
I added one more set of debug code to check what the quest state is.  This may give you a sense of what's going wrong.   Also, you may want to consider switching the 'speakstring' as a debug approach to SendMessageToPC.  As you do more code, you'll run into instances where SpeakString won't work on the object running the script.  
 
#include "pqj_inc"  // journal include
#include "nw_i0_tool"
void main()
{
    object oPC = GetLastUsedBy();
    object oBox = GetItemPossessedBy(oPC, "memorybox");  // item created on PC when entering the world
    string sName = GetName(OBJECT_SELF);
    int nBug = 1;//change to 0 once testing is done
    int nCheck = GetLocalInt(oBox, sName);
 
    if (!GetIsPC(oPC)) return;//if not a pc stop
    
    if(nBug == 1)
    {  //if debugging the script
     SpeakString("Plant Name: "+sName, TALKVOLUME_SHOUT);
     //speak the plant name
     if(!GetIsObjectValid(oBox))
     {  //if the box is NOT VALID
      SpeakString("The character does not have a valid memorybox.", TALKVOLUME_SHOUT);
     }
     if(nCheck == 1)
     {//if the pc has used this named thing before
      SpeakString(sName+" is marked as used.", TALKVOLUME_SHOUT);
      return;
     }
     else
     {  //if the pc has not used this named thing before
      SpeakString(sName+" is marked as NOT USED.", TALKVOLUME_SHOUT);
     }
    }
    SetLocalInt(oBox,sName,1);  //set plant name as int ref on box
    ExportSingleCharacter(oPC);  //save pc thereby saving box info
    int nInt = RetrieveQuestState("q_plants",oPC);
    if(nBug == 1)
    {  //if debugging == 1
     SpeakString("PlantName: "+sName+" SetTo: "+IntToString(GetLocalInt(oBox,
     sName)), TALKVOLUME_SHOUT);
     SendMessageToPC(oPC, "PC Quest State:  "+IntToString(nInt));
    }
    if (nInt >= 10 && nInt < 80)
        {
        AddPersistentJournalQuestEntry("q_plants",nInt+10, oPC,FALSE);
        FloatingTextStringOnCreature("** Your Journal Has Been Updated **", oPC);
        DelayCommand(2.0, FloatingTextStringOnCreature("** Character Saved **", oPC));
        GiveXPToCreature(oPC, 1000);
        }
}


#3
zero-feeling

zero-feeling
  • Members
  • 144 messages

yes, this is a quest, so it's journal updates.

 

ok, implemented the extra debug and tested.. got some weird results... 

i'd like to say, this script worked fine the last time i ran my server about a year ago and nothing in the quest has changed... 

 

so did 4 tests, got different results, but yet still all the same...

 

test 1: (quest removed from pc)

7 plants touched/used

only 1 gave an update, the 3rd plant touched. (all should give updates)

quest state at 10 when touched and 20 after. (this part worked)

 

test 2: (quest removed from pc)

7 plants touched/used

only 1 gave an update, the 5th plant touched.

quest state at 10 when touched and 20 after.

 

test 3: (quest removed from pc)

7 plants touched/used

only 1 gave an update, the 6th plant touched.

quest state at 10 when touched and 20 after.

 

test 4: (quest removed from pc)

7 plants touched/used

only 1 gave an update, the 2nd plant touched.

quest state at 10 when touched and 20 after.

 

in my head i'm simply thinking... "wtf is going on?"

 

can anyone explain this? why only one plant, at random, is working?



#4
BelowTheBelt

BelowTheBelt
  • Members
  • 394 messages

A few questions that might help you figure it out:

 

  1. What item/object type is running this script?  What event are you using it on?
  2. There's nothing in this script that sets a quest state to anything unless the quest state is already >=10 and < 80.  How does the quest state being set originally?
  3. Are there any other scripts that are coming into play here?
  4. The only 'return' is when sName is the same.  Do you have plants that are named the same?
  5. Take a look at the item that is giving the updates.  Are they the same item in each test?  Are there local variables, resref, or Tag or scripts on them that make them different than the items that don't give the updates?


#5
zero-feeling

zero-feeling
  • Members
  • 144 messages

*pounds head on desk*

 

did compile all scripts in my mod and found nwnx_funcs wasn't compiling.

looked at why, missing nwnx_funcs_effs.nss (include)

downloaded the latest version.

installed it.

retested.

works fine.

it took me a few to realize the script might not be the issue and it might be the memory box wasn't being set properly.

 

i do thank you for your assistance BelowTheBelt.



#6
BelowTheBelt

BelowTheBelt
  • Members
  • 394 messages
LoL. We've all been there. Good luck.