Raised This Month: $51 Target: $400
 12% 

[L4D2] Saferoom Door Lock


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RU_6uK
SourceMod Donor
Join Date: May 2010
Old 11-12-2010 , 05:49   [L4D2] Saferoom Door Lock
Reply With Quote #1

Oh wrong forum thread. I'm sorry. Must be Scripting.

Need some help.
I want to lock the saferoom doors in the round start for some time. To prevent players from leaving the saferoom ahead of time.
I use this code. But the doors are locked not always. Approximately 50 \ 50.
Is there a better way to lock the door?

Code:
public OnPluginStart()
{
	HookEvent("player_use", OnPlayerUse);
}

public Action:OnPlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if(IsClientInGame(client) && GetClientTeam(client) == 2)
	{
		new entity = GetEventInt(event, "targetid");
		
		AcceptEntityInput(entity, "Close");
		AcceptEntityInput(entity, "Lock");
		AcceptEntityInput(entity, "forceclosed");
	}
	
	return Plugin_Continue;
}
For unlock saferoom door i use this code and timer:

Code:
OpenDoor()
{
	decl String:sClassname[] = "prop_door_rotating_checkpoint";
	
	new index = -1;
	while((index = FindEntityByClassname(index, sClassname)) != -1)
	{
		if(GetEntProp(index, Prop_Data, "m_bLocked") > 0)
		{
			AcceptEntityInput(index, "Unlock");
		}
	}
}
Unlock always works. No problem with it.

Last edited by RU_6uK; 11-12-2010 at 05:57.
RU_6uK is offline
Jon
Veteran Member
Join Date: Dec 2007
Old 11-13-2010 , 07:17   Re: [L4D2] Saferoom Door Lock
Reply With Quote #2

PHP Code:
new DoorEntity GetSafeRoomDoorEntity();

GetSafeRoomDoorEntity()
{
    new 
ent = -1;
    while ((
ent FindEntityByClassname(ent"prop_door_rotating_checkpoint")) != -1)
    {
        if (
GetEntProp(entProp_Data"m_bLocked") == 1)
        {
            return 
ent;
        }
    }
    
    return -
1;
}

ToggleDoorLock(bool:lock)
{
    if (
lock)
    {
        
SetVariantString("spawnflags 40960");
    }
    else
    {
        
SetVariantString("spawnflags 8192");
    }
    
    
AcceptEntityInput(DoorEntity"AddOutput");

Lock door:
PHP Code:
ToggleDoorLock(true); 
Unlock door:
PHP Code:
ToggleDoorLock(false); 
Jon is offline
RU_6uK
SourceMod Donor
Join Date: May 2010
Old 11-13-2010 , 17:43   Re: [L4D2] Saferoom Door Lock
Reply With Quote #3

Thank you. I will check.
RU_6uK is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode