Scripts / Timer based code - please help?

Author
Message
Isagabe
9
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 21st Sep 2015 11:12
Greetings
Please, will someone be able to assist with this minor code I am trying to put together? Alas I have no skills besides minor stuff like spawning entities and notes etc. I want to spawn an entity, line of text, sound or what ever, after a timed delay when triggering a zone.

My logic says;
player in zone
start timer
get timer
if time X then
spawn X.
close script

But everything I have tried falls flat. Can anyone help? Many thanks. My attempts below Thanks in advance.

and


and finally


Thanks for reading. This is driving me nuts
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st Sep 2015 12:25 Edited at: 21st Sep 2015 12:27
good try but StartTimer(e) doesnt work quite as you're expecting, it resets the timer the entire time it's called, therefore in your script the GetTimer(e) will always be 0.

what i would do is move the starttimer outside the zone check this way while the player is in the zone the timer will start from 0 and the player needs to stay in the zone until the duration has passed (leaving the zone will reset the timer)

note also it's a good idea to check the GetTimer(e) is greater and equal as it's very possible it'll miss the timer being exactly equal to the duration ( >= instead of == )
also a good idea to destroy the zone after the spawn has been made so it wont continuously spawn the object (only an issue if it's something you can kill - it'll have unlimited lives while you're in the zone)

life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Isagabe
9
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 21st Sep 2015 17:34
Thank you smallg. so very kind of you as always. Will try it out tonight.
Isagabe
9
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 21st Sep 2015 17:40 Edited at: 21st Sep 2015 17:40
also staying in zone for duration is exactly what has to happen for my needs- so perfect. and thanks for the clear explanation on StarTimer - certainly counter intuitive to my logic LOL.
Isagabe
9
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 22nd Sep 2015 13:42
Many Thanks smallg. This worked perfectly.

Login to post a reply

Server time is: 2024-05-05 09:16:03
Your offset time is: 2024-05-05 09:16:03