Thread: Unlock Doors
View Single Post
Plugin Info:     Modification:          Category:          Approver:   EKS (166)
commonbullet
Veteran Member
Join Date: Oct 2005
Old 11-06-2005 , 21:46   Unlock Doors
Reply With Quote #1

Unlock Doors

This script unlocks every door that is opened by buttons, so they will automatically open. This is particularly useful when playing with bots – many bots like the cz official bots (csbots) can’t open triggered doors.

It should work for every mod, but I only tested it in cs and I don’t know if it’s ever needed in other mods.

Cvars- amx_unlockatstart [0-1]
Set the script to unlock doors when map is loaded.

Commands
- amx_unlockdoors
Unlock triggered doors
- amx_defaultlock
Doors back to default

Modules Required:
Engine

About the script

The idea is very simple: to remove “targetname” property from func_doors and func_doors_rotating entities so they’ll open automatically. But that can’t be done very easily because there’s no way to remove targetname from an existing entity, and that’s not the same as setting targetname = “”.

The obvious solution is to duplicate the entity, copy only the desired properties and remove the old one. In order duplicate it, it's required to collect all entity properties. But entities pair values are tricky to be read, they have got to be hooked at spawn with that function,
Code:
public pfn_keyvalue(entid)
Not all doors that have a targetname should be replaced; sometimes func_doors are used to trigger a muilti-manager or other entity at spawn for example. So the plugin looks for buttons that are triggering a specific door targetname and if it finds one, the door will be respawned.

This plugin is not likely to be called more than once by users, so processing is not a big issue in here. Some global variables are inevitably allocated because of the hooking process; I did my best as so to use the minimum space.

I have tested it in cs_highsociety and cs_007bunker. It's working fine.

Log:
last version downloads: 668

Credits:
Hook function provided by
XxAvalanchexX
Attached Files
File Type: sma Get Plugin or Get Source (unlockdoors.sma - 4337 views - 9.2 KB)

Last edited by commonbullet; 01-24-2007 at 17:48.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet