Raised This Month: $ Target: $400
 0% 

[L4D2] Change Versus Map Score


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
larrybrains
Senior Member
Join Date: May 2017
Old 05-28-2018 , 15:11   [L4D2] Change Versus Map Score
Reply With Quote #1

I am looking for a way to change some specific map completion scores on my server. Will it work to just make a map_name.cfg file in /maps/cfg and add the following?

Code:
sm_cvar VersusCompletionScore 800
Or do I need to use a function from left4downtown or something?

Any help on this is much appreciated, thanks!
larrybrains is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-28-2018 , 15:47   Re: [L4D2] Change Versus Map Score
Reply With Quote #2

PHP Code:
    GameRules_SetProp("m_iSurvivorScore"040true);
    
GameRules_SetProp("m_iSurvivorScore"041true);
    
GameRules_SetProp("m_iCampaignScore"040true);
    
GameRules_SetProp("m_iCampaignScore"041true);
    
GameRules_SetProp("m_iChapterScore"040true);
    
GameRules_SetProp("m_iChapterScore"041true);
    
GameRules_SetProp("m_iChapterDamage"040true);
    
GameRules_SetProp("m_iChapterDamage"041true);

    
GameRules_SetProp("m_iScavengeTeamScore"040true);
    
GameRules_SetProp("m_iScavengeTeamScore"041true);
    
GameRules_SetProp("m_iScavengeTeamScore"042true);
    
GameRules_SetProp("m_iScavengeTeamScore"043true);
    
GameRules_SetProp("m_iScavengeTeamScore"044true);
    
GameRules_SetProp("m_iScavengeTeamScore"045true);
    
GameRules_SetProp("m_iScavengeTeamScore"046true);
    
GameRules_SetProp("m_iScavengeTeamScore"047true);
    
GameRules_SetProp("m_iScavengeTeamScore"048true);
    
GameRules_SetProp("m_iScavengeTeamScore"049true);

    
GameRules_SetProp("m_iScavengeMatchScore"040true);
    
GameRules_SetProp("m_iScavengeMatchScore"041true);
    
GameRules_SetPropFloat("m_flTeamRoundTime"0.00true);
    
GameRules_SetPropFloat("m_flTeamRoundTime"0.01true);
    
GameRules_SetProp("m_iVersusDistancePerSurvivor"040true);
    
GameRules_SetProp("m_iVersusDistancePerSurvivor"041true);
    
GameRules_SetProp("m_iVersusDistancePerSurvivor"042true);
    
GameRules_SetProp("m_iVersusDistancePerSurvivor"043true);
    
GameRules_SetProp("m_iVersusDistancePerSurvivor"044true);
    
GameRules_SetProp("m_iVersusDistancePerSurvivor"045true);
    
GameRules_SetProp("m_iVersusDistancePerSurvivor"046true);
    
GameRules_SetProp("m_iVersusDistancePerSurvivor"047true);

    
GameRules_SetProp("m_iVersusSurvivorDeathDistance", -140true);
    
GameRules_SetProp("m_iVersusSurvivorDeathDistance", -141true);
    
GameRules_SetProp("m_iVersusSurvivorDeathDistance", -142true);
    
GameRules_SetProp("m_iVersusSurvivorDeathDistance", -143true);
    
GameRules_SetProp("m_iVersusSurvivorDeathDistance", -144true);
    
GameRules_SetProp("m_iVersusSurvivorDeathDistance", -145true);
    
GameRules_SetProp("m_iVersusSurvivorDeathDistance", -146true);
    
GameRules_SetProp("m_iVersusSurvivorDeathDistance", -147true);

    
GameRules_SetProp("m_iVersusSurvivalMultiplier"040true);
    
GameRules_SetProp("m_iVersusSurvivalMultiplier"041true);
    
GameRules_SetProp("m_iVersusDefibsUsed"040true);
    
GameRules_SetProp("m_iVersusDefibsUsed"041true);
    
GameRules_SetProp("m_bInIntro"040true);
    
GameRules_SetPropFloat("m_flRoundStartTime"0.00true);
    
GameRules_SetPropFloat("m_flRoundEndTime"0.00true);
    
GameRules_SetPropFloat("m_flAccumulatedTime"90.00true);
    
GameRules_SetProp("m_nRoundNumber"040true);
    
