Scags / TF2Classic-Tools

Basic tools for TF2Classic dedicated server development
7 stars 11 forks source link

Map time limit #1

Open NickCloudAT opened 4 years ago

NickCloudAT commented 4 years ago

Hey, I already love what you did here and I know its WIP.. I would still like to report this to you, maybe you will be able to do something about that..

In TF2C the Map Time Limit of the Game itself and the one from Sourcemod get out of sync as soon as the TimeLimit changes from the game itself (for example if you vote Extend Map Time). This leads to the mapchooser plugin not correctly doing votes etc..

As an example, the sourcemod hook OnMapTimeLeftChanged is not even called in TF2c.

Scags commented 4 years ago

I see how this is an issue. Unfortunately, the only way you can solve this, instead of using ExtendMapTimeLimit, is to set the cvar directly.

public void OnPluginStart()
{
    RegServerCmd("sm_extend", CmdExtend);
    RegServerCmd("sm_extend2", CmdExtend2);
}

public Action CmdExtend(int args)
{
    int extend = 15;
    if (args)
    {
        char arg[8]; GetCmdArg(1, arg, sizeof(arg));
        extend = StringToInt(arg);
    }

    PrintToServer("Extended -> %s", (ExtendMapTimeLimit(extend) ? "success" : "failure"));
}

public Action CmdExtend2(int args)
{
    int extend = 15;
    if (args)
    {
        char arg[8]; GetCmdArg(1, arg, sizeof(arg));
        extend = StringToInt(arg);
    }

    PrintToServer("Extended2 -> %d", FindConVar("mp_timelimit").IntValue);
    FindConVar("mp_timelimit").IntValue = FindConVar("mp_timelimit").IntValue + extend;
}

public void OnMapTimeLeftChanged()
{
    PrintToServer("mp_timelimit = %d", FindConVar("mp_timelimit").IntValue);
}

Which provided this output:

NickCloudAT commented 4 years ago

I see.. But this will probably still lead to GetMapTimeLeft giving out a wrong number, wont it? Because, if you still vote for a Map Extend, GetMapTimeLeft will not get reseted back.

Scags commented 4 years ago

You can try, I'm not sure. GetMapTimeLeft just reads off of the start time and mp_timelimit so it could possibly work.

NickCloudAT commented 4 years ago

Well I now tried.. Unfortunately it does not work :/

GetMapTimeLeft will not reset if a Extend Map Time vote is called.. It is also not resetet/extendet when a Scramble and Restart vote is called.

Scags commented 4 years ago

Idk what else to tell you. You could delta-time it. For example store the start time of the map with OnMapStart and then do math based off of mp_limelimit in various functions.