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 Crowbar/Key Script Help
wagiwombledog Offline
Junior Member

Posts: 8
Threads: 4
Joined: Mar 2012
Reputation: 0
#1
Crowbar/Key Script Help

Please Help,

My .hps has a fatal error, mostly Unexpected token "{" here is the script:


Entrance.hps

////////////////////////////
// Run when the map starts
void OnStart()
{

AddUseItemCallback("", "Waterworks Key", "Waterworks", "FUNCTION", true);

}

void FUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}

{
AddUseItemCallback("", "crowbar_1", "Storage", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);
}


void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
}


void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false);
SetEntityActive("crowbar_joint_1", true);
}


void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("prison_1", false, true);
AddPropImpulse("prison_1", 0, 0, -50, "World");
SetSwingDoorDisableAutoClose("prison_1", true);
SetSwingDoorClosed("prison_1", false, false);
SetMoveObjectState("prison_1", 1);
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}



////////////////////////////
// Run when entering map
void OnEnter()




////////////////////////////
// Run when entering map
void OnLeave()
{

}


void DoorLockedPlayer(string &in entity)

{
if(GetSwingDoorLocked("Storage Locked") == true)
{

SetMessage("Messages", "msgname", 0);

}
}


{
if(GetSwingDoorLocked("WW Locked") == true)
{

SetMessage("Messages", "msgname", 0);

}
}

Can you see anything wrong with it?

Please help,
wagiwombledog
09-11-2012, 05:43 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#2
RE: Crowbar/Key Script Help

A few quick notes:
- All callbacks should be under OnStart
-All functions need a header (i.e. void + name + callback syntax)
-Never use spaces in a string name, always use underscores "_"

With that said, here's a revision:


void OnStart()
{
AddUseItemCallback("", "Waterworks_Key", "Waterworks", "FUNCTION", true);
AddUseItemCallback("", "crowbar_1", "Storage", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);
}

void FUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}

void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
}

void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false);
SetEntityActive("crowbar_joint_1", true);
}


void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("prison_1", false, true);
AddPropImpulse("prison_1", 0, 0, -50, "World");
SetSwingDoorDisableAutoClose("prison_1", true);
SetSwingDoorClosed("prison_1", false, false);
SetMoveObjectState("prison_1", 1);
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}

void DoorLockedPlayer(string &in asEntity)
{
if(GetSwingDoorLocked("Storage Locked") == true)
{
SetMessage("Messages", "msgname", 0);
}
}

void DoorLockedPlayer2(string &in asEntity)
{
if(GetSwingDoorLocked("WW Locked") == true)
{
SetMessage("Messages", "msgname", 0);
}
}



////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when entering map
void OnLeave()
{

}

I hope that helped!

I rate it 3 memes.
09-11-2012, 05:54 AM
Find




Users browsing this thread: 1 Guest(s)