Frictional Games Forum (read-only)
i need some help/ explaination - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: i need some help/ explaination (/thread-28348.html)

Pages: 1 2 3 4


i need some help/ explaination - Headless - 12-24-2014

Can someone help me with this code
Can anyone help me plz.
dont know why its wrong:/

Can you guys also explain to me why its wrong?
thx guys.

Btw i get error (14,1) : ERR : Uncexpected token'{'

But its hould be there right?
-----------------------------------------------------------------------------------------------------


void OnStart()
{
AddUseItemCallback("", "SoundDoor", "DoorSlam", "DOORopenSOUND", true);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);
}

void DOORopenSOUND(string& asName, string& asSound);
{
SetLevelDoorLockedSound(string& asName, string& asSound, true);
}


RE: i need some help/ explaination - Kurton - 12-24-2014

Take the semicolon off the end of your DOORopenSOUND syntax.

Also this should be in Support


RE: i need some help/ explaination - Headless - 12-24-2014

Like this???

void OnStart()
{
AddUseItemCallback("", "SoundDoor", "DoorSlam", "DOORopenSOUND", true);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);
}

void DOORopenSOUND
{
SetLevelDoorLockedSound(string& asName, string& asSound)
}

bc now i get a error (14,1) : ERR : Exprected '('


RE: i need some help/ explaination - PutraenusAlivius - 12-24-2014

