Raised This Month: $117 Target: $400
 29% 

Solved [CSS] Menu with map elimination


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kshishu
Junior Member
Join Date: Mar 2016
Location: Opole
Old 01-12-2018 , 21:01   [CSS] Menu with map elimination
Reply With Quote #1

Hey,

How can I do menu with elimination item??

When you click on cs_assault than be kicked from list(menu). and I also need this for two players - for choose map at match, so when PLAYER_A click on map de_XXX that he don't want this map is kicked from list and menu is given to PLAYER_B without map de_XXX and he also click on some map... and the last map will WIN.


This code I need for 1vs1. Can someone help?


Code:
public Action Choose_map_all()
{
	if(map_chooser_lock == 1)
	{
		Menu menu = new Menu(MainMenu_choose_map_all, MENU_ACTIONS_ALL);
		menu.SetTitle("[WAR] - Choose map to elimination");
		menu.AddItem("cs_assault", "cs_assault");
		menu.AddItem("cs_compound", "cs_compound");
		menu.AddItem("cs_havana", "cs_havana");
		menu.AddItem("cs_italy", "cs_italy");
		menu.AddItem("cs_militia", "cs_militia");
		menu.AddItem("cs_office", "cs_office");
		menu.AddItem("de_aztec", "de_aztec");
		menu.AddItem("de_cache", "de_cache");
		menu.AddItem("de_cbble", "de_cbble");
		menu.AddItem("de_chateau", "de_chateau");
		menu.AddItem("de_contra", "de_contra");
		menu.AddItem("de_cpl_fire", "de_cpl_fire");
		menu.AddItem("de_cpl_mill", "de_cpl_mill");
		menu.AddItem("de_cpl_strike", "de_cpl_strike");
		menu.AddItem("de_dust", "de_dust");
		menu.AddItem("de_dust2", "de_dust2");
		menu.AddItem("de_dust2_pro", "de_dust2_pro");
		menu.AddItem("de_inferno", "de_inferno");
		menu.AddItem("de_nuke", "de_nuke");
		menu.AddItem("de_piranesi", "de_piranesi");
		menu.AddItem("de_port", "de_port");
		menu.AddItem("de_prodigy", "de_prodigy");
		menu.AddItem("de_scorch", "de_scorch");
		menu.AddItem("de_season", "de_season");
		menu.AddItem("de_strata", "de_strata");
		menu.AddItem("de_tides", "de_tides");
		menu.AddItem("de_train", "de_train");
		menu.AddItem("de_tuscan", "de_tuscan");
		menu.AddItem("de_vertigo", "de_vertigo");
		menu.ExitButton = true;
		menu.DisplayVoteToAll(0);
	}
	return Plugin_Handled;
}


public int MainMenu_choose_map_all(Menu menu, MenuAction action, int param1, int param2)
{
	switch(action)
	{
		case MenuAction_Select:
		{
			char sItem[32];
			menu.GetItem(param2, sItem, sizeof(sItem));
			
			if(StrEqual(sItem, "cs_assault"))
				ClientCommand(param1, "sm_setmap cs_assault");
			else if(StrEqual(sItem, "cs_compound"))
				ClientCommand(param1, "sm_setmap cs_compound");
			else if(StrEqual(sItem, "cs_havana"))
				ClientCommand(param1, "sm_setmap cs_havana");
			else if(StrEqual(sItem, "cs_italy"))
				ClientCommand(param1, "sm_setmap cs_italy");
			else if(StrEqual(sItem, "cs_militia"))
				ClientCommand(param1, "sm_setmap cs_militia");
			else if(StrEqual(sItem, "cs_office"))
				ClientCommand(param1, "sm_setmap cs_office");
			else if(StrEqual(sItem, "de_aztec"))
				ClientCommand(param1, "sm_setmap de_aztec");
			else if(StrEqual(sItem, "de_cache"))
				ClientCommand(param1, "sm_setmap de_cache");
			else if(StrEqual(sItem, "de_cbble"))
				ClientCommand(param1, "sm_setmap de_cbble");
			else if(StrEqual(sItem, "de_chateau"))
				ClientCommand(param1, "sm_setmap de_chateau");
			else if(StrEqual(sItem, "de_contra"))
				ClientCommand(param1, "sm_setmap de_contra");
			else if(StrEqual(sItem, "de_cpl_fire"))
				ClientCommand(param1, "sm_setmap de_cpl_fire");
			else if(StrEqual(sItem, "de_cpl_mill"))
				ClientCommand(param1, "sm_setmap de_cpl_mill");
			else if(StrEqual(sItem, "de_cpl_strike"))
				ClientCommand(param1, "sm_setmap de_cpl_strike");
			else if(StrEqual(sItem, "de_dust"))
				ClientCommand(param1, "sm_setmap de_dust");
			else if(StrEqual(sItem, "de_dust2"))
				ClientCommand(param1, "sm_setmap de_dust2");
			else if(StrEqual(sItem, "de_dust2_pro"))
				ClientCommand(param1, "sm_setmap de_dust2_pro");
			else if(StrEqual(sItem, "de_inferno"))
				ClientCommand(param1, "sm_setmap de_inferno");
			else if(StrEqual(sItem, "de_nuke"))
				ClientCommand(param1, "sm_setmap de_nuke");
			else if(StrEqual(sItem, "de_piranesi"))
				ClientCommand(param1, "sm_setmap de_piranesi");
			else if(StrEqual(sItem, "de_port"))
				ClientCommand(param1, "sm_setmap de_port");
			else if(StrEqual(sItem, "de_prodigy"))
				ClientCommand(param1, "sm_setmap de_prodigy");
			else if(StrEqual(sItem, "de_scorch"))
				ClientCommand(param1, "sm_setmap de_scorch");
			else if(StrEqual(sItem, "de_season"))
				ClientCommand(param1, "sm_setmap de_season");
			else if(StrEqual(sItem, "de_strata"))
				ClientCommand(param1, "sm_setmap de_strata");
			else if(StrEqual(sItem, "de_tides"))
				ClientCommand(param1, "sm_setmap de_tides");
			else if(StrEqual(sItem, "de_train"))
				ClientCommand(param1, "sm_setmap de_train");
			else if(StrEqual(sItem, "de_tuscan"))
				ClientCommand(param1, "sm_setmap de_tuscan");
			else if(StrEqual(sItem, "de_vertigo"))
				ClientCommand(param1, "sm_setmap de_vertigo");
		
		}
		case MenuAction_End:
		{
			delete menu;
		}
	}
	return 0;
}
__________________




