Raised This Month: $51 Target: $400
 12% 

[L4D2] Map-Specific Alterations to Versus Completion Score


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DannBo
Junior Member
Join Date: Apr 2012
Old 05-24-2022 , 18:51   [L4D2] Map-Specific Alterations to Versus Completion Score
Reply With Quote #1

I'm trying to write a simple plugin that changes the maximum completion score in versus for specific custom maps, such as Warcelona, which only grants players a maximum score of 400 (not including survival bonus) on all maps.

Basically, when a specified map loads it calls L4D_SetVersusMaxCompletionScore from <left4dhooks>

I tried the following (based on an old suggestion here):

PHP Code:
public void OnMapStart() {

    
decl String:Map[64];
    
GetCurrentMap(Mapsizeof(Map));
    
//Warcelona
    
if(StrEqual(Map"srocchurch"))
    {
        
PrintToServer("[SM] Scoring Fixed");
        
L4D_SetVersusMaxCompletionScore(500);
    }
    if(
StrEqual(Map"plaza_espana"))
    {
        
PrintToServer("[SM] Scoring Fixed");
        
L4D_SetVersusMaxCompletionScore(600);
    }
    if(
StrEqual(Map"maria_cristina"))
    {
        
PrintToServer("[SM] Scoring Fixed");
        
L4D_SetVersusMaxCompletionScore(700);
    }
    if(
StrEqual(Map"mnac"))
    {
        
PrintToServer("[SM] Scoring Fixed");
        
L4D_SetVersusMaxCompletionScore(800);
    }

It prints the string to the server successfully but the L4D_SetVersusMaxCompletionScore doesn't appear to accomplish anything. Is there something else that needs to be called to allow the server to change the score, or is OnMapStart() too early to use L4D_SetVersusMaxCompletionScore?

Last edited by DannBo; 05-24-2022 at 19:00. Reason: Formatting, Title Clarification
DannBo is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 05-24-2022 , 19:12   Re: [L4D2] Map-Specific Alterations to Versus Completion Score
Reply With Quote #2

try changing on round_start, also try running the game late game and check if that does change the score.
__________________
Marttt is offline
DannBo
Junior Member
Join Date: Apr 2012
Old 05-24-2022 , 21:00   Re: [L4D2] Map-Specific Alterations to Versus Completion Score
Reply With Quote #3

It appears round_start is still too early as L4D_GetVersusMaxCompletionScore() reveals the score at that point is still 0 before I try to change it, which means it hasn't been set yet. And so it undoes anything I do at that stage.

I tried to rig L4D_SetVersusMaxCompletionScore() to a command as shown below:

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <left4dhooks>

#define PLUGIN_VERSION  "0.0.1"

int vscore;
int vinput;

public 
Plugin:myinfo 
{
    
name "L4D2 Versus Scoring Fixer",
    
author "DannBo",
    
description "Fixes Broken Scoring on Select Custom Maps",
    
version PLUGIN_VERSION,
    
url "http://therocinante.clanservers.com/motd.html"
}

public 
void OnPluginStart()
{
    
CreateConVar("sm_vscore_fixer_version"PLUGIN_VERSION"Get Plugin Version"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
RegConsoleCmd("sm_vscore_set"cmdScoreSet"Set Score Completion");
}

public 
Action:cmdScoreSet(clientargs)
{
        
L4D_NotifyNetworkStateChanged();
        
         new 
String:buffer[32];
          
GetCmdArg(1buffersizeof(buffer));
          
vinput StringToInt(buffer);
          
          
L4D_SetVersusMaxCompletionScore(vinput);
          
        
vscore L4D_GetVersusMaxCompletionScore();
        
PrintToChat(client"Versus Completion Score is now %d"vscore);
        
        return 
Plugin_Handled;

And it sort of works. If I use the command once I am connected to the server, it sets the scores appropriately for both teams, however, the UI still shows the maximum as what it was set to before. So if the default is 400, and I set it to 500, at the end it shows 500 / 400 for full completion, rather than updating the UI to show 500 / 500.

While this works functionally, it would be nice to have an event to hook it too that's after round_start, rather than having to call the command each time I want to do it after I'm connected. Is there an event I could hook it too where it would also reflect fully in the UI?
DannBo is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-25-2022 , 05:45   Re: [L4D2] Map-Specific Alterations to Versus Completion Score
Reply With Quote #4

Maybe you can use the "Info Editor" plugin forward "OnGetMissionInfo" to set the score at that moment using the Left4DHooks native. It seems setting the key value "VersusCompletionScore" does not change the value so the native is still required.
__________________
Silvers is offline
DannBo
Junior Member
Join Date: Apr 2012
Old 05-25-2022 , 16:27   Re: [L4D2] Map-Specific Alterations to Versus Completion Score
Reply With Quote #5

Added this:

PHP Code:
#include <l4d_info_editor>

public void OnGetMissionInfo()
{
    
    new 
String:gamemodecvar[16];
    
decl String:mapname[64];
    
    
GetConVarString(FindConVar("mp_gamemode"), gamemodecvarsizeof(gamemodecvar));
    
    if (
StrEqual(gamemodecvar,"versus"))
    {
        
GetCurrentMap(mapnamesizeof(mapname));
        
L4D_NotifyNetworkStateChanged();
        
vscore L4D_GetVersusMaxCompletionScore();
        
PrintToServer("[SM] Versus Score is %d"vscore);
        
        
//Warcelona
        
if(StrEqual(mapname"srocchurch"))
        {
            
L4D_SetVersusMaxCompletionScore(500);
            
vscore L4D_GetVersusMaxCompletionScore();
            
PrintToServer("[SM] Score Fixed To %d"vscore);
        }
        if(
StrEqual(mapname"plaza_espana"))
        {
            
L4D_SetVersusMaxCompletionScore(600);
            
vscore L4D_GetVersusMaxCompletionScore();
            
PrintToServer("[SM] Score Fixed To %d"vscore);
        }
        if(
StrEqual(mapname"maria_cristina"))
        {
            
L4D_SetVersusMaxCompletionScore(700);
            
vscore L4D_GetVersusMaxCompletionScore();
            
PrintToServer("[SM] Score Fixed To %d"vscore);
        }
        if(
StrEqual(mapname"mnac"))
        {
            
L4D_SetVersusMaxCompletionScore(800);
            
vscore L4D_GetVersusMaxCompletionScore();
            
PrintToServer("[SM] Score Fixed To %d"vscore);
        }
    }

Like with using the console command, this works functionally but isn't reflected in the UI in the scoring and the scaling of the progress bar.



For now I can include a PrintToChatAll that informs players of the true max versus scoring to help alleviate confusion. I'm not sure I can think of a way to specifically target a change with the UI...
DannBo is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 05-26-2022 , 03:52   Re: [L4D2] Map-Specific Alterations to Versus Completion Score
Reply With Quote #6

It's client-side. Only way for the same changes to fully reflect on clients would be making them download different versions of the mission files with the same values set for every "VersusCompletionScore" key value.

Last edited by cravenge; 05-26-2022 at 03:54.
cravenge is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:33.


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