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
Padlock Question
Nevicar Offline
Junior Member

Posts: 37
Threads: 4
Joined: Mar 2012
Reputation: 0
#1
Padlock Question

Hello everyone!

I have a question about padlocks; how would I go about setting it up on a prison door and then unlocking it with a key and having it disappear with the key from the inventory? I can't seem to find much about that in the wiki, sadly, and figured I'd ask here to pick your guys brains Smile

Unless I'm just an idiot and coded my door open wrong, which I'll post here:


AddUseItemCallback("", "key1", "padlock_1", "func_key", true);

void func_key(string &in item, string &in door){  SetSwingDoorLocked("padlock_1", false, true);  PlaySoundAtEntity("Player", "unlock_door", door, 0, false); RemoveItem(item);}

Thanks for the help!
(This post was last modified: 03-06-2012, 02:42 AM by Nevicar.)
03-05-2012, 08:07 PM
Find
jessehmusic Offline
Senior Member

Posts: 423
Threads: 102
Joined: Dec 2011
Reputation: 8
#2
RE: Padlock Question

(03-05-2012, 08:07 PM)Nevicar Wrote: Hello everyone!

I have a question about padlocks; how would I go about setting it up on a prison door and then unlocking it with a key and having it disappear with the key from the inventory? I can't seem to find much about that in the wiki, sadly, and figured I'd ask here to pick your guys brains Smile

Unless I'm just an idiot and coded my door open wrong, which I'll post here:


AddUseItemCallback("", "key1", "padlock_1", "func_key", true);

void func_key(string &in item, string &in door){  SetSwingDoorLocked("padlock_1", false, true);  PlaySoundAtEntity("Player", "unlock_door", door, 0, false); RemoveItem(item);}

Thanks for the help!
AddUseItemCallback("", "key1", "padlock_1", "KeyOnDoor", true);

void KeyOnDoor (string &in item, string &in door)
{

SetSwingDoorLocked("padlock_1 ", false, true);
PlaySoundAtEntity("", "unlock_door", "padlock_1 ", 0, false);
RemoveItem("key1");
}



Test that Wink

http://www.moddb.com/mods/jessehmusic - Hospital of horror , WIP
(This post was last modified: 03-05-2012, 10:13 PM by jessehmusic.)
03-05-2012, 10:12 PM
Website Find
Nevicar Offline
Junior Member

Posts: 37
Threads: 4
Joined: Mar 2012
Reputation: 0
#3
RE: Padlock Question

Tested, nothing happened still, the padlock on the door doesn't disappear.

Edit: I've moved the lock and now it can at least be manipulated. So I need to change what I've asked. I want the padlock to despawn when I add the key to it.

IE: I have a prison style door with a lock to do it manually instead of with a key. I want to take the key, apply it to the lock, and have the lock disappear.
(This post was last modified: 03-05-2012, 10:51 PM by Nevicar.)
03-05-2012, 10:44 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#4
RE: Padlock Question

Still not quite about some things you've posted, but a padlock is an entity of sub-type Object > Grab. You can't set it locked or unlocked. Use SetEntityActive to make it disappear, in tandem with SetSwingDoorLocked to unlock your door.

03-06-2012, 01:22 AM
Find
Nevicar Offline
Junior Member

Posts: 37
Threads: 4
Joined: Mar 2012
Reputation: 0
#5
RE: Padlock Question

Thanks, that was actually exactly what I needed to know. I figured that the thing couldn't be unlocked, but I'm incredibly new at this so I didn't know about the SetEntityActive command, but now how I know how the entire code structure works, I'll surely be able to fix more problems.
03-06-2012, 02:33 AM
Find




Users browsing this thread: 1 Guest(s)