Frictional Games Forum (read-only)

Full Version: Broken Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have two scripts that don't seem to be working right.

The first is trying to make a grunt spawn when walking into a specific area but when I run the map it doesn't work
This the script in full

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Monsterdoorkey", "Monsterdoor", "UsedKeyOnDoor", true);
}

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

void OnLeave()

////////////////////////////
// Run when leaving map



{
AddEntityCollideCallback("Player", "PlayerCollide", "SpawnMonster", true, 1);
}
void SpawnMonster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_3", true);

}

I'm also trying to make a key unlock a door on another map but when I try to unlock the door it says "cannot use item this way"
Here is the script in full

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 1);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alstate)
{
SetSwingDoorClosed("RoomTwoDoor", true, true);
GiveSanityDamage(90 , true);
PlayGuiSound("react_past", 1);
}

void OnEnter()
{
AddUseItemCallback("", "WaterDoorkey", "WaterDoor", "UsedKeyOnDoor", true);
}

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

If anyone can offer a solution, I would be glad to hear it.
wow your script is a chaos ^^



Let me rewrite it for you:

First Map:


Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "Monsterdoorkey", "Monsterdoor", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "SpawnMonster", true, 0);
}

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

void SpawnMonster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_3", true);
}

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

}

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

}

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 0);
AddUseItemCallback("", "WaterDoorkey", "WaterDoor", "UsedKeyOnDoor", true);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alstate)
{
SetSwingDoorClosed("RoomTwoDoor", true, true);
GiveSanityDamage(90 , true);
PlayGuiSound("react_past", 1);
}

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

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

}

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

}

Check so everything is spelled right Smile