Script: Pick up a key and unlock a door...

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Goldeneye090
Colour Sergeant
Posts: 79
Joined: Mon May 10, 2004 10:11 pm

Script: Pick up a key and unlock a door...

Post by Goldeneye090 »

Hey all. Just wondering if it's possible to make a script where you can only go through a certain door if you've picked up an object...like a key or somethin...and once u pick up the object no one else can have it unless u drop it...Thanks.

GoldenEye
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Sure, make the "setthread" of a trigger around the key set a value in the player

If the trigger has: "setthread gimmi_a_key_goddamnit"

Code: Select all

gimmi_a_key_goddamnit:
    param.other.i_am_the_key_master = 1
end
And it the door trigger has: "setthread lemme_in_you_stooopid_imitation_of_a_door"

Code: Select all

lemme_in_you_stooopid_imitation_of_a_door:
    if(param.other.i_am_the_key_master == 1) {
        // stuff to open door
    } else {
        // tell param.other that he/she needs a key
    }
end
Thats the base of it, just add some more scripting ;)
Admin .MAP Forums
Image
Head above heels.
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

trigger around the key, setthread give_key:

Code: Select all

give_key:
$key remove
level.key = 1
at the door trigger_multiple with setthread detect_key:

Code: Select all

detect_key:
if(level.key = 1)
{
$locked_door open
}
is how id do it at least.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Well lizardkid, by doing so you would enable everyone to access the door as soon as anyone picked up the key ( but yes: removing the key is smatt if you only want one person to have it ).

Also: as soon as you start demanding a unique key: you must also start to handle people dying to drop the key, and people leaving the server... so you would probably need to scan all the players on aregular basis to make sure the key is still in the game.

So the simplest is to leave the key for anyone to pick up and just mark the ones that triggered the key trigger like in the code I did... and only let them pass the door. ( but simple solutions are not always what you want ;) )
Admin .MAP Forums
Image
Head above heels.
Post Reply