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

CSGO in game map vote | EndMatchMapGroupVoteOptions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-06-2016 , 09:12   CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #1

My little incomplete plugin.

This plugin disturb CSGO in game map vote at end of match.
It will now excluded previous maps from vote.

PHP Code:
#include <regex>
#include <sdktools>

ArrayList EndMatchMapGroupVoteList// store and refresh mapgroup map list every map change and match end
StringMap EndMatchMapGroupVoteExcluded// store previous maps at end of match

int excluded_amount 5;

public 
void OnPluginStart()
{
    
EndMatchMapGroupVoteExcluded = new StringMap();    
    
HookEventEx("cs_win_panel_match"cs_win_panel_match); // Match totally ends
}

public 
OnConfigsExecuted()
{
    
RequestFrame(frame);
}

public 
void frame(any data)
{
    
// Need maplist for "nominate"
    
CreateMapList();
}

public 
void cs_win_panel_match(Event event, const char[] namebool dontBroadcast)
{
    
// Collect map list end of match, if mapgroup have changed to another
    //Note: If server change mapgroup in the middle of the game, players still have previous mapgroup maps in vote.
    //        Players need reconnect to server to update they list of maps.
    
CreateMapList();



    
// Keep count previous maps and how many times have excluded from vote
    
char buffer[PLATFORM_MAX_PATH];
    
int value;
    
StringMapSnapshot snapshot EndMatchMapGroupVoteExcluded.Snapshot();

    for(
int x 0snapshot.Lengthx++)
    {
        
snapshot.GetKey(xbuffersizeof(buffer));
        
EndMatchMapGroupVoteExcluded.GetValue(buffervalue);
        
EndMatchMapGroupVoteExcluded.SetValue(buffervalue+1true);
        
//PrintToServer("Excluded %i %s %i", x, buffer, value);

        
if(value >= excluded_amount)
        {
            
//PrintToServer("Remove %i %s %i", x, buffer, value);
            
EndMatchMapGroupVoteExcluded.Remove(buffer);
        }
    }

    
delete snapshot;

    
// Exclude current map from vote
    
GetCurrentMap(buffersizeof(buffer));
    
EndMatchMapGroupVoteExcluded.SetValue(buffer1true);
    
//PrintToServer("exclude new map %s", buffer);



    
int ent FindEntityByClassname(-1"cs_gamerules");

    if(
ent != -1)
    {
        
int VoteOptionArraySize GetEntPropArraySize(entProp_Send"m_nEndMatchMapGroupVoteOptions");
        
int[] VoteOptions = new int[VoteOptionArraySize];

        
// save given map indexs
        
for(int x 0VoteOptionArraySizex++)
        {
            
VoteOptions[x] = GameRules_GetProp("m_nEndMatchMapGroupVoteOptions"_x);
        }

        
bool VoteOptionAlready;

        for(
int x 0VoteOptionArraySizex++)
        {

            if(
VoteOptions[x] == -|| VoteOptions[x] >= EndMatchMapGroupVoteList.Length) return;

            
EndMatchMapGroupVoteList.GetString(VoteOptions[x], buffersizeof(buffer));
            
//PrintToServer("-option %i %s", x, buffer);

            // map have played newly
            
if(EndMatchMapGroupVoteExcluded.GetValue(buffervalue))
            {
                
//PrintToServer("-%i %s", VoteOptions[x], buffer);
                
for(int i 0EndMatchMapGroupVoteList.Lengthi++)
                {
                    
EndMatchMapGroupVoteList.GetString(ibuffersizeof(buffer));
                    
//PrintToServer("--%i %s", i, buffer);

                    
if(!EndMatchMapGroupVoteExcluded.GetValue(buffervalue))
                    {
                        for(
int l 0VoteOptionArraySizel++)
                        {
                            if(
VoteOptions[l] == i)
                            {
                                
//PrintToServer("SAME!!");
                                
VoteOptionAlready true;
                            }
                        }

                        if(
VoteOptionAlready)
                        {
                            
GameRules_SetProp("m_nEndMatchMapGroupVoteOptions", -1_xtrue);
                            
VoteOptionAlready false;
                            
i++;
                            continue;
                        }


                        
//PrintToServer("Change %i to %i", VoteOptions[x], i)
                        
VoteOptions[x] = i;
                        
GameRules_SetProp("m_nEndMatchMapGroupVoteOptions"i_xtrue);
                        break;
                    }                    
                }
            }
        }

    }
}


