![]() |
[SOLVED] RemoveTimer doesn't work - 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: [SOLVED] RemoveTimer doesn't work (/thread-15532.html) Pages:
1
2
|
[SOLVED] RemoveTimer doesn't work - FlawlessHappiness - 05-20-2012 Yea so i have the timer: void cry_1_timer(string &in asTimer) { PlaySoundAtEntity("", "12_girl_cry", "mansion_5", 0.5f, false); AddTimer("girl_cry", 40, "cry_1_timer"); } This timer triggers itself This next script should remove the timer, but instead, nothing happens. The girl keeps crying. void girl_flee_stop_timer(string &in asTimer) { PlaySoundAtEntity("", "door_level_wood_open", "level_wood_1", 0, false); RemoveTimer("girl_cry"); StopSound("12_girl_cry", 0); } Why won't it stop? The PlaySoundAtEntity("", "door_level_wood_open", "level_wood_1", 0, false); is working fine! It's only the timer that doesn't stop RE: RemoveTimer doesn't work - Putmalk - 05-20-2012 Okay, I see it. StopSound isn't stopping the correct sound. That's because you left your sound name blank (a practice I HIGHLY do not recommend, because then problems like this are so easy to happen). Rewrite your sound function like this: PlaySoundAtEntity("girlcry", "12_girl_cry", "mansion_5", 0.5f, false); Then, StopSound("girlcry", 0); will work. And start naming your sounds and callbacks. That will make problems like this easier to avoid as well as make your scripts easier to understand. Just name them simply so you can understand them. Just note that only certain functions support names, like PlaySound..., CreateParticleSystem..., AddUseItemCallback, AddTimer, etc. Hope this helps! RE: RemoveTimer doesn't work - Statyk - 05-20-2012 No, your script is calling a loop which is basically two timers in this case. You have to add two RemoveTimers. Like this: void girl_flee_stop_timer(string &in asTimer) { PlaySoundAtEntity("", "door_level_wood_open", "level_wood_1", 0, false); RemoveTimer("girl_cry"); RemoveTimer("cry_1_timer"); } RE: RemoveTimer doesn't work - Cranky Old Man - 05-20-2012 He never calls girl_flee_stop_timer(). RE: RemoveTimer doesn't work - Statyk - 05-20-2012 (05-20-2012, 07:54 PM)Cranky Old Man Wrote: He never calls girl_flee_stop_timer().My assumption was that he has a timer somewhere in the script that he did not put in the info... If this is the case: ![]() RE: RemoveTimer doesn't work - FlawlessHappiness - 05-20-2012 Ok sorry ![]() ![]() void OnStart() { AddUseItemCallback("", "crowbar_guestroom", "mansion_7", "UsedCrowbarOnDoor", true); AddEntityCollideCallback("crowbar_guestroom_joint", "crowbar1_script", "CollideAreaBreakDoor", true, 1); AddTimer("", 30, "cry_1_timer"); } void UsedCrowbarOnDoor(string &in asItem, string &in asEntity) { AddTimer("", 0.2, "TimerSwitchShovel"); RemoveItem("crowbar_guestroom"); } void TimerSwitchShovel(string &in asTimer) { PlaySoundAtEntity("","puzzle_place_jar.snt", "mansion_7", 0, false); SetEntityActive("crowbar_guestroom_joint", true); } void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState) { AddPlayerSanity(5); SetSwingDoorLocked("mansion_7", false, true); AddPropImpulse("mansion_7", 0, 0, -50, "World"); SetSwingDoorDisableAutoClose("mansion_7", true); SetSwingDoorClosed("mansion_7", false, false); SetMoveObjectState("mansion_7", 1); PlaySoundAtEntity("","break_wood_metal", "crowbar1_area", 0, false); CreateParticleSystemAtEntity("", "ps_hit_wood", "crowbar1_area", false); SetEntityActive("crowbar_guestroom_joint", false); SetLocalVarInt("Door", 1); SetEntityActive("crowbar_guestroom_broken", true); AddTimer("", 1, "girl_scream_timer"); } ///SCARES void girl_scream_timer(string &in asTimer) { PlaySoundAtEntity("", "12_girl_scream", "level_wood_1", 0, false); AddTimer("", 2, "girl_flee_timer"); } void girl_flee_timer(string &in asTimer) { SetSwingDoorLocked("mansion_5", false, true); SetSwingDoorDisableAutoClose("mansion_5", true); AddPropImpulse("mansion_5", 0, 0, 20, ""); AddTimer("", 1, "girl_flee_stop_timer"); } void girl_flee_stop_timer(string &in asTimer) { PlaySoundAtEntity("", "door_level_wood_open", "level_wood_1", 0, false); SetGlobalVarInt("Cellar", 1); RemoveTimer("girl_cry"); StopSound("12_girl_cry", 0); } ///TIMERS void cry_1_timer(string &in asTimer) { PlaySoundAtEntity("", "12_girl_cry", "mansion_5", 0.5f, false); AddTimer("girl_cry", 40, "cry_1_timer"); } EDIT: And no it doesn't work ![]() RE: RemoveTimer doesn't work - FlawlessHappiness - 05-24-2012 Sorry for bumping, but i just can't make this work ![]() RE: RemoveTimer doesn't work - Your Computer - 05-24-2012 You still have not followed the advise posted in post #2. RE: RemoveTimer doesn't work - Acies - 05-24-2012 void girl_flee_stop_timer(string &in asTimer) { PlaySoundAtEntity("", "door_level_wood_open", "level_wood_1", 0, false); SetGlobalVarInt("Cellar", 1); RemoveTimer("girl_cry"); StopSound("12_girl_cry", 0); } ///TIMERS void cry_1_timer(string &in asTimer) { PlaySoundAtEntity("", "12_girl_cry", "mansion_5", 0.5f, false); AddTimer("girl_cry", 40, "cry_1_timer"); } (05-20-2012, 07:29 PM)Putmalk Wrote: Okay, I see it.Why don't you read your advice boy? PlaySoundAtEntity("girlcry", "12_girl_cry", "mansion_5", 0.5f, false); Naming goes here ^ RE: RemoveTimer doesn't work - Cranky Old Man - 05-24-2012 (05-20-2012, 07:59 PM)Statyk Wrote:Sorry. Sometimes I just hastily stick my head in a thread and post the first thing I find. After properly pinpointing the problem, I agreee with your advice.(05-20-2012, 07:54 PM)Cranky Old Man Wrote: He never calls girl_flee_stop_timer().My assumption was that he has a timer somewhere in the script that he did not put in the info... If this is the case: |