Jump to content
  • 0

OnInit:


mirabell

Question


  • Group:  Members
  • Topic Count:  41
  • Topics Per Day:  0.01
  • Content Count:  197
  • Reputation:   19
  • Joined:  11/20/11
  • Last Seen:  

this isnt working for me  not sure why

 

OnInit:
if (gettime(3) >=0 && gettime(3) <=3) 
set $@isnight, 1; 
night;
if (gettime(3) >=4 && gettime(3) <=7) 
set $@isnight, 0;
day;
if (gettime(3) >=8 && gettime(3) <=11)
set $@isnight, 1; 
night;
if (gettime(3) >=12 && gettime(3) <=15) 
set $@isnight, 0;
day;
if (gettime(3) >=16 && gettime(3) <=19)
set $@isnight, 1; 
night;
if (gettime(3) >=20 && gettime(3) <=23) 
set $@isnight, 0;
day;
end;

 

Edited by mirabell
wrong part of script
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3127
  • Reputation:   1617
  • Joined:  03/26/12
  • Last Seen:  

If-statements with more than one line of code to perform should be in curly braces:

OnInit:
	if (gettime(3) >=0 && gettime(3) <=3) {
		$@isnight = 1; 
		night;
	}
	if (gettime(3) >=4 && gettime(3) <=7) {
		$@isnight = 0;
		day;
	if (gettime(3) >=8 && gettime(3) <=11) {
		$@isnight = 1; 
		night;
	}
	if (gettime(3) >=12 && gettime(3) <=15) {
		$@isnight = 0;
		day;
	}
	if (gettime(3) >=16 && gettime(3) <=19) {
		$@isnight = 1; 
		night;
	}
	if (gettime(3) >=20 && gettime(3) <=23) {
		$@isnight = 0;
		day;
	}
	end;

Don't forget that gettime() now uses constants:

Quote

*gettime(<type>)

This function will return specified information about the current system time.

DT_SECOND - Seconds (of the current minute)
DT_MINUTE - Minutes (of the current hour)
DT_HOUR - Hour (of the current day)
DT_DAYOFWEEK - Week day (constants for MONDAY to SUNDAY are available)
DT_DAYOFMONTH - Day of the current month
DT_MONTH - Month (constants for JANUARY to DECEMBER are available)
DT_YEAR - Year
DT_DAYOFYEAR - Day of the year

It will only return numbers. If another type is supplied -1 will be returned.

	if (gettime(DT_DAYOFWEEK)==SATURDAY) mes "It's a Saturday. I don't work on Saturdays.";

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  41
  • Topics Per Day:  0.01
  • Content Count:  197
  • Reputation:   19
  • Joined:  11/20/11
  • Last Seen:  

thanks so i should be using   (gettime(DT_HOUR) >=16 && gettime(DT_HOUR) <=19)    thanks i forgot about the curls its been 4 years since i wrote a script 

 

Edited by mirabell
  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...