Author Topic: using day cycle in gamemode, day length defaults to 5 minutes long  (Read 1600 times)

i've been trying to create a gamemode that uses the default day cycle, and setting the length of the day to 30 minutes and 24 hours to test it. (set through the gamemode.txt. 30 minutes being "1800 seconds", 24 hours being "86400 seconds")

but when i test my gamemode, the length of the day cycle seems to not follow the length of day in the gamemode.txt
i timed the entire cycle (day and night) to be at around 5 minutes long (300 seconds) despite different values in the gamemode.txt
manually setting the number through the Environment settings while playing works though.

most of the console log attached below

Do you mind posting Add-Ons/GameMode_Castle_Crashers/gamemode.txt as well?

Do you mind posting Add-Ons/GameMode_Castle_Crashers/gamemode.txt as well?
attached

the thing that controls the length of the day cycle is as followed
Code: [Select]
$EnvGuiServer::DayLength (in the gamemode.txt, this is set to 86400)

Well, you could try making a server.cs in the gamemode.zip with

$EnvGuiServer::DayLength=86400;

Well, you could try making a server.cs in the gamemode.zip with

$EnvGuiServer::DayLength=86400;

inputting that solely in it's own server.cs (while having the gamemode.txt execute it) sends out a syntax error. i don't know what else to put in the server.cs because i know nothing of things code/script

personally, i'd prefer if the gamemode didn't have a server.cs solely for a bug/error/problem/something else

Well, gamemode.txt isn't supposed to execute it. It gets executed automatically because it's a server.cs in a server add-on.

I tried it at the campus and you're right. When I get home, I'll check in my PC for a workaround. I'm thinking about trying to schedule the daycycle to, say, the next frame after the first player enters the game. As in, using the following code:

Code: [Select]
$FirstJoin = true;

package autoAdminCheck
{
function gameConnection::AutoAdminCheck(%client) {
Parent::AutoAdminCheck(%client);
if($firstJoin) {
$firstJoin = false;
schedule(0,0,"$EnvGuiServer::DayLength=86400");
}
}
};
activatePackage(autoAdminCheck);

That schedule will not work because there's no function being called.

Use schedule(100, 0, eval, "blah"); instead.

You're right, sorry.

Code: [Select]
$FirstJoin = true;

package autoAdminCheck
{
function gameConnection::AutoAdminCheck(%client) {
Parent::AutoAdminCheck(%client);
if($firstJoin) {
$firstJoin = false;
schedule(0,0,eval,"$EnvGuiServer::DayLength=86400");
}
}
};
activatePackage(autoAdminCheck);

Well, gamemode.txt isn't supposed to execute it. It gets executed automatically because it's a server.cs in a server add-on.
i think that, when a gamemode has it's own server.cs, the gamemode.txt has to include the server.cs in it in the form of adding
Code: [Select]
ADDON Gamemode_Castle_Crashersto the gamemode.txt

thank you Pie Crust and Advance Bot for your efforts with this work around

i added a server.cs with the code you both come up with together
but the problem with the day cycle is still there

i looked at the console, and found this error with the server.cs

Code: [Select]
Syntax error in input.
eval error >> $EnvGuiServer::DayLength=86400

He forgot the ;

Also in a gamemode the server.cs is executed automatically. No need to add the same gamemode



$EnvGuiServer::DayLength=86400;
thank you for your help

the server.cs has no syntax error but the problem still persists

augh

In the server.cs, instead of using Pie Crust's code since there's no reason to use a admin check, use this code since it's only being executed once and performs the function once the game loads all the add-ons plus 100 milliseconds.

Code: server.cs (6 lines)
function doTheLoop()
{
    $EnvGuiServer::DayLength = 86400;
    DayCycle.setDayLength($EnvGuiServer::DayLength);
}
schedule(100, 0, doTheLoop);




In the server.cs, instead of using Pie Crust's code since there's no reason to use a admin check, use this code since it's only being executed once and performs the function once the game loads all the add-ons plus 100 milliseconds.

-code stuffs-

it actually worked! holy damn! thank you very much!

thank you both for helping me with this!
even though it's only a workaround, thank you both