The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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
#1
[SOLVED] Using a Single Crowbar on Multiple Doors

All righty, so basically I'm trying to break against the traditional crowbar-breaks-after-one-use shenanigans and I have at least four doors that will require using the crowbar, three being the regular mansion door and the last being boards covering a door.

I've been able to successfully script for a single door, but now that I have to add to it, I have no idea where to really start. While I know that I can use the Variables to help condense the scripts, I'm not entirely sure how to go about it or if with also needing to script for boards, if that might makes things a little different.

____________________________________________________________
Finished Script:

-Be sure to check the names thoroughly
-I'm leaving the 4 in the script, but you do not necessarily have to leave it at 4

Thank you to the guys who contributed to this thread to get this script working![/code]

void OnStart()
{  
    for(int i = 1; i <= 4; i++) {
    AddUseItemCallback("crowbarondoors", "crowbar", "Door_"+i, "UseCrowbarOnDoor", false);
    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_"+asChild, false);
    PlaySoundAtEntity("", "break_wood_metal", "AreaEffect_"+asChild, 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);
}

(This post was last modified: 09-22-2014, 09:10 PM by AGP.)
09-21-2014, 08:13 PM
Find


Messages In This Thread
[SOLVED] Using a Single Crowbar on Multiple Doors - by AGP - 09-21-2014, 08:13 PM



Users browsing this thread: 1 Guest(s)