PHP Code:
void DOORopenSOUND 
{
    
SetLevelDoorLockedSound(stringasNamestringasSound)


Two problems here.
First is at the void DOORopenSOUND. There should have been the callback syntax. Because the function used was AddUseItemCallback, use (string &in asItem, string &in asEntity) as it's callback.

Second is at the SetLevelDoorLockedSound function. You need to fill the parameters in. Like what asName is, what asSound is, etc. You're also missing a semicolon.

And that's it.


OR!
Ignore everything I said above and just copy-paste the script below.

Spoiler below!

PHP Code:
void DOORopenSOUND(string &in asItemstring &in asEntity)
{
    
SetLevelDoorLockedSound("LevelDoor""SoundFile"); ///Note: I'm not sure if SoundFile uses an extension or not.





RE: i need some help/ explaination - Headless - 12-24-2014

okay thx i will try it out

Oh i screwed up kinda, sorry.
What i wanted is when you try to open this door.
Another door slammed open.

Dont know how to code this so lookin at engine scripts but didnt read it properly
thanks anyways.
i will keep searching how to do it


RE: i need some help/ explaination - PutraenusAlivius - 12-24-2014

(12-24-2014, 12:43 PM)Headless Wrote: Oh i screwed up kinda, sorry.
What i wanted is when you try to open this door.
Another door slammed open.

Oh, like uh..
You have two doors, both locked. On the left is Door A and on the right is Door B. If you interact with Door B, nothing happens. But if you try to pull or push Door A, Door B will slam open, is that what you mean?

If it is, then I could probably do it.


RE: i need some help/ explaination - Headless - 12-24-2014

void OnStart()
{
AddUseItemCallback("Player", "DoorLocked", "DoorOpenSlamming", "DOORopen", true);
AddUseItemCallback("", "DoorLocked", "SlammingSound", "DOORopenSOUND", true);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);
}

void DOORopen(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("DoorOpenSlamming", false, false);
SetSwingDoorDisableAutoClose("DoorOpenSlamming", true);

PlaySoundAtEntity("SlammingSound", "joint_door_move_special.snt", "DoorOpenSlamming", false);

Addtimer("", 2, "TimerStopSound");
AddTimer("DoorOpenSlamming", 0, "TimerMoveDoor");
}

void TimerMoveDoor(string &in asTimer)
{
if(GetLocalVarInt("VarDoor") == 10) return;
AddLocalVarInt("VarDoor", 1);

AddTimer(asTimer, 0.03, "TimerMoveDoor");

AddPropForce(asTimer, -70, 0, 0, "world");
}

void TimerStopSound(string &in asTimer)
{
StopSound("SlammingSound", 0.4);
}
I think im closer but im lost again

Yes exactly that!

DoorOpenSlamming>DoorB ..........................................Doorlocked>DoorA
----------------------------------------------------------------------------00000--
0
0
0
---------------------------------------------------------------------------00000--
.................................................................................................Door:Where you enter the room


RE: i need some help/ explaination - PutraenusAlivius - 12-24-2014

Spoiler below!

PHP Code:
void OnStart()
{
    
SetLocalVarInt("DoorVar"0);
    
SetSwingDoorLocked("Door_A"truetrue);
    
SetSwingDoorLocked("Door_B"truetrue);
    
SetEntityPlayerInteractCallback("Door_A""Slam_Door_B"false);
}

void Slam_Door_B(string &in asEntity)
{
    
AddLocalVarInt("DoorVar"1);
    
DoorCheck();
}

void DoorCheck()
{
    if(
GetLocalVarInt("DoorVar") == 10//Indicates you have to interact with it ten(10) times
    
{
        
AddTimer("Slam"2.75f"Slam");
    }
}

void Slam(string &in asTimer)
{
    
SetSwingDoorLocked("Door_B"falsefalse);
    
AddPropForce("Door_B"000"World"); //Change the Z or X argument (X is the first zero, Z is the last zero) to fit your door's alignment



That's my take on this. Untested. If something doesn't fit what you want, go ahead and give me a PM.


RE: i need some help/ explaination - Headless - 12-24-2014

Thanks Im gonna test it right away

changed my door names to Door_A and Door_B Sound to Slam right?

ANd i get error 14.1

void OnStart()
{
AddUseItemCallback("Player", "DoorLocked", "DoorOpenSlamming", "DOORopen", true);
AddUseItemCallback("", "DoorLocked", "SlammingSound", "DOORopenSOUND", true);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
RemoveItem(asItem);
}

{ //here
SetLocalVarInt("DoorVar", 0);
SetSwingDoorLocked("Door_A", true, true);
SetSwingDoorLocked("Door_B", true, true);
SetEntityPlayerInteractCallback("Door_A", "Slam_Door_B", false);
}

void Slam_Door_B(string &in asEntity)
{
AddLocalVarInt("DoorVar", 1);
DoorCheck();
}

void DoorCheck()
{
if(GetLocalVarInt("DoorVar") == 10) //Indicates you have to interact with it ten(10) times
{
AddTimer("Slam", 2.75f, "Slam");
}
}

void Slam(string &in asTimer)
{
SetSwingDoorLocked("Door_B", false, false);
AddPropForce("Door_B", -1, 0, 0, "World"); //Change the Z or X argument (X is the first zero, Z is the last zero) to fit your door's alignment
}

Maybe i think i didnt put it in right but not sure how to do it

Sorry im kinda new to scripting and mostly use tutorials and trail and error.


RE: i need some help/ explaination - PutraenusAlivius - 12-24-2014

PHP Code:
void OnStart()
{
    
AddUseItemCallback("Player""DoorLocked""DoorOpenSlamming""DOORopen"true);
    
AddUseItemCallback("""DoorLocked""SlammingSound""DOORopenSOUND"true);
    
AddUseItemCallback("""Key""Door""UseKeyOnDoor"true);
    
SetLocalVarInt("DoorVar"0);
    
SetSwingDoorLocked("Door_A"truetrue);
    
SetSwingDoorLocked("Door_B"truetrue);
    
SetEntityPlayerInteractCallback("Door_A""Slam_Door_B"false);
}

void UseKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
RemoveItem(asItem);
}

void Slam_Door_B(string &in asEntity)
{
    
AddLocalVarInt("DoorVar"1);
    
DoorCheck();
}

void DoorCheck()
{
    if(
GetLocalVarInt("DoorVar") == 10//Indicates you have to interact with it ten(10) times
    
{
        
AddTimer("Slam"2.75f"Slam");
    }
}

void Slam(string &in asTimer)
{
    
SetSwingDoorLocked("Door_B"falsefalse);
    
AddPropForce("Door_B", -100"World"); //Change the Z or X argument (X is the first zero, Z is the last zero) to fit your door's alignment


Corrected.


Here's a lesson.
Spoiler below!

ALL FUNCTIONS MUST EXIST IN A CALLBACK FUNCTION. So stuff like SetSwingDoorLocked or AddTimer must be inside things like:
Code:
void Function(parameter)
{
//Function//
}

If you see two void OnStarts that are conflicting, put the functions in the secondary OnStart. So if you see:
Code:
//Primary OnStart//
void OnStart()
{
//Function A..//
}
AND
Code:
//Secondary OnStart
void OnStart()
{
//Function B..
}

that, eliminate the second OnStart and put the functions in the secondary OnStart to the primary OnStart. In the end it should look like:
Code:
//Primary OnStart//
void OnStart()
{
//Function A...//
//Function B...// <- Function from second OnStart
}