Frictional Games Forum (read-only)

Full Version: Need help with Crowbar on door
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello i get error at 44,2 at this script im going to make a crowbar that opens a door here is script "
PHP Code:
void OnStart()
{
SetEntityConnectionStateChangeCallback("lever""func_shelf");
AddEntityCollideCallback("Player""monsterspawn_1""MonsterFunction"true1); 
AddEntityCollideCallback("servant_brute_1""servant_grunt_1_remove""RemoveMonster"true1);
AddUseItemCallback("""crowbar_1""mansion_1""CrowbarOnDoor"true);
}

 
void func_shelf(string &in asEntityint alState)
{
     if (
alState == 1)
     {
     
SetMoveObjectState("shelf",1.0f);
     
PlaySoundAtEntity("""quest_completed.snt""shelf_move_1"0false);
          return;
     }
}
void MonsterFunction(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("servant_brue_1"true); 
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_1"2"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_2"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_3"0"");
}
void RemoveMonster(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("servant_brute_1"false);
}    
void CrowbarOnDoor(string &in itemstring &in door)
{
    
SetSwingDoorLocked(mansion_1", false, true);
    PlaySoundAtEntity("", "
unlock_door", "mansion_1", 0, false);
    RemoveItem(crowbar_1);
}    
    
    void OnEnter() 
{

}

void OnLeave() 
{

I have a tip for you. If you are using Notepad ++. Go over to language and change it to C++. You will see all the errors you are making ALOT easier.


Quote:void OnStart()
{
SetEntityConnectionStateChangeCallback("lever", "func_shelf");
AddEntityCollideCallback("Player", "monsterspawn_1", "MonsterFunction", true, 1);
AddEntityCollideCallback("servant_brute_1", "servant_grunt_1_remove", "RemoveMonster", true, 1);
AddUseItemCallback("", "crowbar_1", "mansion_1", "CrowbarOnDoor", true);
}


void func_shelf(string &in asEntity, int alState)
{
if (alState == 1)
{
SetMoveObjectState("shelf",1.0f);
PlaySoundAtEntity("", "quest_completed.snt", "shelf_move_1", 0, false);
return;
}
}
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brue_1", true);
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_3", 0, "");
}
void RemoveMonster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_brute_1", false);
}
void CrowbarOnDoor(string &in item, string &in door)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("crowbar_1");
}

void OnEnter()
{

}

void OnLeave()
{
}
I haven't checked whether or not you want to have the animation of the crowbar. Or if it just disappears and the door opens. Either way; I fixed up some of the errors. You are making some mistakes by not closing your strings with another ". Or not even doing them at all sometimes. Do what I said with the notepad and try to figure out the problem from there. It is alot easier than using the regular notepad. Smile
Thank you im going to test the script now Smile
it work but like a key want a crowbar to be pusched like in the dark descent Sad how do i do that

I'm too tired to tell you what everything means but here is the script. Put "crowbar_joint" in the door and set it unactive. Put a scriptarea next to the crowbar; this is for when the crowbar hits the scriptarea, it will trigger the "crowbarfunc". Put the scriptarea name where i made the text bold.

Quote:void OnStart()
{
AddUseItemCallback("crowbaractivate1", "crowbar_1", "cellar_wood01_4", "crowbar" , true);
AddEntityCollideCallback("crowbar_joint_1", "nameofscript", "crowbarfunc", true, 1);
}


void crowbar(string &in asItem, string &in asEntity)
{
SetEntityActive("crowbar_joint_1", true);
}


void crowbarfunc(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("cellar_wood01_4", 0.0f);
SetEntityActive("crowbar_joint_1", false);
SetEntityActive("crowbar_dyn_1", true);
}
So
PHP Code:
void OnStart()
 {
 
AddUseItemCallback("this is area ""the item""The door""No ide" true);
 
AddEntityCollideCallback("name of what""script name""the func"true1);
 }


 
void crowbar(string &in asItemstring &in asEntity)
 {
 
SetEntityActive("crowbar_joint_1"true);
 }


 
void crowbarfunc(string &in asParentstring &in asChildint alState)
 {
 
SetPropHealth("cellar_wood01_4"0.0f);
 
SetEntityActive("crowbar_joint_1"false);
 
SetEntityActive("crowbar_dyn_1"true);
 } 
or do i have wrong please help am new :S
Still got same prob
this is my hps and crowbar open the door like a key it dosnt work at all cant get it to work Sad i have made that with Crowbar_joint_1 dosnt work
PHP Code:
oid OnStart()
{
//START MOVE SHELF EVENT1
    
SetEntityConnectionStateChangeCallback("lever""func_shelf");
//END MOVE SHELF EVENT1

//START SERVANT BRUTE EVENT1
    
AddEntityCollideCallback("Player""monsterspawn_1""MonsterFunction"true1); 
    
AddEntityCollideCallback("servant_brute_1""servant_grunt_1_remove""RemoveMonster"true1);
//END SERVANT BRUTE EVENT1

//START CROWBAR EVENT1
    
AddUseItemCallback("""crowbar_1""mansion_1""CrowbarOnDoor"true);
    
AddEntityCollideCallback("crowbar_joint_1""door_script_1""crowbarfunc"true1);
//END CROWBAR EVENT1
}
void crowbar(string &in asItemstring &in asEntity)
 {
 
SetEntityActive("crowbar_joint_1"true);
 }


 
void crowbarfunc(string &in asParentstring &in asChildint alState)
 {
 
SetPropHealth("mansion_1"0.0f);
 
SetEntityActive("crowbar_joint_1"false);
 
SetEntityActive("crowbar_1"true);
 }
//START MOVE SHELF EVENT1
void func_shelf(string &in asEntityint alState)
{
if (
alState == 1)
{
    
SetMoveObjectState("shelf",1.0f);
    
PlaySoundAtEntity("""quest_completed.snt""shelf_move_1"0false);
    return;
}
}
//END MOVE SHELF EVENT1


//START SERVANT BRUTE EVENT1 
void MonsterFunction(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("servant_brute_1"true); 
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_1"2"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_2"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_3"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_4"2"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_5"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_6"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_7"2"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_8"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_9"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_10"2"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_11"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_12"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_13"0"");
    
AddEnemyPatrolNode("servant_brute_1""PathNodeArea_14"0"");
    
    }    

void RemoveMonster(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("servant_brute_1"false);

//END SERVANT BRUTE EVENT1

//START CROWBAR EVENT1
void CrowbarOnDoor(string &in itemstring &in door)
{
    
SetSwingDoorLocked("mansion_1"falsetrue);
    
PlaySoundAtEntity("""unlock_door""mansion_1"0false);
    
RemoveItem("crowbar_1");
}
//END CROWBAR EVENT1

void OnEnter() 
{

}

void OnLeave() 
{


Okay, start again.

Put a crowbar joint where you want to move the crowbar and set it inactive.
Also put crowbar_dyn in the same spot as the crowbar_joint and set it inactive.
Then put a little scriptarea next to that crowbar, this so when the crowbar meets the scriptarea; function will happen.

Now:

Quote:void OnStart()
{
AddUseItemCallback("", "crowbar_1", "mansion_1", "CrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "door_script_1", "crowbarfunc", true, 1);
}

void CrowbarOnDoor(string &in asItem, string &in asEntity)
{
SetEntityActive("crowbar_joint_1", true);
}


void crowbarfunc(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("mansion_1", 0.0f);
SetEntityActive("crowbar_joint_1", false);
SetEntityActive("crowbar_dyn_1", true);
}
Sorry I didn't explain it very good before. Smile