Author Topic: A clock.  (Read 3022 times)

For an rpg server where days go by every minute, that level of accuracy isn't necessary. Using 30 days per month for every month is like super easy and nobody notices the difference
you shouldnt assume what he wants, or post that your stuff works without clarifying that it wont be truly accurate. you give the wrong impression otherwise

The day counter is supposed to add a day every six hours actually. It's intended for a friend's server, nothing special really. But my friend and I rather the months have separate day limits. I saw it possible in a CityRPG script but I couldn't figure out how they did it. I vaguely figured out how to do this, and if someone could walk me through how I could make this neater/actually work properly (and save the time when the host closes) that'd be awesome. I only tried it myself first to practice a little bit, since I'm mostly new to using torquescript.
Here's what I put together based on your guys help so far (besides what phantos suggested, as I didn't quite understand what he asked to do.) and snippets of code from other places. It showed no errors at the end but didn't function properly at all. December counted to 28 days only, then reset back to December 1st rather than January 1st. The announcement didn't print the variables for the names and stuff.

Code: [Select]
$day = 1;
$month = 1;
$year = 2150;
$m = "January";
$n = "th";

$dayInterval = 5000; //set to five seconds so I can actually test it, otherwise would be 2,600,000 for six hours. I dont even know if that's valid for torquescript.

function dayAdder()
{
    cancel($dayAdder);
    $day += 1;
if ($month = 1)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 2)
{
if ($day > 28)
{
$day = 1;
$month += 1;
}
}
if ($month = 3)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 4)
{
if ($day > 30)
{
$day = 1;
$month += 1;
}
}
if ($month = 5)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 6)
{
if ($day > 30)
{
$day = 1;
$month += 1;
}
}
if ($month = 7)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 8)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 9)
{
if ($day > 30)
{
$day = 1;
$month += 1;
}
}
if ($month = 10)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
if ($month = 11)
{
if ($day > 30)
{
$day = 1;
$month += 1;
}
}
if ($month = 12)
{
if ($day > 31)
{
$day = 1;
$month += 1;
}
}
switch$ ($month)
{
case 1: $m = "January";
case 2: $m = "February";
case 3: $m = "March";
case 4: $m = "April";
case 5: $m = "May";
case 6: $m = "June";
case 7: $m = "July";
case 8: $m = "August";
case 9: $m = "September";
case 10: $m = "October";
case 11: $m = "November";
case 12: $m = "December";
default: $m = "n/a";
}
switch$ ($day)
{
case 1: $d = "st";
case 2: $d = "nd";
case 3: $d = "rd";
case 21: $d = "st";
case 22: $d = "nd";
case 23: $d = "rd";
case 31: $d = "st";
default: $d = "th";
}
announce("Today is $m $day$d, $year.);
schedule($dayInterval, 0, dayAdder);
}
The only thing that worked properly was that it played every five seconds and each number had it's own suffix. 1=st, 25=th, etc.
« Last Edit: December 11, 2017, 05:46:08 PM by Doctor Disco »

$month = 12
should be
$month == 12

I don't think you meant to set the value in each if statement, but meant to compare it instead
(note that "$month = 12" sets month to 12, and returns 12, which evaluates to true)


Now that everything is functioning properly, I just have two final questions.
How do I save the variables when the host closes the server?
And how do I have /commands set variables depending on what the host types? (e.g. /setday 5)

http://docs.garagegames.com/tge/official/content/documentation/Reference/Console%20Functions/TorqueScript_Console_Functions_5.html#export.28_wildCard_.5B_.2C_fileName_.5B_.2C_append_.5D_.5D_.29

then you can execute that filepath or something.

And how do I have /commands set variables depending on what the host types? (e.g. /setday 5)
Code: [Select]
function servercmdSetDay(%cl,%day)
{
       if(%cl.isSuperAdmin)
               if(%day >= 0)
                        $Whateveryourdayvariableis = %day;
}