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

Different Menu's for different maps


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gasior
Member
Join Date: Mar 2012
Old 08-21-2013 , 10:16   Different Menu's for different maps
Reply With Quote #1

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?

Last edited by Gasior; 08-21-2013 at 10:29.
Gasior is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-21-2013 , 10:40   Re: Different Menu's for different maps
Reply With Quote #2

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 ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Gasior
Member
Join Date: Mar 2012
Old 08-21-2013 , 10:51   Re: Different Menu's for different maps
Reply With Quote #3

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")

Gasior is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 08-21-2013 , 11:07   Re: Different Menu's for different maps
Reply With Quote #4

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_
        
}
    }

.Dare Devil. is offline
Gasior
Member
Join Date: Mar 2012
Old 08-21-2013 , 14:47   Re: Different Menu's for different maps
Reply With Quote #5

I don't get it .

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.
Gasior is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 08-21-2013 , 15:47   Re: Different Menu's for different maps
Reply With Quote #6

sorry about that

Quote:
Originally Posted by Gasior View Post
I don't get it .
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 View Post

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...

Last edited by .Dare Devil.; 08-21-2013 at 15:50.
.Dare Devil. is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-21-2013 , 16:57   Re: Different Menu's for different maps
Reply With Quote #7

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 ... 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Gasior
Member
Join Date: Mar 2012
Old 08-21-2013 , 18:41   Re: Different Menu's for different maps
Reply With Quote #8

Thank you very much guys, now it's a bit more brighter to me ;) .

Last edited by Gasior; 08-21-2013 at 18:41.
Gasior 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 09:03.


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