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

[CS:GO] Maplist set?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LMNTRIX
New Member
Join Date: May 2015
Old 05-25-2016 , 11:44   [CS:GO] Maplist set?
Reply With Quote #1

Hey guys! Have a problem here, I need some help with a fuction. Well, there is a plugin that I want it to work on the maps that would be in a cfg, (ex.: maplist_enabled) AND ONLY ON THOSE MAPS. What is the function that I need to add to the plugin? (Basic sourcemod skills btw)
LMNTRIX is offline
Wilczek
AlliedModders Donor
Join Date: Oct 2012
Location: Poland
Old 05-25-2016 , 12:26   Re: [CS:GO] Maplist set?
Reply With Quote #2

PHP Code:
Handle a_Maps INVALID_HANDLE;
Handle f_MapList INVALID_HANDLE;
char mapList[PLATFORM_MAX_PATH];
bool g_bIsValidMap false;

public 
OnPluginStart()
{
    
BuildPath(Path_SMmapListsizeof(mapList), "configs/maplist.cfg");
    
LoadMapList();
}

public 
OnMapStart()
{
    
g_bIsValidMap false;
    
    
char mapname[64];
    
GetCurrentMap(mapnamesizeof(mapname));
    
    if (
FindStringInArray(a_Mapsmapname) != -1)
        
g_bIsValidMap true;
}

public 
Action LoadMapList()
{
    if (
FileExists(mapListfalse)) {
        
f_MapList OpenFile(mapList"rt");
    }
    else {
        
f_MapList OpenFile(mapList"at+");
    }

    if (
f_MapList == INVALID_HANDLE)
        
LogMessage("Error - unable to load or create file: %s"mapList);
    
    
a_Maps CreateArray(256);
    
    
char sReadBuffer[256];
    
    
int len;
    while (!
IsEndOfFile(f_MapList) && ReadFileLine(f_MapListsReadBuffersizeof(sReadBuffer))) {
        if(
sReadBuffer[0] == '/' || IsCharSpace(sReadBuffer[0]))
            continue;
    
        
ReplaceString(sReadBuffersizeof(sReadBuffer), "\n""");
        
ReplaceString(sReadBuffersizeof(sReadBuffer), "\r""");
        
ReplaceString(sReadBuffersizeof(sReadBuffer), "\t""");
        
ReplaceString(sReadBuffersizeof(sReadBuffer), " """);
        
        
len strlen(sReadBuffer);
        for(new 
ileni++) {
            if(
sReadBuffer[i] == ' ' || sReadBuffer[i] == '/')
            {
                
sReadBuffer[i] = '\0';
                break;
            }
        }
    
        
PushArrayString(a_MapssReadBuffer);
    }

    
CloseHandle(f_MapList);
}

public 
Action SomeYourFunction()
{
    if(
g_bIsValidMap) {
        
//do your stuff here
    
}

__________________

Last edited by Wilczek; 05-25-2016 at 12:31.
Wilczek is offline
LMNTRIX
New Member
Join Date: May 2015
Old 05-25-2016 , 12:41   Re: [CS:GO] Maplist set?
Reply With Quote #3

Quote:
Originally Posted by Wilczek View Post
PHP Code:
Handle a_Maps INVALID_HANDLE;
Handle f_MapList INVALID_HANDLE;
char mapList[PLATFORM_MAX_PATH];
bool g_bIsValidMap false;

public 
OnPluginStart()
{
    
BuildPath(Path_SMmapListsizeof(mapList), "configs/maplist.cfg");
    
LoadMapList();
}

public 
OnMapStart()
{
    
g_bIsValidMap false;
    
    
char mapname[64];
    
GetCurrentMap(mapnamesizeof(mapname));
    
    if (
FindStringInArray(a_Mapsmapname) != -1)
        
g_bIsValidMap true;
}

public 
Action LoadMapList()
{
    if (
FileExists(mapListfalse)) {
        
f_MapList OpenFile(mapList"rt");
    }
    else {
        
f_MapList OpenFile(mapList"at+");
    }

    if (
f_MapList == INVALID_HANDLE)
        
LogMessage("Error - unable to load or create file: %s"mapList);
    
    
a_Maps CreateArray(256);
    
    
char sReadBuffer[256];
    
    
int len;
    while (!
IsEndOfFile(f_MapList) && ReadFileLine(f_MapListsReadBuffersizeof(sReadBuffer))) {
        if(
sReadBuffer[0] == '/' || IsCharSpace(sReadBuffer[0]))
            continue;
    
        
ReplaceString(sReadBuffersizeof(sReadBuffer), "\n""");
        
ReplaceString(sReadBuffersizeof(sReadBuffer), "\r""");
        
ReplaceString(sReadBuffersizeof(sReadBuffer), "\t""");
        
ReplaceString(sReadBuffersizeof(sReadBuffer), " """);
        
        
len strlen(sReadBuffer);
        for(new 
ileni++) {
            if(
sReadBuffer[i] == ' ' || sReadBuffer[i] == '/')
            {
                
sReadBuffer[i] = '\0';
                break;
            }
        }
    
        
PushArrayString(a_MapssReadBuffer);
    }

    
CloseHandle(f_MapList);
}

public 
Action SomeYourFunction()
{
    if(
g_bIsValidMap) {
        
//do your stuff here
    
}

Oh my god! Thanks mate!
LMNTRIX 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 10:26.


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