Author Topic: script for a gate  (Read 5363 times)

Offline Daniel1975

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • http://
    • Email
script for a gate
« 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
« Last Edit: January 05, 2005, 05:30:47 PM by Daniel1975 »
G[/span][span style=\'color:orange\']w[/span][span style=\'color:yellow\']y[/span][span style=\'color:green\']d[/span][span style=\'color:blue\']i[/span][span style=\'color:purple\']on[/span] - Slann [span style=\'color:red\']Lord[/span] of the [span style=\'color:green\']Antediluvians

Offline Celestial1

  • Hero Member
  • *****
  • Posts: 625
    • AOL Instant Messenger - n1megakid92
    • Yahoo Instant Messenger - n1megakid92
    • View Profile
    • http://
    • Email
script for a gate
« Reply #1 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
Yes I know... I have no idea why these random animals are carrying 148 gold and a magic fire ring. It will be forever a mystery![/span]

[span style=\'color:green\']It's better to keep your mouth shut and appear stupid than to open it and remove all doubt.

-Samuel Langhorne Clemens, Mark Twain.

Offline Tea-cup

  • Hero Member
  • *****
  • Posts: 916
    • View Profile
script for a gate
« Reply #2 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