Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Having problems with key unlocking a door scripting.
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#3
RE: Having problems with key unlocking a door scripting.

The best way to make that function is like this:

PHP Code: (Select All)
void OnStart()
{
AddUseItemCallback("""KeyOne""manny""UsedKeyOnDoor"true);

}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem);


By writing the function like this will make that function be reusable without unlocking wrong door and removing a key you don't have.

For Example:

PHP Code: (Select All)
void OnStart()
{
AddUseItemCallback("""KeyOne""manny""UsedKeyOnDoor"true);
AddUseItemCallback("""KeyTwo""Manny2""UsedKeyOnDoor"true);
}

void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
PlaySoundAtEntity("""unlock_door"asEntity0false);
RemoveItem(asItem);


The above code is an example on how you can reuse the code. You can have 2 UseItemCallbacks and both works without any problems Smile

(This post was last modified: 06-10-2012, 09:17 AM by SilentStriker.)
06-10-2012, 09:16 AM
Find


Messages In This Thread
RE: Having problems with key unlocking a door scripting. - by SilentStriker - 06-10-2012, 09:16 AM



Users browsing this thread: 1 Guest(s)