GSC Timers
#1
Well I'm wondering how to make a timer for my mod for example...

if timer = 5
do this
else if timer = 10
do something else


I'm stumped at the moment but if anyone can help me that'd be awesome thanks Smile
Reply

#2
Code:
Init() { level thread Timer("timer1", 25); level thread Effect(); } Timer(name, time) { for(level.timer[name]=time;level.timer[name]>0;level.timer[name]--) { wait 1; } } Effect() { if(level.timer[timer1] > 15) { //dostuff } }
YouTube 1:Azumikkel- Modding
YouTube 2:DerpShark- Gaming Entertainment
Website:Jensby.me
Contact: im[at]jensby.me
Reply

#3
(12-05-2012, 11:14)AZUMIKKEL Wrote:
Code:
Init() { level thread Timer("timer1", 25); level thread Effect(); } Timer(name, time) { for(level.timer[name]=time;level.timer[name]>0;level.timer[name]--) { wait 1; } } Effect() { if(level.timer[timer1] > 15) { //dostuff } }

Thank you so so so much!

*edit*
I get an error;\

ERROR: script compile error
uninitialised variable 'timer1'
maps/mp/gametypes/_rank.gsc
(see console for actual details)

I'm new to modding.-.
Reply

#4
My bad

Code:
Init() { level thread Timer("timer1", 25); level thread Effect(); } Timer(name, time) { for(level.timer[name]=time;level.timer[name]>0;level.timer[name]--) { wait 1; } } Effect() { if(level.timer["timer1"] > 15) { //dostuff } }
YouTube 1:Azumikkel- Modding
YouTube 2:DerpShark- Gaming Entertainment
Website:Jensby.me
Contact: im[at]jensby.me
Reply

#5
@AZUMIKKEL That isn't going to work, it's just going to exit the Effect function/sub straight away....
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply

#6
Of course it is, the effect thread is an example...
YouTube 1:Azumikkel- Modding
YouTube 2:DerpShark- Gaming Entertainment
Website:Jensby.me
Contact: im[at]jensby.me
Reply

#7
Yes but to make it keep checking can't i just put wait 1; in the effect as well?
Reply

#8
Code:
Effect() { for(;;) { if(level.timer["timer1"] > 15) { //dostuff } wait 0.5; } }

Every coding language 101..
YouTube 1:Azumikkel- Modding
YouTube 2:DerpShark- Gaming Entertainment
Website:Jensby.me
Contact: im[at]jensby.me
Reply

#9
I was just making sure...
Reply

#10
Yes
YouTube 1:Azumikkel- Modding
YouTube 2:DerpShark- Gaming Entertainment
Website:Jensby.me
Contact: im[at]jensby.me
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.