Last edited by kshishu; 01-12-2018 at 23:18. Reason: solved
kshishu is offline
Send a message via Skype™ to kshishu
1337norway
AlliedModders Donor
Join Date: Feb 2014
Location: Usa
Old 01-12-2018 , 22:02   Re: [CSS] Menu with map elimination
Reply With Quote #2

I made a version from your script to fit your needs

PHP Code:
#include <sourcemod>

#define MAXMAPS 30

char maps[MAXMAPS][260] = {"de_vertigo","de_tuscan","de_train","de_tides","de_strata","de_season","de_scorch","de_prodigy","de_port",
"de_piranesi","de_nuke","de_inferno","de_dust2_pro","de_dust2","de_dust","de_cpl_strike","de_cpl_mill","de_cpl_fire","de_contra","de_chateau",
"de_cbble","de_cache","de_aztec","cs_office","cs_militia","cs_italy","cs_havana","cs_compound","cs_compound","cs_assault"};

bool maps_vetoed[MAXMAPS] = false;

public 
OnMapStart()
{
    for(
int map 0;map MAXMAPS;map++)
        
maps_vetoed[map] = false;
}

public 
void OnClientPutInServer(client)
{
    if(
IsValidClient(client) && !IsFakeClient(client))
        
Choose_map(client);
}

void choose_map_all()
{
    for(new 
client 1;client MAXPLAYERS+1;client++)
        if(
IsValidClient(client) && !IsFakeClient(client))
            
Choose_map(client);
}

public 
Action Choose_map(client)
{
    
Menu menu = new Menu(MainMenu_choose_map_allMENU_ACTIONS_ALL);
    
menu.SetTitle("[WAR] - Choose map to elimination");
    for(
int map 0;map MAXMAPS;map++)
        if(!
maps_vetoed[map])
            
menu.AddItem(maps[map], maps[map]);
            
    
menu.ExitButton true;
    
menu.Display(clientMENU_TIME_FOREVER);

    return 
Plugin_Handled;
}

public 
int MainMenu_choose_map_all(Menu menuMenuAction actionint param1int param2)
{
    switch(
action)
    {
        case 
MenuAction_Select:
        {
            
char sItem[32];
            
menu.GetItem(param2sItemsizeof(sItem));
            
            
ClientCommand(param1"sm_setmap %s"sItem);
            
            for(
int map 0;map MAXMAPS;map++)
                if(!
maps_vetoed[map])
                    if(
StrEqual(sItemmaps[map]))
                        
maps_vetoed[map] = true;
            
            
choose_map_all();
        }
        case 
MenuAction_End:
        {
            
delete menu;
        }
    }
    return 
0;
}

