AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Different Menu's for different maps (https://forums.alliedmods.net/showthread.php?t=224207)

Gasior 08-21-2013 10:16

Different Menu's for different maps
 
Hi,
I have a problem with following code
PHP Code:

public HookSay(id)
{
    new 
map[32];
    
    
get_mapname(mapcharsmax(map) - 1);
    if(
equali(map"1hp_he") || containi(map"ka_")) {
        
DisplayMenu1(id)
    }
    else if(
containi(map"awp_") || containi(map"awesome_")) {
        
DisplayMenu2(id);
    }
    else if(
containi(map"knives")) {    
        
DisplayMenu3(id);
    }
    else 
        
DisplayMenu(id)
    return 
PLUGIN_HANDLED_MAIN


The problem is that no matter what map is, it always runs DisplayMenu1. Can someone show me what is wrong?

ConnorMcLeod 08-21-2013 10:40

Re: Different Menu's for different maps
 
Problem is bad containi usage.

Anyway, you should initialize all stuff in plugin_init, could you show the register_clcmd line with say command please ?

Gasior 08-21-2013 10:51

Re: Different Menu's for different maps
 
PHP Code:

public plugin_init()
{    
    
gmsgScreenFade get_user_msgid("ScreenFade")
    
    
register_clcmd("say /funshop""HookSay")
    
register_clcmd("say_team /funshop""HookSay")
    
register_clcmd("say /fun""HookSay")
    
register_clcmd("say_team /fun""HookSay")
    
register_clcmd("say /shop""HookSay")
    
register_clcmd("say_team /shop""HookSay")
    
    
RegisterHam(Ham_Spawn"player""runda"1)
    
    
register_event("CurWeapon""HookCurWeapon""be""1=1" );
    
    
register_cvar("sv_respawn""1")



.Dare Devil. 08-21-2013 11:07

Re: Different Menu's for different maps
 
PHP Code:


#define maxmaps 3
new const mapnames[maxmaps][48] =
{
    
"1hp_he",
    
"awp_",
    
"ka_"
}

new const 
mapnames_usecontaini[maxmaps] =
{
    
0,
    
1,
    
1
}

new 
ismap
public plugin_init()
{
    
check_map()
}

check_map()
{
    new 
map[48], a
    get_mapname
(mapcharsmax(map))
    for( 
0maxmapsa++ )
    {
        if(!
mapnames_usecontaini[a])
        {
            if(
equali(map,mapnames[a]))
            {
                
ismap a
                
break
            }
            continue
        }
        
        if(
containi(map,mapnames[a]) != -1)
        {
            
ismap a
            
break
        }
    }
}

public 
yourfunc()
{
    switch(
ismap)
    {
        case 
0:
        {
            
// map is 1hp_he
        
}
        case 
1:
        {
            
// mapname contains awp_
        
}
        case 
2:
        {
            
// mapname contains ka_
        
}
    }



Gasior 08-21-2013 14:47

Re: Different Menu's for different maps
 
I don't get it :D .

It's kind of scripting help so I'll just go for it and ask questions:
PHP Code:

new const mapnames_usecontaini[maxmaps] = 

    
0
    
1
    



Why 0 1 1?

PHP Code:

public yourfunc() 

    switch(
ismap
    { 
        case 
0
        { 
            
// map is 1hp_he 
        

        case 
1
        { 
            
// mapname contains awp_ 
        

        case 
2
        { 
            
// mapname contains ka_ 
        

    } 


Is it a place for menu?? And should it look like that:

PHP Code:

public DisplayMenu(id)() 

    new 
Menu menu_create("Fun Shop""Menu_Handler")
    if(
wylosowal[id]) {
        
ColorChat(id,RED,"^3 [FUNSHOP] ^4 Juz uzyles menu w tej rundzie."0
        
menu_destroy(Menu)
    }
    else {
    
menu_additem(Menu"Gravity = 2000$ (VIP 1400$)""1"0)
        switch(
ismap
        { 
                case 
0
            { 
            
menu_additem(Menu"Option1""1"0)
            } 
            case 
1
            { 
            
menu_additem(Menu"Option1 ""1"0)
            } 
            case 
2
            { 
             
menu_additem(Menu"Option1 ""1"0)
            } 
        } 


To be honest I am so confused.

.Dare Devil. 08-21-2013 15:47

Re: Different Menu's for different maps
 
sorry about that

Quote:

Originally Posted by Gasior (Post 2018857)
I don't get it :D .
PHP Code:

new const mapnames_usecontaini[maxmaps] = 

    
0
    
1
    



Why 0 1 1?

mapnames_usecontaini is connected with mapnames.
for example first item in mapnames is
1hp_he, that should be full map name so when i checking the map name i have to be sure
that it is full map name because you need to check full map name and map beggining "kz_ for example" differently
native containi will check if map name contains "1hp_he" and
native equali will check if map name is exacly the same name as the map what is running in server.
0 means that my code use equali native to check, that means that map name must be full not the beggining of the map name or map tag what ever.
1 means that my code use containi and map name what you put mapnames variable is the map tag.

and this is how are the connected
PHP Code:

new const mapnames[maxmaps][48] = 

    
"1hp_he"// 0
    
"awp_",  // 1
    
"ka_"  // 1


new const 
mapnames_usecontaini[maxmaps] = 

    
0// 1hp_he
    
1// awp_
    
1  // ka_


Quote:

Originally Posted by Gasior (Post 2018857)

PHP Code:

public yourfunc() 

    switch(
ismap
    { 
        case 
0
        { 
            
// map is 1hp_he 
        

        case 
1
        { 
            
// mapname contains awp_ 
        

        case 
2
        { 
            
// mapname contains ka_ 
        

    } 


Is it a place for menu?? And should it look like that:

You said that you want every map have his own menu so basically

PHP Code:

public yourfunc() 

    switch(
ismap
    { 
        case 
0
        { 
            
show_1hp_he_menu()
        }
        case 
1
        { 
            
show__awp_menu()
        } 
        case 
2
        { 
            
show__ka_menu()
        } 
    } 


If your server running map named 1hp_he
ismap will be 0
and this part will be called:
PHP Code:

        case 0
        { 
            
show_1hp_he_menu()
        } 

if map name begin with awp_
ismap will be 1 and this part will be called
PHP Code:

        case 1
        { 
            
// mapname contains awp_ 
        


And so on...

ConnorMcLeod 08-21-2013 16:57

Re: Different Menu's for different maps
 
Initialize all at plugin_init :

PHP Code:

public plugin_init()
{
    new 
map[32], callback[32];
    
get_mapname(mapcharsmax(map));
    if(
equali(map"1hp_he") || containi(map"ka_") != -)
    {
        
callback "DisplayMenu1";
    }
    else if(
containi(map"awp_") != -|| containi(map"awesome_") != -1) {
        
callback "DisplayMenu2";
    }
    else if(
containi(map"knives") != -1) {    
        
callback "DisplayMenu3";
    }
    else
    {
        
callback "DisplayMenu";
    }

    
register_clcmd("say /funshop"callback);
    
register_clcmd("say_team /funshop"callback);
    
register_clcmd("say /fun"callback);
    
register_clcmd("say_team /fun"callback);
    
register_clcmd("say /shop"callback);
    
register_clcmd("say_team /shop"callback);
}

public 
DisplayMenu1(id)
{
}

// etc ... 


Gasior 08-21-2013 18:41

Re: Different Menu's for different maps
 
Thank you very much guys, now it's a bit more brighter to me ;) .


All times are GMT -4. The time now is 15:59.

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