Raised This Month: $ Target: $400
 0% 

[PAY] Small Plugin Edit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 02-17-2016 , 12:43   [PAY] Small Plugin Edit
Reply With Quote #1

Hello, looking for a change with this plugin: https://github.com/Nerus87/mapconfigs

Currently with the plugin, it executes the map prefix config file (ex. surf_.cfg), then the map specific config file (ex. surf_beginner.cfg). I'm requesting an edit so that it checks if a map-specific file is found, and if it is, the prefix config file is NOT executed.

To be clear, I will show another example:

If I have surf_.cfg and surf_beginner.cfg, and the map rolls to surf_beginner, surf_.cfg will NOT be executed, but surf_beginner.cfg will. If the next map is surf_rands, and there is not a surf_rands.cfg, surf_.cfg will be executed.

Paying $5 for this small plugin edit, thank you.

Last edited by sneaK; 02-17-2016 at 12:43.
sneaK is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 02-17-2016 , 13:59   Re: [PAY] Small Plugin Edit
Reply With Quote #2

I'll do your request.


EDIT: Not tested but should work as requested.
PHP Code:
/*
    12.06.2015 Updated to 1.3a for Sourcemod 1.7.2 by Nerus.
*/

#include <sourcemod>
#include <sdktools>

// enforce semicolons after each code statement
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_VERSION "1.3a"

#define CONFIG_DIR "sourcemod/map-cfg/"



/*****************************************************************
        P L U G I N   I N F O
*****************************************************************/

public Plugin myinfo = {
    
name "Map configs",
    
author "Berni updated by Nerus",
    
description "Map specific configs execution with prefix support",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?p=607079"
}



/*****************************************************************
        G L O B A L   V A R S
*****************************************************************/

// ConVar Handles
Handle mc_version INVALID_HANDLE;

// Misc



/*****************************************************************
        F O R W A R D   P U B L I C S
*****************************************************************/

public void OnPluginStart() {
    
    
// ConVars
    
mc_version CreateConVar("mc_version"PLUGIN_VERSION"Map Configs plugin version"FCVAR_DONTRECORD|FCVAR_PLUGIN|FCVAR_NOTIFY);
    
// Set it to the correct version, in case the plugin gets updated...
    
SetConVarString(mc_versionPLUGIN_VERSION);
}

public 
void OnAutoConfigsBuffered() {
    
ExecuteMapSpecificConfigs();
}



/*****************************************************************
        P L U G I N   F U N C T I O N S
*****************************************************************/

public void ExecuteMapSpecificConfigs() {
    
    
char currentMap[PLATFORM_MAX_PATH];
    
GetCurrentMap(currentMapsizeof(currentMap));

    
int mapSepPos FindCharInString(currentMap'/'true);
    if (
mapSepPos != -1) {
        
strcopy(currentMapsizeof(currentMap), currentMap[mapSepPos+1]);
    }

    
LogMessage("Searching specific configs for %s"currentMap);

    
Handle adt_configs CreateArray(PLATFORM_MAX_PATH);

    
char cfgdir[PLATFORM_MAX_PATH];
    
    
Format(cfgdirsizeof(cfgdir), "cfg/%s"CONFIG_DIR);
    
    
Handle dir OpenDirectory(cfgdir);
    
    if (
dir == INVALID_HANDLE) {
        
        
LogMessage("Error iterating folder %s, folder doesn't exist !"cfgdir);
        return;
    }
    
    
char configFile[PLATFORM_MAX_PATH];
    
char explode[2][64];
    
FileType fileType;
    
    while (
ReadDirEntry(dirconfigFilesizeof(configFile), fileType)) {
        if (
fileType == FileType_File) {
            
            
ExplodeString(configFile"."explode2sizeof(explode[]));
            
            if (
StrEqual(explode[1], "cfg"false)) {
                
                if (
strncmp(currentMapexplode[0], strlen(explode[0]), false) == 0) {
                    
PushArrayString(adt_configsconfigFile);
                }
            }
        }
    }
    
    
SortADTArray(adt_configsSort_AscendingSort_String);
    
    
int size GetArraySize(adt_configs);
    
    if(
size 0)
    {
        for (
int i=0i<size; ++i) {
            
GetArrayString(adt_configsiconfigFilesizeof(configFile));
            
            
LogMessage("Executing map specific config: %s"configFile);
            
            
ServerCommand("exec %s%s"CONFIG_DIRconfigFile);
        }
    }
    else
    {
        
Format(cfgdirsizeof(cfgdir), "%s%s"cfgdir"surf_.cfg");
        if(
FileExists(cfgdir))
            
ServerCommand("exec %s"cfgdir);
        else
            
PrintToServer("surf_.cfg not found !");
    }
    
    
CloseHandle(dir);
    
CloseHandle(adt_configs);
    
    return;

__________________
Want to check my plugins ?

Last edited by Arkarr; 02-17-2016 at 14:05.
Arkarr 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 05:06.


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