Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help [SOLVED] Using a Single Crowbar on Multiple Doors
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#14
RE: Using a Single Crowbar on Multiple Doors

Spoiler below!
void OnStart()
{  
    for(int i=1; i<=4; ++i) AddUseItemCallback("crowbarondoors", "Crowbar_1", "Door_"+i, "UseCrowbarOnDoor", false);
    for(int i=1; i<=4; ++i) AddEntityCollideCallback("Joint_Door_"+i, "AreaBreak_"+i, "BreakDoor", true, 1);
}
    
void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
    RemoveItem("asItem");
    PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);
    AddTimer(asEntity, 0.2, "TimerPlaceCrowbar");

    SetLocalVarString("CrowbarDoor", asEntity);
}
    
void TimerPlaceCrowbar(string &in asTimer)
{
    SetEntityActive("Joint_"+asTimer, true);
    PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);
}
    
void BreakDoor(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive(asParent, false);
  
    SetSwingDoorLocked(GetLocalVarString("CrowbarDoor"), false, false);
    SetSwingDoorClosed(GetLocalVarString("CrowbarDoor"), false, false);
    SetSwingDoorDisableAutoClose(GetLocalVarString("CrowbarDoor"), true);
    
    AddPropImpulse(GetLocalVarString("CrowbarDoor"), 0, 0, 3, "world");

    CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false);
    PlaySoundAtEntity("", "break_wood_metal", "AreaEffect", 0, false);
    
    GiveSanityBoostSmall();
    
    PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
    
    AddTimer("", 0.1, "TimerPushDoor");

    GiveItem("crowbar", "Puzzle", "crowbar", "crowbar.tga", 1);
}

void TimerPushDoor(string &in asTimer)
{
        AddPropImpulse(GetLocalVarString("CrowbarDoor"), -4, 2, 1, "world");
        AddTimer("", 1.1, "TimerDoorCanClose");
}
    
void TimerDoorCanClose(string &in asTimer)
{
        SetSwingDoorDisableAutoClose(GetLocalVarString("CrowbarDoor"), false);
}


09-22-2014, 08:13 AM
Find


Messages In This Thread
RE: Using a Single Crowbar on Multiple Doors - by AGP - 09-22-2014, 08:13 AM



Users browsing this thread: 2 Guest(s)