Can you give keys to players?

  • If you're asking a question make sure to set the thread type to be a question!

bob+M|M+

L6: Sharp Member
Mar 31, 2008
346
394
In TFC mapping there was an entity that allowed you to give players "keys" so that they could activate triggers only if they carried the key. I don't think the entity exists anymore in TF2, however, so I wonder if there is an alternative method, or if I overlooked something.
 

MrAlBobo

L13: Stunning Member
Feb 20, 2008
1,059
219
i recall someone saying that you could give players "names" and then use those names to activate things...but no way in hell could I tell you how to do it

Id suggest you ask pseudo, he knows an unusual amount about entities (haven't seen him on lately though)
 

Bonafide

L6: Sharp Member
Mar 18, 2008
313
25
in rock2 you need to pick up a key and carry it to activate the gas chamber. Ask Juice how he did it.
 

Pseudo

L6: Sharp Member
Jan 26, 2008
319
150
To "name" a player that activated a trigger you would target !activator and send the output AddOutput with the parameter targetname whatevername. Then you could use filter_activator_name to make it so only a player with a certain "name" could activate something.

You could give this a graphical representation by using SetParent !activator with something such as a sprite, and SetParentAttachment with a parameter of head to position an image of a key over the player's head.

It would also be possible to use item_teamflag as keys. The way that I would do this would be to put a point_proximity_sensor by the door. Its target would be the name of an item_teamflag. A logic_compare could then Enable or Disable a door-opening trigger_multiple based on the distance from the door to the flag. This is similar to the method described here.
 

bob+M|M+

L6: Sharp Member
Mar 31, 2008
346
394
I like the first idea it works great for my situation.

I may or may not do the sprite thing. I'll have to play around it, but right now it looks pretty fugly, not to mention very distracting from the player's point of view.

spritewa9.png


the briefcase and logic_compare example was pretty cool too. probably won't use it this time, but I can think of a ton of useful scenarios where it would come in handy, for instance entrance doors to a 1on1 deathmatch arena
 

Pseudo

L6: Sharp Member
Jan 26, 2008
319
150
What I had in mind with the sprite was to make a custom material that was a picture of a key. You could also control the height of the sprite above the player's head so that the player's view wouldn't be obstructed. But if it's not important that other players know who has a key then a visual isn't needed.
 

bob+M|M+

L6: Sharp Member
Mar 31, 2008
346
394
hmm, well I'm keeping my options open. The player would be given this sprite/key upon beating my jump map, so they can enter into a locked room near the beginning of the map. but a visual would be more of an indication of "hey look I beat the map" instead of "I got the key to open door"

I was worried about performance loss from the sprite, but you mentioned that you could place it above the head so now that's a non-issue. and having a solid object instead of a world glow sprite seems like it would be better. I've never made any custom materials before, but maybe I can find something amongst the stock sprites.

btw how would you go about positioning the sprite above the head?