Author
|
Message
|
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
|
08-09-2019
, 19:00
[L4D2/CS:GO/TF2/NMRiH] VScript File Replacer (1.17) [28-Jan-2024]
|
#1
|
About:- Provides a config to specify which VScript files to override.
- You can replace the whole script or search and replace specific strings.
- Supports RegEx matching for filenames and for matching strings within the VScripts.
- Some games or maps will have embedded and possibly encrypted scripts preventing any reasonable method to modify them. This plugin makes that happen.
Supported Games:- CS:GO
- L4D2
- NMRiH
- TF2
- Can be extended to other games which use VScripts. Please request if required.
Related Plugins:
Thanks:- "Peace-Maker" - Fixing dHooks SetParamString.
- "Lux" - Testing
- "Dragokas" - Testing
- "Mr. Man" - Testing
Admin Commands:- Requires "z" - ADMFLAG_ROOT flag
PHP Code:
sm_vs_dump // Dumps all found VScripts from the servers /scripts/vscripts/ file system to /scripts/vscripts/vscripts_dump/. Automatically decodes if required.
sm_vs_encrypt // Usage: sm_vs_encrpt <filename.nut>. Encode the specified script, must be inside the servers /scripts/vscripts/ folder, include the extension.
sm_vs_exec // Usage: sm_vs_exec <filename>. Executes a VScript file. This is a wrapper to the script_execute command. Can recompile plugin to use logic_script instead.
sm_vs_file // Usage: sm_vs_file <filename>. Extracts the specified VScript from the Valve file system to the servers /scripts/vscripts/vscripts_dump/ folder. Automatically decodes if required.
sm_vs_list // Show data config tree of modified scripts for the current map.
sm_vs_listen // Toggle printing to server console the names of scripts being executed.
sm_vs_reload // Reloads the data config. This also replaces files in the override folder.
ConVars:
Saved to vscript_replacer.cfg in your servers \cfg\sourcemod\ folder.
PHP Code:
// 0=Off. 1=Print to server. 2=Print to chat. 4=Verbose logging. Add numbers together.
vscript_replacer_debug "0"
// VScript File Replacer plugin version.
vscript_replacer_version
Forward for developers:
Spoiler
PHP Code:
/**
* Triggered when a VScript is being executed, allowing you to block or change filename.
* All script names will use lowercase letters.
*
* @param sScript VScript filename being executed. Does not include the .nuc or .nut extension.
* @param sOverride VScript being used to override the original script when override is true.
* @param bOverride True when the sScript is being overwritten by the sOverride value.
*
* @return Plugin_Handled to block the script from being executed.
* Plugin_Changed to change the script and use your provided sOverride value.
* Plugin_Continue to continue without changes.
*/
forward Action OnVScriptExecuted(const char[] sScript, char sOverride[PLATFORM_MAX_PATH], bool bOverride);
Example script:
PHP Code:
public Action OnVScriptExecuted(const char[] sScript, char sOverride[PLATFORM_MAX_PATH], bool bOverride)
{
// Debug print
PrintToServer("VSCRIPT FORWARD [%s] [%s] [%d]", sScript, sOverride, bOverride);
// Overwrite script example.
if( strcmp(sScript, "test1") == 0 || (bOverride && strcmp(sOverride, "test1") == 0) )
{
sOverride = "test2";
return Plugin_Changed;
}
// Block script example.
if( strcmp(sScript, "test1") == 0 )
{
return Plugin_Handled;
}
return Plugin_Continue;
}
Config:- Plugin data config saved to \addons\sourcemod\data\vscripts_override.cfg.
Here is an example demonstrating various features and techniques.
Spoiler
PHP Code:
// When a script is matched and modified they are saved to your servers /scripts/vscripts/vscripts_overrides/ folder.
// Do not save files there, they will be overwritten.
// The extension ".nut" or ".nuc" shouldn't be added to names below.
// This is an example script with comments on the features provided, delete the sections you don't need.
// For L4D2 I recommend keeping the "jukebox_dlc1", "jukebox_main" and "helms_deep" sections.
"vscript_replacer"
{
// /* CS:GO + ANY: delete the // on this line to comment out everything and start from fresh.
// All maps
".+"
{
// Matches all script names.
// ".+"
// {
// Script name will be matched with RegEx.
// 1=RegEx match script name. 2=RegEx search string for replacement. 3=Use RegEx for both. Delete line to not use RegEx.
// "regex" "1"
// }
// L4D2: No more jukebox debug spam!
"jukebox_dlc1"
{
// Find and replace the string literally, you must always escape any quotes or backslashes: " with \" and \ with \\
// Strings must be less than 8192 characters. Use the file "override" keyvalue for anything longer.
"DBG <- ::JUKEBOX_DEBUG <- true" "DBG <- ::JUKEBOX_DEBUG <- false"
}
"jukebox_main"
{
"DBG <- ::JUKEBOX_DEBUG <- true" "DBG <- ::JUKEBOX_DEBUG <- false"
}
}
// Map name to activate on. Supports RegEx matching. For RegEx testing use: https://regex101.com/ or any similar site.
// This matches "c1m1_" to "c99m99_" for example, all Valve maps in L4D2.
"c[0-9]m[0-9]_.+"
{
// VScript filename to override, searches the Valve file system and gamedir.
// This matches the script "some_vscript_file".
"some_vscript_file"
{
// The "override" key is reserved for replacing the whole VScript file with a custom one, if both files exist.
// The specified value must point to a filename in your servers /scripts/vscripts/vscripts_custom/ folder.
// The file is copied to the your servers /scripts/vscripts/vscripts_override/ folder.
// Any script using a custom override will take priority when the script name is also matched using RegEx.
"override" "my_vscript_file"
// Can still use other keys to find and replace strings within the override file. Even when matched with RegEx.
"some_random_var = false;" "some_random_var = true;"
}
}
// L4D2: This map was stolen by a megalomaniac. It used to execute the "KillServer" command when detecting MetaMod or SourceMod.
// Why block the communities plugins? We will always reverse.
"helms_deep"
{
// Main script
"helms_deep_.+_survival"
{
// Matches the script name and strings with RegEx.
"regex" "3"
// Replace all string occurrences:
// RegEx replace all matched SteamIDs with Gabe's SteamID.
"(STEAM_[0-5]:[0-1]:[0-9]+)" "STEAM_1:0:11101" // Your donators can fuck off too.
}
}
}
Changes:
Code:
1.17 (28-Jan-2024)
- Fixed memory leak caused by clearing StringMap/ArrayList data instead of deleting.
1.16 (10-Mar-2023)
- Changed command "sm_vs_dump" to display the number of scripts dumped.
- Fixed error when no VScript files or directories exist. Thanks to "Sreaper" for reporting.
1.15 (20-Dec-2022)
- Added support for Team Fortress 2.
- GameData file and plugin updated.
1.14 (15-Oct-2022)
- Added an include file for other plugins to require this plugin.
- Added registering the plugin library as "vscript_replacer" for plugins to detect.
1.13 (15-Jul-2022)
- Increased buffer size. Thanks to "Psyk0tik" for reporting.
1.12 (03-Jun-2022)
- Added support for "NMRiH" game. Thanks to "Dysphie" for the signatures.
- GameData file and plugin updated.
1.11 (07-Oct-2021)
- Fixed compile errors on SourcecMod version 1.11. Thanks to "Hajitek Majitek" for reporting.
- Thanks to "asherkin" for helping fix.
1.10a (10-Apr-2021)
- Minor change to "vscript_replacer.cfg" for demonstrating regex in map names. Thanks to "Tonblader" for reporting.
1.10 (04-Mar-2021)
- Added ConVar "vscript_replacer_debug" to enable debugging with options for verbose debugging and printing to chat or server.
- ConVar config is saved as "vscript_replacer.cfg" filename in your servers standard "cfg/sourcemods" folder.
1.9 (30-Sep-2020)
- Increased MAX_BUFFER size to support largest known VScript file sizes.
1.8 (20-Jul-2020)
- Fixed overrides not working. Not sure why this went undetected for so long.
1.7 (10-May-2020)
- Various changes to tidy up code.
- Various optimizations and fixes.
1.6 (05-May-2020)
- Added forward "OnVScriptExecuted" to notify plugins when a script is executed (allows blocking or changing).
- Changed script names to be case insensitive.
- Fixed leaking handle when searching through directories.
- Various small changes.
1.5 (03-Feb-2020)
- Fixed previous update breaking support for scripts within folders. Thanks to "Marttt" for reporting.
1.4 (27-Jan-2020)
- Updated "data/vscript_replacer.cfg" with Helms Deep new additions.
1.4 (22-Jan-2020)
- Added RegEx support for matching multiple script names.
- Updated "data/vscript_replacer.cfg" to fix Helms Deep patches. All working now.
1.3 (18-Jan-2020)
- Changed command "sm_vs_exec" to use a logic_script instead, due to script_execute requiring sv_cheats.
- Fixed not loading scripts where the filename is matched using regex. Thanks to "dustinandband" for reporting.
- Fixed error when reporting duplicate keys in config.
- Updated "data/vscript_replacer.cfg" to fix Helms Deep patches and added various critical cvars being changed.
1.2 (16-Jan-2020)
- Added command "sm_vs_exec" to execute a VScript file. This is a wrapper to the function "script_execute".
- Fixed not using the specified "override" filename. Thanks to "xZk" for reporting.
1.1b (11-Nov-2019)
- Edited "data/vscripts_override.cfg" data config adding more Helms Deep fixes.
- No plugin changes.
1.1 (01-Nov-2019)
- Added command "sm_vs_listen" to print to server console the names of scripts being executed.
- Fixed command "sm_vs_dump" from copying files from the dump folder.
1.0 (10-Aug-2019)
- Initial release.
Requirements:
Installation:- Download the .zip and extract the files to their respective folders in your servers \addons\sourcemod\ folder.
__________________
Last edited by Silvers; 01-28-2024 at 02:35.
|
|
|
|