Neverwinter Nights > Script Request

script for a gate

(1/1)

Daniel1975:
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

Celestial1:
I have no clue how to script, or if I'm right on this, but I think it requires to be in OnUsed.

~Celestial

Tea-cup:

--- 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]
--- End quote ---
GetLastUsedBy(); won't work just by setting it in onuserdef. Put it in unused.

Post what happens then.

-Mel

Navigation

[0] Message Index

Go to full version