Raised This Month: $ Target: $400
 0% 

Solved Safe room L4D2


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-24-2020 , 19:37   Re: Safe room L4D2
Reply With Quote #5

Now I have test much.

*edit
*edit
*edit
*edit
Updated code.

Checkpoint Exit Door will be forced to open after 30 seconds at round start.
- To get door open automatically, there should be bots or players in team survivor.

PHP Code:
#include <sdktools>

Handle TimerCheckpointDoor;
bool DoOnce;

public 
void OnPluginStart()
{
    
HookEventEx("round_freeze_end"round_freeze_end);
    
HookEventEx("player_first_spawn"player_first_spawn);
}


public 
void round_freeze_end(Event event, const char[] namebool dontBroadcast)
{
    
// when map start

    
DoOnce false;

    if(
TimerCheckpointDoor == null) return;

    
delete TimerCheckpointDoor;
}


public 
void player_first_spawn(Event event, const char[] namebool dontBroadcast)
{
    
// Timer already executed
    
if(DoOnce || TimerCheckpointDoor != null) return;


    
int client GetClientOfUserId(event.GetInt("userid"));
    
    
// Don't check unnecessary events. Only players in team survivor
    
if(client == || !IsClientInGame(client) || GetClientTeam(client) != 2) return;

    
char doorname[30];
    
int door = -1;


    
int entity = -1;
    
    while( (
entity FindEntityByClassname(entity"prop_door_rotating_checkpoint")) != -)
    {
        
//PrintToServer("m_hasUnlockSequence %i,   %i", GetEntProp(entity, Prop_Data, "m_hasUnlockSequence"), entity);
        
GetEntPropString(entityProp_Data"m_iName"doornamesizeof(doorname));
        
        if(
StrEqual(doorname"checkpoint_exit"false))
        {
            
// yes
            
door entity;
            break;
        }
        else if(
StrEqual(doorname"checkpoint_entrance"false))
        {
            
// skip
            
continue;
        }
        else if(
GetEntProp(entityProp_Data"m_hasUnlockSequence") == 1)
        {
            
// empty targetname ex. Look door m_hasUnlockSequence
            
door entity;
            break;
        }
    }


    if(
door == -1) return;


    
SetVariantString("OnOpen !self:Lock::0.1:1");
    
AcceptEntityInput(door"AddOutput");
    
    
SetVariantString("OnUser1 !self:playeropen::0.1:1");
    
AcceptEntityInput(door"AddOutput");

    
SetVariantString("OnUser1 !self:playeropen::1.0:1");
    
AcceptEntityInput(door"AddOutput");
    
    
PrintToChatAll("\x05[SM] \x04Checkpoint Exit Door \x05will be forced open in 30 seconds");

    
DoOnce true;
    
TimerCheckpointDoor CreateTimer(30.0OpenDoorEntIndexToEntRef(door));
}

public 
Action OpenDoor(Handle timerint ref)
{
    
TimerCheckpointDoor null;

    
int door EntRefToEntIndex(ref);

    if(
door != -1)
    {
        for(
int i 1<= MaxClientsi++)
        {
            if(!
IsClientInGame(i) || GetClientTeam(i) != 2) continue;

            
AcceptEntityInput(door"FireUser1"i);
            
PrintToChatAll("\x05[SM] \x04Checkpoint Exit Door \x05will be forced open!");
            break;
        }
    }

Attached Files
File Type: sp Get Plugin or Get Source (L4D2openCheckpointDoor.sp - 194 views - 2.4 KB)
__________________
Do not Private Message @me

Last edited by Bacardi; 10-25-2020 at 20:58. Reason: updated code, again
Bacardi is offline
 


Thread Tools
Display Modes

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 05:38.


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