NotJustin / SkillAutoBalance

12 stars 3 forks source link

[Error] Force join spectate not work. #24

Closed WhyFaust closed 4 years ago

WhyFaust commented 4 years ago

As the name implies, it does not automatically connect for the observer command when it is set in !settings. cfg file:

// This file was auto-generated by SourceMod (v1.10.0.6488)
// ConVars for plugin "skillautobalance-ncrpg.smx"

// 0 = Disabled. Otherwise, balance  teams when 'N' players join/leave the server. Requires sab_balanceafternrounds to be enabled
// -
// Default: "0"
// Minimum: "0.000000"
sab_balanceafternplayerschange "0"

// 0 = Disabled. Otherwise, after map change balance teams when 'N' rounds pass. Then balance based on team win streaks
// -
// Default: "0"
// Minimum: "0.000000"
sab_balanceafternrounds "0"

// If enabled, teams will be rebalanced at the end of every round
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_balanceeveryround "1"

// 0 = Don't block. 1 = Block, can join spectate, must rejoin same team. 2 = Block completely (also disables teammenu and chatchangeteam commands like !join !spec)
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "2.000000"
sab_blockteamswitch "1"

// When teams are being balanced, 1 = Bots are players (bots have points/KDR), 0 = Bots are outliers (bots do not have points/KDR)
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_botsareplayers "0"

// Enable joining teams by chat commands '!join, !play, !j, !p, !spectate, !spec, !s (no picking teams)
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_chatchangeteam "0"

// The amount to subtract from a streak if UseDecay is true. In other words, the ratio of a team's round wins to the opposing team's must be greater than this number in order for a team balance to eventually occur.
// -
// Default: "1.5"
// Minimum: "1.000000"
sab_decayamount "1.5"

// Allow plugin to display messages in the chat
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_displaychatmessages "0"

// Show the messages in chat when a player switches team?
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_enableplayerteammessage "0"

// Add 'force balance' to 'server commands' in generic admin menu
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_forcebalance "1"

// 0 = Disabled, 1 = Optional (!settings), 2 = Forced. Force clients to join a team upon connecting to the server. Always enabled if both sab_chatchangeteam and sab_teammenu are disabled
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "2.000000"
sab_forcejointeam "1"

// Living players are kept alive when their teams are changed
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_keepplayersalive "1"

// See sab_messagetype for info
// -
// Default: "white"
sab_messagecolor "white"

// How this plugin's messages will be colored in chat. 0 = no color, 1 = color only prefix with sab_prefixcolor, 2 = color entire message with sab_messagecolor, 3 = color prefix and message with both sab_prefixcolor and sab_messagecolor
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "3.000000"
sab_messagetype "0"

// The amount of players not in spectate must be at least this number for a balance to occur
// -
// Default: "7"
// Minimum: "2.000000"
sab_minplayers "5"

// Amount of wins in a row a team needs before autobalance occurs
// -
// Default: "6"
// Minimum: "0.000000"
sab_minstreak "3"

// The prefix for messages this plugin writes in the server
// -
// Default: "[SAB]"
sab_prefix "[SAB]"

// See sab_messagetype for info
// -
// Default: "white"
sab_prefixcolor "white"

// Value to multiply IQR by. If your points have low spread keep this number. If your points have high spread change this to a lower number, like 0.5
// -
// Default: "1.5"
// Minimum: "0.100000"
sab_scale "1.5"

// Randomize teams instead of using a skill formula
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_scramble "0"

// Add 'set player team' to 'player commands' in generic admin menu
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_setteam "1"

// Whether to enable or disable the join team menu.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_teammenu "1"

// If 1, subtract sab_decayamount from a team's streak when they lose instead of setting their streak to 0
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
sab_usedecay "1"
NotJustin commented 4 years ago

Fixed, thanks for telling me.

WhyFaust commented 4 years ago

Simply changing the version will fix the problem?)). Well, the binary is probably normal, I guess.

NotJustin commented 4 years ago

You do not need to change anything besides version, correct.

WhyFaust commented 4 years ago

I mean, you've only changed the version of the commits and the rest of the code isn't xD.

NotJustin commented 4 years ago

AAAAAAAH you are right, I forgot to drag the other folder in.

edit: here it is https://github.com/NotJustin/SkillAutoBalance/commit/b08b651c65f92752c1c76f60609a3f5a007ac490

The numbers before were backward even though it "looked" correct. Now, the numbers are correct but they look backward. It works. It is just ugly. I will change it later to make more sense.

WhyFaust commented 4 years ago

By the way, now the game, which has a point 1 drag when connecting to the spectators, because of this there are small problems on the server, as I have a maximum of 2 spectators, and if I go ahead and they will throw for the spectators(take all seats), then I'm thrown for the team, although I have an auto-connection for the spectator.

WhyFaust commented 4 years ago

I didn't quite understand what I wrote myself. I'll write it more clearly: All in all. The player has a 100% auto-connection per team (not spectator) in the settings, because I have a blocked command sm_settings. But they are still thrown when you connect for spectators, I do not know what it has to do with. Because of that I can't connect to the spectators myself, because the command is full.

NotJustin commented 4 years ago

The plugin creates a cookie for each client when they join your server for the first time. It is never assigned a value unless they pick something in settings. You blocked that option, so they should not be able to set their cookie. All of these players have empty cookie values. When it is empty, I set it so their preference by default is to join spectator.

You want this to put them on a team by default instead? Maybe I can add a convar to allow you to set the default value of the cookie.

For now, it is in here "SkillAutoBalance/funcs_public.sp"

public void OnClientCookiesCached(int client)
{
    char buffer[24];
    GetClientCookie(client, g_hForceSpawn, buffer, sizeof(buffer));
    // 0 is spectate, 1 is join a team
    if (strlen(buffer) > 0)
    {
        g_iClientForceJoinPreference[client] = StringToInt(buffer);
    }
    else
    {
        //this puts them in spectate. Change to 1 to put them on a team. Maybe I replace this with a convar instead.
        g_iClientForceJoinPreference[client] = 0;
    }
}

Did I understand correctly? If I did, I am confused. If you disable settings, why not set sab_forcejointeam 2 so that it does not use cookies?

The other thing you might be saying is, you want them to be put on UNASSIGNED team so they don't fill spectator slots? If so, I do not like that idea (in my experience, it is very confusing for players)

WhyFaust commented 4 years ago

Ahh... Yeah, well, I'd like the default value to be 1, not the spectators. I just don't get it, because when someone writes !settings, they have the default value of the first item on, and the second item(s) is off. That's why I said so. I put a value of 1 in the config and block the command only to be personally thrown by spectators, because I join my server and minimize the game to work in filezilla or elsewhere. Well, it would be really more logical for the default value to be 1 instead of 0.

NotJustin commented 4 years ago

That is likely my mistake, I rushed this implementation originally. I will rework this later.