bool:IsValidClient(client)
{
    if (
client <= 0)
        return 
false;
    
    if (
client MaxClients)
        return 
false;
    
    if (!
IsClientConnected(client))
        return 
false;
    
    return 
IsClientInGame(client);

__________________
Taking Free/Paid Requests! Send a PM
--->Donate here if you like my work. <---
1337norway is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-12-2018 , 22:08   Re: [CSS] Menu with map elimination
Reply With Quote #3

I highly recommend reading the map list from a file instead. There's a dedicated command for this: ReadMapList, which will read them into an ArrayList
__________________
Am I back? Well, we'll see.

Last edited by Powerlord; 01-12-2018 at 22:09.
Powerlord is offline
kshishu
Junior Member
Join Date: Mar 2016
Location: Opole
Old 01-12-2018 , 22:26   Re: [CSS] Menu with map elimination
Reply With Quote #4

Thanks a lot!

It's working good but... ;pp
I have one question.

How can I detect last map for this "ClientCommand(param1, "sm_setmap %s", sItem);" ? This is map eliminations so last map is map that players will play.
__________________




Last edited by kshishu; 01-12-2018 at 22:26.
kshishu is offline
Send a message via Skype™ to kshishu
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-12-2018 , 22:53   Re: [CSS] Menu with map elimination
Reply With Quote #5

I forgot to mention, you can just call SetNextMap instead of using a ClientCommand to do it.

As for reading the previous map, you can't. However, you can read the current map using GetCurrentMap... and as I recall, you can use this in an OnMapEnd callback, which would pretty much be the same thing as reading the previous map.
__________________
Am I back? Well, we'll see.

Last edited by Powerlord; 01-12-2018 at 22:55.
Powerlord is offline
kshishu
Junior Member
Join Date: Mar 2016
Location: Opole
Old 01-12-2018 , 22:57   Re: [CSS] Menu with map elimination
Reply With Quote #6

I will not use mapchooser - I want to remove standard plugins. I am still beginner at coding but I think that is some trick to read last map on menu. Not last played map
__________________



kshishu is offline
Send a message via Skype™ to kshishu
1337norway
AlliedModders Donor
Join Date: Feb 2014
Location: Usa
Old 01-12-2018 , 23:10   Re: [CSS] Menu with map elimination
Reply With Quote #7

I've accidentally placed cs_compound on the list twice, make sure to remove one of those copys and change MAXMAPS from 30 to 29.

PHP Code:
public int MainMenu_choose_map_all(Menu menuMenuAction actionint param1int param2)
{
    switch(
action)
    {
        case 
MenuAction_Select:
        {
            
char sItem[32];
            
menu.GetItem(param2sItemsizeof(sItem));
            
            
ClientCommand(param1"sm_setmap %s"sItem);
            
            for(
int map 0;map MAXMAPS;map++)
                if(!
maps_vetoed[map])
                    if(
StrEqual(sItemmaps[map]))
                        
maps_vetoed[map] = true;

            
            
int mapsleft 0;
            
int lastmapslot = -1;
            
            for(
int map 0;map MAXMAPS;map++)
                if(!
maps_vetoed[map])
                {
                    
mapsleft++;
                    
lastmapslot map;
                }
            
            if(
mapsleft == 1)
            {
                
PrintToChat(param1"last map was %s"maps[lastmapslot]);
                
delete menu;
                return 
0;
            }
            
            
choose_map_all();
        }
        case 
MenuAction_End:
        {
            
delete menu;
        }
    }
    return 
0;

__________________
Taking Free/Paid Requests! Send a PM
--->Donate here if you like my work. <---
1337norway is offline
kshishu
Junior Member
Join Date: Mar 2016
Location: Opole
Old 01-12-2018 , 23:17   Re: [CSS] Menu with map elimination
Reply With Quote #8

Thank you so much! Good work man

I'm coding automatic matches for 1vs1, I want to create leagues for CS:S for free and with free servers . That code from you is very expensive for me. THANKS!!! :*

@close
__________________




Last edited by kshishu; 01-12-2018 at 23:17.
kshishu is offline
Send a message via Skype™ to kshishu
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-12-2018 , 23:56   Re: [CSS] Menu with map elimination
Reply With Quote #9

Quote:
Originally Posted by kshishu View Post
I will not use mapchooser - I want to remove standard plugins. I am still beginner at coding but I think that is some trick to read last map on menu. Not last played map
SetNextMap and ReadMapList aren't part of mapchooser, they're part of SourceMod itself.

Having said that, I've spent a lot of time working on Mapchooser and its variants, so I have a pretty good idea how to do map votes.

As for reading the last map on the list, just get the number of items in the vote, then get the menu item with one less than that number.
__________________
Am I back? Well, we'll see.

Last edited by Powerlord; 01-12-2018 at 23:57.
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 19:45.


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