07-15-2011, 01:51 AM
07-15-2011, 11:21 AM
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
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
then for the callback make it so that when you use the key on the door, a local variable is set to 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:
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
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 just make sure you dont actually unlock the level door
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("" , "" , "");
}
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);
}
Spoiler below!
Code:
void unlock(string &in asItem, string &in asEntity)
{
SetLocalVarInt("IsDoorUnlocked" , 1);
}
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
}
}
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 just make sure you dont actually unlock the level door
07-16-2011, 08:28 PM
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?
(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);
}
}
07-16-2011, 09:21 PM
your if statement has a capital 'I', it must be lowercase to work
'if(GetLocalVarInt("IsDoorunLocked") == 1)'
Not 'If(GetLocalVarInt("IsDoorunLocked") == 1)'
'if(GetLocalVarInt("IsDoorunLocked") == 1)'
Not 'If(GetLocalVarInt("IsDoorunLocked") == 1)'
07-16-2011, 10:06 PM
IT DOESN"T WORK!! > THis is getting rediculous...
07-16-2011, 10:20 PM
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.
07-16-2011, 10:33 PM
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.
07-16-2011, 10:34 PM
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
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
07-16-2011, 10:53 PM
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?
take a look?
07-16-2011, 11:07 PM
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...
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...