AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [ANY?] Timescale Windows Fix (https://forums.alliedmods.net/showthread.php?t=324264)

bakugo 05-10-2020 19:09

[ANY?] Timescale Windows Fix
 
3 Attachment(s)
This plugin allows host_timescale changes to work on Windows servers without having to turn on sv_cheats. This has always worked fine on Linux servers, but there is some extra engine code that only exists on Windows for some reason that prevents the value from being applied if cheats are disabled.

Keep in mind that you will still need to set a fake sv_cheats 1 value on the client using SendConVarValue for timescale to work without desync issues. This will not allow the client to use server-side cheat commands like noclip, but they will be able to use clientside cheats such as mat_wireframe. These clientside cheats will automatically disable themselves if you set the fake sv_cheats value back to 0.

An example of an existing plugin that benefits from this fix is Freak Fortress 2. Ninja Spy's slowmo rage normally does not work properly on Windows servers, but with this, it will.

This has only been tested in TF2, but in theory it should work for other games with the same/similar engine.


Installation
  • Put timescale_win_fix.smx in the plugins folder
  • Put timescale_win_fix.txt in the gamedata folder

XGAK 05-14-2020 04:19

Re: [ANY?] Timescale Windows Fix
 
Nice work. Thanks for the fix!

axelnieves2012 01-24-2021 16:32

Re: [ANY?] Timescale Windows Fix
 
Seem not working on L4D1.

Where are the instructions??
I installed your plugin+gamedata,
restarted my server,
sm_cvar host_timescale 2.0

And nothing happened.
(Windows 10, L4D1 Dedicated Server)

axelnieves2012 01-24-2021 17:00

Re: [ANY?] Timescale Windows Fix
 
2 Attachment(s)
SOLVED. I had to make an extra plugin but it works now.
Here is the source if anyone needs it.
Works pretty fine on L4D1 now.
Nice work.
Maybe I would have to check if client disables sv_cheats on his console.
I wonder whats happens if one client overrides "sv_cheats 1" while other clients are in "slow camera" (host_timescale 0.5).

PHP Code:

#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.0"

public Plugin myinfo =
{
    
name "Host Time Scale",
    
author "Axel Juan Nieves",
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

ConVar host_timescalesv_cheats;

public 
void OnPluginStart()
{
    
host_timescale FindConVar("host_timescale");
    
sv_cheats FindConVar("sv_cheats");
    
HookConVarChange(host_timescaleTimescaleChange);
}

public 
void OnClientPutInServer(int client)
{
    if ( 
IsFakeClient(client) )
        return;
    if ( 
GetConVarFloat(host_timescale)!=1.0 )
        
SendConVarValue(clientsv_cheats"1");
    else
        
SendConVarValue(clientsv_cheats"0");
}

public 
void OnClientDisconnect(int client)
{
    if ( 
IsFakeClient(client) )
        return;
    
SendConVarValue(clientsv_cheats"0");
}

public 
void TimescaleChange(Handle convar, const char[] oldValue, const char[] newValue)
{
    for (
int client=1client<=MaxClientsclient++)
    {
        if ( 
IsFakeClient(client) )
            continue;
        if ( 
GetConVarFloat(host_timescale)!=1.0 )
            
SendConVarValue(clientsv_cheats"1");
        else
            
SendConVarValue(clientsv_cheats"0");
    }




All times are GMT -4. The time now is 06:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.