GameRules_SetProp("m_nRoundLimit"340true);

    
GameRules_SetProp("m_iWinningTeamNumber"040true);
    
GameRules_SetProp("m_iWinningTeamNumber"041true);
    
GameRules_SetProp("m_iWinningTeamNumber"042true);
    
GameRules_SetProp("m_iWinningTeamNumber"043true);
    
GameRules_SetProp("m_iWinningTeamNumber"044true);
    
GameRules_SetPropFloat("m_flTeamBestRoundTime"0.00true);
    
GameRules_SetPropFloat("m_flRoundDuration"0.00true);
    
GameRules_SetProp("m_nScavengeItemsRemaining"040true);
    
GameRules_SetProp("m_nScavengeItemsGoal"040true);
    
GameRules_SetProp("m_bAreTeamsFlipped"040true);
    
GameRules_SetProp("m_bInSecondHalfOfRound"040true);
    
GameRules_SetProp("m_bIsTransitioningToNextMap"040true);
    
GameRules_SetProp("m_bIsVersusVoteRestarting"040true);
    
GameRules_SetProp("m_iSacrificeEscapees"040true); 
From a test plugin, I forgot the results.
__________________
Silvers is offline
midnight9
Senior Member
Join Date: Nov 2012
Old 05-28-2018 , 15:52   Re: [L4D2] Change Versus Map Score
Reply With Quote #3

I belive you do have to use native L4D_SetVersusMaxCompletionScore(score);

You could try something like this:
Code:
#include <left4downtown>

public OnMapStart() {

	decl String:Map[64];
	GetCurrentMap(Map, sizeof(Map));
	if(StrEqual(Map, "c1m1_hotel))
	{
		L4D_SetVersusMaxCompletionScore(500); // replace 500 with desired value
	}
}
midnight9 is offline
PatPeter
Member
Join Date: Apr 2009
Location: Chicago
Old 02-08-2025 , 03:37   Re: [L4D2] Change Versus Map Score
Reply With Quote #4

Quote:
Originally Posted by Silvers View Post
From a test plugin, I forgot the results.
EDIT: Turns out I was trying to do something very similar... 14 years ago! https://forums.alliedmods.net/showthread.php?t=140230

I am trying to write a plugin that awards 200 points to each survivor that escapes in the Versus finale. In my community, if the other team surpasses the 900 points that can be attained on the finale (think 2150 points to 1200), then the other team does not want to play and finish the finale. This would incentivize people to keep playing as long as the other team doesn't have survivors escape.

How do I figure out which index of m_iSurvivorScore corresponds to each survivor?

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

#pragma semicolon 1

public Plugin myinfo = 
{
    name = "L4D2 Versus Finale Bonus",
    author = "PatPeter",
    description = "Awards 200 additional points per survivor escaping in a Versus Finale",
    version = "1.0",
    url = ""
};

public void OnPluginStart()
{
    // Hook into the finale_vehicle_leaving event (this means a survivor escaped)
    HookEvent("finale_vehicle_leaving", Event_FinaleVehicleLeaving, EventHookMode_Post);
}

// Called when a survivor leaves in the escape vehicle
public void Event_FinaleVehicleLeaving(Event event, const char[] name, bool dontBroadcast)
{
    int userid = event.GetInt("userid"); // Get the escaping player's User ID
    int client = GetClientOfUserId(userid); // Convert User ID to entity index

    if (client > 0 && IsClientInGame(client))
    {
        // Get current survivor team score
        int survivorScore = GameRules_GetProp("m_iSurvivorScore", 4, HOW_DO_I_GET_THIS_VALUE);
        
        // Award 200 extra points
        survivorScore += 200;

        // Set new score for the survivor team
        GameRules_SetProp("m_iSurvivorScore", survivorScore, 4, HOW_DO_I_GET_THIS_VALUE, true);

        // Get the player's name
        char name[MAX_NAME_LENGTH];
        GetClientName(client, name, sizeof(name));

        PrintToChatAll("[L4D2] %s escaped! +200 bonus points awarded to the Survivors.", name);
    }
}
__________________
SourceMod = Linux
EventScripts = Windows
Mani = Mac OS

Last edited by PatPeter; 02-08-2025 at 03:41.
PatPeter is offline
Reply


Thread Tools
Display Modes

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 20:08.


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