LucidMagic.net

Neverwinter Nights => NwN Building => Script Request => Topic started by: Daniel1975 on January 05, 2005, 05:24:33 PM

Title: script for a gate
Post by: Daniel1975 on January 05, 2005, 05:24:33 PM
I made a big gate and I don't want to use a key to open it as we have enough items already.
I like to have a cd-key check on the one who tries to open the door.
If the cd-key matches the door will unlock and open.
I made one like this:

void main()
{
 object oOpener = GetLastUsedBy();
 object oDoor = GetObjectByTag("TagOfTheDoor");

 if(GetPCPublicCDKey(oOpener) == "xxx"||
    GetPCPublicCDKey(oOpener) == "xxx")
    {
     SetLocked(oDoor, FALSE);
     ActionOpenDoor(oDoor);
    }
   else
    {
     SetLocked(oDoor, TRUE);
    }
}


the gate is locked in the beginning when the module loads.
But this script won't work as the closed door won't open.
What did i do wrong?
I placed this script in "OnUserDefined" and the gate is an area-placeable
Title: script for a gate
Post by: Celestial1 on January 05, 2005, 05:43:49 PM
I have no clue how to script, or if I'm right on this, but I think it requires to be in OnUsed.

~Celestial
Title: script for a gate
Post by: Tea-cup on January 05, 2005, 05:44:06 PM
Quote
I made a big gate and I don't want to use a key to open it as we have enough items already.
I like to have a cd-key check on the one who tries to open the door.
If the cd-key matches the door will unlock and open.
I made one like this:

void main()
{
 object oOpener = GetLastUsedBy();
 object oDoor = GetObjectByTag("TagOfTheDoor");

 if(GetPCPublicCDKey(oOpener) == "xxx"||
    GetPCPublicCDKey(oOpener) == "xxx")
    {
     SetLocked(oDoor, FALSE);
     ActionOpenDoor(oDoor);
    }
   else
    {
     SetLocked(oDoor, TRUE);
    }
}


the gate is locked in the beginning when the module loads.
But this script won't work as the closed door won't open.
What did i do wrong?
I placed this script in "OnUserDefined" and the gate is an area-placeable
[snapback]14945[/snapback]
GetLastUsedBy(); won't work just by setting it in onuserdef. Put it in unused.

Post what happens then.

-Mel