Time Request

dfabsgwapings

New member
Messages
165
Points
0
Github
dfabsgwapings
Hi there, can anyone do a script for this?

like it will announce every hour

It is currently <time> on <day>, <month> <date>, <year>.

example:

It is currently 08:00:00 on Thursday, January 5th, 2017.

thanks in advance..

 
Hello there i made it in 2 ways 

1- short way

- script timeannouncer FAKE_NPC,{

OnMinute00:
announce("It is currently " + gettimestr("%Y-%m/%d %H:%M:%S", 21), bc_all);
end;
}

2- A bit long one

- script timeannouncer FAKE_NPC,{

OnMinute00:
setarray(.@Days$, "Monday", "Thuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
setarray(.@Months$, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
.@sec = gettime(GETTIME_SECOND);
.@min = gettime(GETTIME_MINUTE);
.@hour = gettime(GETTIME_HOUR);
.@day = gettime(GETTIME_WEEKDAY);
.@dayofmonth = gettime(GETTIME_DAYOFMONTH);
.@month = gettime(GETTIME_MONTH);
.@year = gettime(GETTIME_YEAR);

if (.@dayofmonth == 1) {
.@tr$ = "st";
} else if (.@dayofmonth == 2) {
.@tr$ = "nd";
} else if (.@dayofmonth == 3) {
.@tr$ = "rd";
} else {
.@tr$ = "th";
}

announce(sprintf("It is currently %d:%d:%d on %s, %s %d%s, %d", .@sec, .@min, .@hour, .@Days$[.@day], .@Months$[.@month], .@dayofmonth, .@tr$, .@year), bc_all);
end;
}

(ps: maybe there is a better way to do this but i dont know it
default_biggrin.png
)


 
@Asheraf

Hi, thanks for the script and I like the second one, I am getting exactly what I want however the time and date is not same as what's the time on the server. :C

please help me for this one

it crashes my server. this one automatically shuts down the map server without any error

 
@Asheraf

Hi, thanks for the script and I like the second one, I am getting exactly what I want however the time and date is not same as what's the time on the server. :C

You must change this line:

announce(sprintf("It is currently %d:%d:%d on %s, %s %d%s, %d", .@sec, .@min, .@hour, .@Days$[.@day], .@Months$[.@month], .@dayofmonth, .@tr$, .@year), bc_all);




to this:

announce(sprintf("It is currently %d:%d:%d on %s, %s %d%s, %d", .@hour, .@min, .@sec, .@Days$[.@day], .@Months$[.@month], .@dayofmonth, .@tr$, .@year), bc_all);

to follow <hour>:<minutes>:<seconds> format.

it crashes my server. this one automatically shuts down the map server without any error
It works very well with me.

 
Back
Top