Frictional Games Forum (read-only)

Full Version: How to end custom story as a Demo?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
This is so troublesome D:<
you could try this:
I have two possible solutions, if the first doesn't work, try the other

1. so you want it so that when you use the key on the level door, it unlocks. Sorry if someone else has posted this but couldn't you just do
Code:
void OnStart()
{
AddUseItemCallback("key" , "levelDoor" , "StartCredits" , true);
}
void StartCredits(asItem , asEntity)
{
StartCredits("" , "" , "");
}
most of the function names are wrong, because i cant remember them off the top of my head.
Im guessing that you have already tried the above, and also i think you said that you wanted the credits to start when you click on the door. so try this:

2. create an area just in front of the door, add a use item callback so when you use the key on the Door, the callback calls. - set boolautodestroy true
Spoiler below!
Code:
void OnStart()
{
AddUseItemCallback("key" , "mydoor" , "unlock" , true);
}

then for the callback make it so that when you use the key on the door, a local variable is set to 1

Spoiler below!
Code:
void unlock(string &in asItem, string &in asEntity)
{
SetLocalVarInt("IsDoorUnlocked" , 1);
}

finally, in your level editor, set the door locked, and under player interact calbacks, add a callback called eg: StartCredits
then in the editor add the code:
Spoiler below!
Code:
void StartCredits(string &in asEntity)
{
if(GetLocalVarInt("IsDoorUnlocked") == 1){
StartCredits("" , "" , "");
// whatever else you wanna do
}
}

again not all te code is perfect, so if it says fatal error(which it will do in that state) just look through the code, try to solve it, hope this helps Big Grin


Edit: I suppose you wouldn't even need to make an area in front of the door - just change "mydoorarea" to "mydoor" in the useitemcallback Smile just make sure you dont actually unlock the level door
hmm.. got an error saying
(162, 1) Expected ';'
Which is pretty impossible considering the fact the the only thing on row 162 is '{ syntax error somewhere?

Code:
void UseKeyOnDoor_6(string &in asItem, string &in asEntity)
{
    SetLocalVarInt("IsDoorunLocked", 1);
    SetLevelDoorLocked("labdoor", false);
    PlaySoundAtEntity("", "unlock_door", "labdoor", 0, false);
    RemoveItem("labkey_1");
}

void UsedKeyOnDoor_10(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("lloydsoffice", false, true);
    PlaySoundAtEntity("", "unlock_door", "lloydsoffice", 0, false);
    RemoveItem("lloydskey_1");
    SetMessage("Message", "lloydsdooropen", 0);
}

void StartCredits(string &in asEntity)
{
If(GetLocalVarInt("IsDoorunLocked") == 1)
{
FadeOut(2.0f);
StartCredits("01_Vicarious.ogg", false, "Ending", "MainCredits", 1);
}
}
your if statement has a capital 'I', it must be lowercase to work
'if(GetLocalVarInt("IsDoorunLocked") == 1)'

Not 'If(GetLocalVarInt("IsDoorunLocked") == 1)'
IT DOESN"T WORK!! >Sad THis is getting rediculous...
Don't use that kind of method then. Just make a collidecallback and when you collide with that box the story ends and the credits roll.
Here's the main problem, getting the credits to "roll", I'll go with the entire map full of credits method for a while, see if I could fix it, it plays the music, the screen fades to black, but the credits themselves don't show up.
What is the problem? I cant see anything else wrong with the script. If the problem is that you go through the level door when you click on it, comment out the line: SetLevelDoorLocked("labdoor", false);
and add it in again once you've uploaded the demo, that is, if you are still using my script. Also, if that doesn't work, you have probably named something wrong in your level editor/ .lang file
I've done what you've suggested, but it still won't work, I checked both the .lang and .hps files to see if they matched several times, they both match. I don't believe anything is wrong with the .lang file.
take a look?
Ok, does your AddUseItemCallback look word for word exactly like this?

AddUseItemCallback("Unlock" , "labkey_1" , "labdoor" , "UseKeyOnDoor_6" , true);

also, in void OnStart() add

SetLocalVarInt("IsDoorunLocked", 0);

if its still messing up change the UseKeyOnDoor_6 part of the script to:

void UseKeyOnDoor_6(string &in asItem, string &in asEntity)
{
SetLocalVarInt("IsDoorunLocked", 1);
SetLevelDoorLocked(asEntity, false);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}

also, if none of these suggestions work, you may aswell try this --

try making a script area cover the door, rename the door to "randomnamehere" and call the script area "labdoor" hopefully that will work...

Pages: 1 2 3 4 5