Frictional Games Forum (read-only)

Full Version: Crowbar won't work on door! help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
when I use the crowbar on the door, it get's me a message saying cannot use item this way! I named everything the same from level editor to the hps file? is there something I forgot to add for it not not work?

Spoiler below!

void PickupKey(string &in asEntity, string &in asItem)

{

AddQuest("quest1", "TestQuest");
AddTimer("", 0.5f, "NeverCalledTimer"); //Change the time as long as you want

AddUseItemCallback("", "MasterBedroomKey", "bedroomdoor","UseMasterBedroomKey", true);

AddEntityCollideCallback("Player", "AreaMemento", "EventQuest", true, 1);

}



void UseMasterBedroomKey(string &in asItem, string &in asEntity)

{

SetMessage("message", "message1", 3);

}



void NeverCalledTimer(string &in asTimer)

{

AddTimer("", 1.1f, "TimerDoorStart");

}



void TimerDoorStart(string &in asTimer)

{

AddUseItemCallback("", "Crowbar", "Door", "UseCrowbarOnDoor", true);

AddEntityCollideCallback("Joint", "AreaBreak", "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");

}



void TimerPlaceCrowbar(string &in asTimer)

{

SetEntityActive("Joint", true);

PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);

}



void BreakDoor(string &in asParent, string &in asChild, int alState)

