Author Topic: Silently setting timescale [Solved]  (Read 1523 times)

I've searched and found that setTimescale(%num); commandToAll('timescale', %num); should work. However after testing, I found that setTimescale does nothing in a dedicated server. The clients are still getting their timescale set correctly.
Note: Doing this on a non-dedicated server seems to work, I think since your client is being told to modify the timescale, its doing it to the server as well.
setTimescale is a function, timescale isn't.
Port said here to make sure mainServer.cs.dso is being executed. When starting up the dedicated, I see a message something like "Loading mainServer.cs", so i'm pretty sure thats working.

I have attempted to package commandToAll and commandToClient to stop the "Blockhead changed the timescale to #" message, however serverCmdTimescale doesnt call either. And I think gameConnection::chatMessage calls commandToClient, so I cant think what else to package to hide the message.

Id prefer to do this without a client sided mod, however its looking like that is the easiest way.

Any help is appreciated.

Edit: Been looking through v0002, and i cant find any mention of timescale. It might not even of been implemented at that time, so that doesn't help me. I did find that all the messaging functions i found called commandToClient, which I doubt is packageable. I will give it a try when my dedicated is working again anyway.
« Last Edit: August 24, 2013, 10:38:19 AM by boodals 2 »

This is the only way you should be doing it. If this doesn't work on dedicated servers, something is really wrong. I haven't tested it myself on dedicated servers, but yeah, I don't see any reason for why it shouldn't work.

setTimeScale(timeScale);
commandToAll('timeScale', timeScale);

I haven't tested it myself on dedicated servers, but yeah, I don't see any reason for why it shouldn't work.

That's the weird part. There's no reason that I've been able to find. I've even gone as far as testing it on a completely vanilla Blockland dedicated server. It still didn't work.

Of course, if it's extremely important to do it silently, you can use the extremely hacky method of:

  • Create an AIConnection, make it an admin and keep track of it.
  • Create a package which overwrites messageAll, but don't activate it.
  • Calling serverCmdSetTimeScale with the client object and a timescale value. Activate/deactivate the above package before/after calling the function.

Oooh, how could I forget messageAll. Derp. Ill try doing what you said, if my dedi is working again that is..

Huzzah, it works. Code if anyone wants it.
Code: [Select]
function setTimescaleFix(%num)
{
activatePackage(setTimescaleFixPackage);
if(!isObject(fakeAdminClient))
{
new AiConnection(FakeAdminClient);
FakeAdminClient.isAdmin = 1;
FakeAdminClient.isSuperAdmin = 1; //Not really needed for us, but since fakeAdminClient is used in other mods, best to have it SA.
}

serverCmdTimescale(fakeAdminClient, %num);
deactivatePackage(setTimescaleFixPackage);
}
package setTimescaleFixPackage
{
function messageAll(%type, %msg, %a, %b, %c, %d, %e, %f, %g, %h, %i, %j, %k, %l, %m, %n, %o, %p)
{
//Overwrite the function so the message isnt displayed
return;
}
};

Well.. what you posted will just block out all messageAlls. That's no bueno, tons of functions use messageAll.

He's doing it only in that function, it's fine.

Well.. what you posted will just block out all messageAlls. That's no bueno, tons of functions use messageAll.
The package is only activated when serverCmdTimescale is being run, right afterwards it gets deactivated. Read the code before you point out flaws.

I would move the activatePackage call to the line immediately before the servercmdtimescale call, instead of having stuff between them

I would move the activatePackage call to the line immediately before the servercmdtimescale call, instead of having stuff between them
Yeah, it shouldn't effect anything, but I guess it makes more sense when reading it to have it there, plus there's always OCD..