CreateMapList()
{
    if(
EndMatchMapGroupVoteList != nulldelete EndMatchMapGroupVoteList;
    
EndMatchMapGroupVoteList = new ArrayList(ByteCountToCells(PLATFORM_MAX_PATH));

    
// I really hate to do this way, grab map list:(
    
char consoleoutput[5000];
    
ServerCommandEx(consoleoutputsizeof(consoleoutput), "print_mapgroup_sv");

    
int skip;
    
int sub;

    
char buffer[PLATFORM_MAX_PATH];
    
Regex regex = new Regex("^[[:blank:]]+(\\w.*)$"PCRE_MULTILINE);
    
    while( (
sub regex.Match(consoleoutput[skip])) > )
    {
        if(!
regex.GetSubString(0buffersizeof(buffer)))
        {
            break;
        }

        
skip += StrContains(consoleoutput[skip], buffer);
        
skip += strlen(buffer);

        for(
int x 1subx++)
        {
            if(!
regex.GetSubString(xbuffersizeof(buffer)))
            {
                break;
            }
            
EndMatchMapGroupVoteList.PushString(buffer); // Add also false maps to match vote indexs
        
}
    
    }
    
    
delete regex;
    

This grab current mapgroup map list from server command, print_mapgroup_sv
I couldn't find better way to get those and in right order.

There could be some flaw, example, if other plugin block server command print_mapgroup_sv, this plugin can't get maps from server console output text.

Another is, if some reason server command mapgroup change maplist to another in the middle of the game,
players still have previous mapgroup maplist in vote,
so in the end, server and player maps not match together in votes.
Can be check client side print_mapgroup and server side print_mapgroup_sv


But, here snip for anyone who interest.

*edit
I use workshop collection witch have lot of maps. It was annoying when same maps where bring in vote.
__________________
Do not Private Message @me

Last edited by Bacardi; 10-06-2016 at 09:14.
Bacardi is offline
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 10-07-2016 , 05:07   Re: CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #2

I put the plugin on my server and nothing appears when the match is ended.
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-07-2016 , 05:47   Re: CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #3

hmm, can you show list your maps ?
print_mapgroup
or rcon print_mapgroup_sv
Quote:
Originally Posted by hadesownage View Post
I put the plugin on my server and nothing appears when the match is ended.
__________________
Do not Private Message @me
Bacardi is offline
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 10-07-2016 , 06:06   Re: CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #4

Sure.
Code:
13:05:38 print_mapgroup_sv
13:05:38 Map group: mg_active
              de_dust2
              de_train
              de_mirage
              de_nuke
              de_cbble
              de_overpass
              de_cache
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-07-2016 , 06:52   Re: CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #5

works still

or are you asking help to enable that csgo in game map vote ?
This plugin not enable map vote, it remove previous played maps in vote.
Attached Thumbnails
Click image for larger version

Name:	endmatchvote.png
Views:	3010
Size:	86.4 KB
ID:	157792  
__________________
Do not Private Message @me
Bacardi is offline
diller110
Junior Member
Join Date: Sep 2014
Old 10-07-2016 , 09:56   Re: CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #6

Pretty cool feature, two questions:
1. Is it possible to see vote with no items? After 10 mapchanges for example.
2. Is it possible to set custom strings in items, or make any manipulations with it(set custom maps, not from mapgroup)
diller110 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-07-2016 , 12:38   Re: CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #7

1) It is possible to blank all vote options, but this plugin not do it.
When you have few maps and have played 5 maps before, it show all options again.

2) Unfortunally, you can use only indexs, which present order of mapgroup map list.
print_mapgroup_sv
You can't add other maps in current mapgroup during vote.

Creating mapgroup with all maps will make it easier, you can manipulate end match vote how you like, using indexs.
example, I need create nominate list, so it will change end match vote options to these nominated maps (indexs in this system).




Quote:
Originally Posted by diller110 View Post
Pretty cool feature, two questions:
1. Is it possible to see vote with no items? After 10 mapchanges for example.
2. Is it possible to set custom strings in items, or make any manipulations with it(set custom maps, not from mapgroup)
__________________
Do not Private Message @me
Bacardi is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 07-07-2018 , 10:44   Re: CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #8

Another way to grab the maplist (keyvalues)

PHP Code:

void PrecacheMaps
()
{    
    
KeyValues kv = new KeyValues("GameModes_Server.txt");

    if(
kv.ImportFromFile("gamemodes_server.txt"))
    {    
        if(
kv.JumpToKey("mapgroups"))
        {
            if(
kv.GotoFirstSubKey(false))
            {
                if(
kv.JumpToKey("maps"))
                {
                    if(
kv.GotoFirstSubKey(false))
                    {
                        do 
                        {
                            
char Buffer[33];
                            
kv.GetSectionName(Buffersizeof(Buffer));
                            
                            
// Buffer stores the map name
                            // array.PushString(Buffer);
    
                        
} while (kv.GotoNextKey(false));
                    }
                }
            }
        }
    }
    
    
delete kv;

This is working for every mapgroup.
Ilusion9 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-07-2018 , 15:33   Re: CSGO in game map vote | EndMatchMapGroupVoteOptions
Reply With Quote #9

It kinda wish that CS:GO stored its mapgroups in a stringtable.

The TF2 team did some work on this. They use a stringtable named ServerMapCycle, but the actual map cycle was stored as user data for the first (and only) entry in the string table. Which implies they expected to support multiple mapcycles in the future, such as how CS:GO's mapgroups work.

(Before you ask, I looked at a stringtabledump of a CS:GO server and there is no such stringtable on CS:GO)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-07-2018 at 15:33.
Powerlord 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 06:33.


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