Frictional Games Forum (read-only)

Full Version: Sound not playing at the right times
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
////////////////////////////
// Run when the map starts
void OnStart()

{
AddUseItemCallback("", "starterroomkey_1", "starterdoor", "Usekeyondoor", true);
AddEntityCollideCallback("Player", "BLAM1", "func_slam", true, 1);
SetEntityCallbackFunc("earthquakenote", "Func");
}

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

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("starterdoor", true, true);

SetSwingDoorLocked("starterdoor", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false);  PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}

void Func(string &in asEntity, string &in type)
{
if(type == "OnPickup")
    {
    StartScreenShake(0.10f, 5.0f, 1.5f, 4.0f);
    StartPlayerLookAt("lookat", 0.5, 0.5, "");
    SetPlayerActive(false);
    SetPlayerCrouching(true);
    AddTimer("", 1.0, "Timer1");
    AddTimer("", 4.0, "Timer2");
    AddTimer("", 1.0, "PlayShit");
    }
}
void Timer1(string &in asTimer)
{
        PlaySoundAtEntity("", "react_sigh", "Player", 0, false);
}
void Timer2(string &in asTimer)
{
        SetPlayerCrouching(false);
        StopPlayerLookAt();
        SetPlayerActive(true);
}
void PlayShit(string &in asParent, string &in asChild, int alState)
{
        PlaySoundAtEntity("", "general_rock_rumble", "Player", 0, false);
}

The rumble sound seems to be delayed, then it repeats. Also for some reason after the timer ends and the stopplayerlookat function is called, it still automatically looks at random objects.
Can anyone help?
Use that instead of CallEntityCallbackFunc

Code:
void SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);

Calls a function when the player interacts with a certain entity.
Callback syntax: void MyFunc(string &in asEntity)

asName - internal name
asCallback - function to call
abRemoveOnInteraction - determines whether the callback should be removed when the player interacts with the entity