{

SetEntityActive("Joint", false);

SetEntityActive("Broken", true);


SetSwingDoorLocked("Door", false, false);

SetSwingDoorClosed("Door", false, false);

SetSwingDoorDisableAutoClose("Door", true);


AddPropImpulse("Door", 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");

}



void TimerPushDoor(string &in asTimer)

{

AddPropImpulse("Door", -4, 2, 1, "world");

AddTimer("", 1.1, "TimerDoorCanClose");

}

void TimerDoorCanClose(string &in asTimer)

{
SetSwingDoorDisableAutoClose("Door", false);

}

//void touchdoor(string &in asEntity, string &in type) //Where is it called at? Ignoring it for now.

//{

//AddQuest("door", "touchdoor");

//}

void EventQuest(string &in asParent, string &in asChild, int alState)

{

AddQuest("door", "touchdoor");

}

As silly as it sounds, had you activated the timer which has the AddUseItemCallback for the joint and the crowbar?

If you cannot actually activate that timer, cut and paste those two lines of code and place them within your OnStart() routine, so that the callbacks are added when the map begins.
(12-23-2013, 01:55 PM)Romulator Wrote: [ -> ]As silly as it sounds, had you activated the timer which has the AddUseItemCallback for the joint and the crowbar?

If you cannot actually activate that timer, cut and paste those two lines of code and place them within your OnStart() routine, so that the callbacks are added when the map begins.
so where it says

AddUseItemCallback("", "Crowbar", "Door", "UseCrowbarOnDoor", true);

I am supposed to add a timer?
No no, put them into an OnStart().

Like this:
PHP Code:
void OnStart()
{
AddUseItemCallback("""Crowbar""Door""UseCrowbarOnDoor"true);
AddEntityCollideCallback("Joint""AreaBreak""BreakDoor"true1);


Put that anywhere in your code, and delete those two lines from the timer.

Look at this topic, and actually read it. Although it is tough stuff, you need to understand what you are scripting. http://wiki.frictionalgames.com/hpl2/tut...iferorange
(12-23-2013, 02:05 PM)Romulator Wrote: [ -> ]No no, put them into an OnStart().

Like this:
PHP Code:
void OnStart()
{
AddUseItemCallback("""Crowbar""Door""UseCrowbarOnDoor"true);
AddEntityCollideCallback("Joint""AreaBreak""BreakDoor"true1);


Put that anywhere in your code, and delete those two lines from the timer.

Look at this topic, and actually read it. Although it is tough stuff, you need to understand what you are scripting. http://wiki.frictionalgames.com/hpl2/tut...iferorange
still didn't work :/ still gets me cannot use item this way! this is the updated hps

void OnStart()
{
AddUseItemCallback("", "Crowbar", "Door", "UseCrowbarOnDoor", true);
AddEntityCollideCallback("Joint", "AreaBreak", "BreakDoor", true, 1);
}


void PickupKey(string &in asEntity, string &in asItem)

{

AddQuest("quest1", "TestQuest");
AddTimer("", 0.5f, "NeverCalledTimer"); //Change the time as long as you want

AddUseItemCallback("", "MasterBedroomKey", "bedroomdoor","UseMasterBedroomKey", true);

AddEntityCollideCallback("Player", "AreaMemento", "EventQuest", true, 1);

}



void UseMasterBedroomKey(string &in asItem, string &in asEntity)

{

SetMessage("message", "message1", 3);

}



void NeverCalledTimer(string &in asTimer)

{

AddTimer("", 1.1f, "TimerDoorStart");

}



void UseCrowbarOnDoor(string &in asItem, string &in asEntity)

{

RemoveItem(asItem);

PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);

AddTimer(asEntity, 0.2, "TimerPlaceCrowbar");

}



void TimerPlaceCrowbar(string &in asTimer)

{

SetEntityActive("Joint", true);

PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);

}



void BreakDoor(string &in asParent, string &in asChild, int alState)

{

SetEntityActive("Joint", false);

SetEntityActive("Broken", true);


SetSwingDoorLocked("Door", false, false);

SetSwingDoorClosed("Door", false, false);

SetSwingDoorDisableAutoClose("Door", true);


AddPropImpulse("Door", 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");

}



void TimerPushDoor(string &in asTimer)

{

AddPropImpulse("Door", -4, 2, 1, "world");

AddTimer("", 1.1, "TimerDoorCanClose");

}

void TimerDoorCanClose(string &in asTimer)

{
SetSwingDoorDisableAutoClose("Door", false);

}

//void touchdoor(string &in asEntity, string &in type) //Where is it called at? Ignoring it for now.

//{

//AddQuest("door", "touchdoor");

//}

void EventQuest(string &in asParent, string &in asChild, int alState)

{

AddQuest("door", "touchdoor");

}
Spoiler below!

PHP Code:
void OnStart()
{
AddUseItemCallback("""Crowbar_Entity""Door""CrowbarInteract"true);
AddEntityCollideCallback("Crowbar_Joint""JointCollideArea_1""BreakDoorCrowbar"true1);
}
 
 
void CrowbarInteract(string &in asItemstring &in asEntity)
 {
 
AddTimer(""0.2f"TimerSwitchJoint");
 
RemoveItem("Crowbar_Entity");
 }
 
 
void TimerSwitchJoint(string &in asTimer)
 {
 
PlaySoundAtEntity("","puzzle_place_jar.snt""Door"0false);
 
SetEntityActive("Crowbar_Joint"true);
 }
 
 
void BreakDoorCrowbar(string &in asParentstring &in asChildint alState)
 {
 
AddPlayerSanity(25);
 
PlayMusic("10_puzzle01.ogg"false0.70.110false);
 
SetSwingDoorLocked("Door"falsetrue);
 
AddPropImpulse("Door"00, -50"World");
 
SetSwingDoorDisableAutoClose("Door"true);
 
SetSwingDoorClosed("Door"falsefalse);
 
SetMoveObjectState("prison_1"1);
 
PlaySoundAtEntity("","break_wood_metal""EffectsArea"0false);
 
CreateParticleSystemAtEntity("""ps_hit_wood""EffectsArea"false);
 
SetEntityActive("Crowbar_Joint"false);
 
SetLocalVarInt("DoorVarInt"1);
 } 
 
 
void OnEnter()
{
}
 
 
void OnLeave()
{



You might wanna rename some script areas and items in your map...
(12-23-2013, 05:07 PM)JustAnotherPlayer Wrote: [ -> ]
Spoiler below!

PHP Code:
void OnStart()
{
AddUseItemCallback("""Crowbar_Entity""Door""CrowbarInteract"true);
AddEntityCollideCallback("Crowbar_Joint""JointCollideArea_1""BreakDoorCrowbar"true1);
}
 
 
void CrowbarInteract(string &in asItemstring &in asEntity)
 {
 
AddTimer(""0.2f"TimerSwitchJoint");
 
RemoveItem("Crowbar_Entity");
 }
 
 
void TimerSwitchJoint(string &in asTimer)
 {
 
PlaySoundAtEntity("","puzzle_place_jar.snt""Door"0false);
 
SetEntityActive("Crowbar_Joint"true);
 }
 
 
void BreakDoorCrowbar(string &in asParentstring &in asChildint alState)
 {
 
AddPlayerSanity(25);
 
PlayMusic("10_puzzle01.ogg"false0.70.110false);
 
SetSwingDoorLocked("Door"falsetrue);
 
AddPropImpulse("Door"00, -50"World");
 
SetSwingDoorDisableAutoClose("Door"true);
 
SetSwingDoorClosed("Door"falsefalse);
 
SetMoveObjectState("prison_1"1);
 
PlaySoundAtEntity("","break_wood_metal""EffectsArea"0false);
 
CreateParticleSystemAtEntity("""ps_hit_wood""EffectsArea"false);
 
SetEntityActive("Crowbar_Joint"false);
 
SetLocalVarInt("DoorVarInt"1);
 } 
 
 
void OnEnter()
{
}
 
 
void OnLeave()
{



You might wanna rename some script areas and items in your map...
still not working :/
While this is relevant, why is it that when I do AddPropForce("door", -1000, 0, 0, "world") instead of AddPropImpulse on the door after the crowbar'ing it open, the door sometimes flies open in the respective x direction and sometimes doesn't?
Forces push objects according to their mass. Impulses don't, hence will push an object by a set amount. A large enough impulse will cause something to break :3
well I started from scratch again with the crowbar code, but it still doesn't work! so goodbye for my custom story even though lots of people said "it looks amazing" and "best custom story ever", now it's deleted! I just don't know why the crowbar code won't work! I couldn't find the error anyway! happy Christmas guys and a happy new year! sigh it's always been my dream to make a custom story, but the stupid code crushed my dreams :'(
Pages: 1 2 3