Server Totals
Le'Or - (1)
Elysia - (1)
Deglos - (0)
Ferrell - (0)
M'Chek - (0)
Mikona - (0)
Wilderness - (0)
Visimontium - (0)
Underdark - (0)
Total players: 2

Links Menu

Spawning the same object in a chest

Moderators: Nighthawk4, Dungeon Masters

Spawning the same object in a chest

PostAuthor: Orleron » Thu Jun 27, 2002 1:38 pm

Got this off the nwn boards, looks useful:

1) In your area place a chest. Let's give the chest a unique tag like NewGearChest

2) Mark the chest as a plot item so it can not be destroyed.

3) Now head over to the script tab and delete the default scrips for OnOpen and OnDeath

4) In the OnOpen event click edit and paste the code below (Assuming you have created a weapon with the tag of "PlayerSword")

This script checks the PC for an item.
If the PC does NOT have the item it is
created on the chest object and the PC
can then take it.
// Created Jun 22, 2002 by: Raligard

#include "NW_O2_CONINCLUDE"

void main()
object oPC = GetLastOpener();
object oPlayerSword;
oNewbieDagger = GetItemPossessedBy(oPC, "PlayerSword");
CreateItemOnObject("PlayerSword", OBJECT_SELF, 1);

5) If the player closes the chest and doesn't take the item it will remain. Then the next player who opens the chest will make it create a new one, there will be 2 items, then 3... then 4... you get the idea, so let's also prevent this!

6) In the OnClose event click the edit button and paste the text below (Again, assuming the item with the tag "PlayerSword" exists)

#include "NW_O2_CONINCLUDE"

void main()
object oPlayerSword = GetItemPossessedBy(OBJECT_SELF, "PlayerSword");
"Truth has no form."
--Idries Shah

World of Avlis Page

Avlis Project FAQ

World Advisor, Co-founder
World Advisor, Co-founder
Posts: 15040
Joined: Fri Sep 14, 2001 9:48 pm
Timezone: GMT-5

Return to NWN Scripting

Who is online

Registered users: ArgentDuergar, Bing [Bot], Google [Bot], Lucidic, Sephira