How to add an entry to the quest journal when an item is received?(Solved)

I need a script that do
Adds an entry to the quest journal when an item is received.
I tried to use scripts ,but none work .
(i search script and try remake)
where mistake ?or someone can write here script
Thank you very much in advance
I try use scrip nwn1 but it not work

void main()
{
// Get the object which was acquired
object oItemAcquired = GetModuleItemAcquired();

if (oItemAcquired != OBJECT_INVALID)
{
    // Get the tag of the acquired item
    // If it is "my_item_tag" we got the right item
    if (GetTag(oItemAcquired ) == "nwn2_it_ifist_gaunt")
    {
        // Get the object (player) who now possess the item
        object oPC = GetItemPossessor(oItemAcquired );

        // Add an appropriate journal entry to his journal
        AddJournalQuestEntry ("B_1", 21, oPC);
    }
}

}
Thank you very much in advance

use nwn2-style tag based script

// 'i_nwn2_it_ifist_gaunt_aq'
/*
    The filename of the script needs to be
    i_tagofitem_aq
    for the OnItemAcquired event to fire.
*/

#include "ginc_item_script"

//
void main()
{
    if (IsItemAcquiredByPartyMember())
    {
        object oItem = GetModuleItemAcquired();
        if (!IsItemMarkedAsDone(oItem, SCRIPT_MODULE_ON_ACQUIRE_ITEM))
        {
            MarkItemAsDone(oItem, SCRIPT_MODULE_ON_ACQUIRE_ITEM);

            object oPC = GetModuleItemAcquiredBy();
            AddJournalQuestEntry("B_1", 21, oPC);
        }
    }
}
3 Likes

Just to add to what kevL_s is saying: Remember that the script name needs to be i_tagofitem_aq (just like he says in the description of the script). That is vital for it to work. You can find quite a few good templates for scripts for your module under Templates in the Script Assist in the toolset when your editing your script. There you have the basics for a few useful and common scripts.

Also check out Lilac Soul’s Script Generator: LS-TK Script Generator (Lilac Soul's Script Generator, updated for NWN 1.69) | The Neverwinter Vault
Even if it was made for NWN1 most of the scripts generated with this will work in NWN2.

3 Likes

kevL_s,thank you very much for your help!
Everything works great!
also andgalf,thank you very much for your help!
Everything works great! :laughing:
Thanks again to everyone!

2 Likes