Aller au contenu

Photo

Make a starting conditional script so it only runs once


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

#1
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Hello all:

I used the wizard in the conversation editor to create thris script. It makes a line show up if the PC has a specific item in his/her inventory. I need it to only run once, even if the item is still in the PC's inventory. I tried using the Script Generator but I did not find an option to write starting conditional scripts so they run only once.

I'm sure this is an easy fix but I can't figure it out.

Thanks for any help!

//::///////////////////////////////////////////////
//:: FileName sc_atnote
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: Script Wizard
//:: Created On: 2/11/2012 1:45:18 PM
//:://////////////////////////////////////////////
#include "nw_i0_tool"

int StartingConditional()
{

    // Make sure the PC speaker has these items in their inventory
    if(!HasItem(GetPCSpeaker(), "AncientTemple"))
        return FALSE;

    return TRUE;
}

#2
Kato -

Kato -
  • Members
  • 392 messages
int StartingConditional()
{
    object oPC = GetPCSpeaker();
    string sVar = GetPCPlayerName(oPC) + GetName(oPC);
    if(GetLocalInt(OBJECT_SELF, sVar)) return FALSE;
    if(GetItemPossessedBy(oPC, "AncientTemple") != OBJECT_INVALID)
    {
        SetLocalInt(OBJECT_SELF, sVar, TRUE);
        return TRUE;
    }
    return FALSE;
}

EDIT: L8 solution is even better if his assumption is correct


Kato

Modifié par Kato_Yang, 16 juin 2012 - 06:52 .


#3
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Assumptions I made in the rewrite.  
The item is unique. 
You only want the item used once.  Passing it to another PC, Will not allow it to be used again.


int StartingConditional()
{
        object oItem = GetItemPossessedBy(GetPCSpeaker(), "AncientTemple");
        if (oItem != OBJECT_INVALID)
        {
           int nUsed = GetLocalInt(oItem,"used");
           if (!nUsed)
           {
              SetLocalInt(oItem,"used",TRUE);
              return TRUE;
           }
        }
        return FALSE;
}

#4
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Thanks to both of you for your quick replies! It's a SP module so it will only be used once by default.

Thanks again!