Raised This Month: $ Target: $400
 0% 

Getting problems with return value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-09-2013 , 03:44   Getting problems with return value
Reply With Quote #1

So I have this code:
PHP Code:
public Showrod(id)
{
    if(
get_user_flags(id) & ADMIN_LEVEL_H)
    {
        new 
CT get_pcvar_num (awp_ct)
        new 
TR get_pcvar_num (awp_t)
        
get_mapnameszMap charsmaxszMap ) );
        
map_active get_pcvar_num (g_map_active)
        
awp_active get_pcvar_num (g_awp_active)
        if (
map_active == 1//Checks if map_active is 1
        
{
            for( new 
sizeofmapnames ) ; i++ )
            {
                if ( 
containiszMap mapnames] ) !=-//Checks if map is the one mentioned in const mapnames
                
{
                    
client_print(idprint_center"VIP meniu sitame zemelapyje neveikia!"//Sends a message that VIP can't use VIP menu on that map
                
}
                if ( 
containiszMap mapnames] ) !=-//Checks if map is the one mentioned in const mapnames
                    
return; //Stop VIP from getting the VIP menu
            
}
        }
        new 
menu menu_create("\rVIP meniu:""Pressedrod"); //Creates menu
        
        
menu_additem(menu"\yM4A1 su Deagle""1"0); //Menu choise/case 1
        
menu_additem(menu"\yAK47 su Deagle""2"0); //Menu choise/case 2
        
if( iPlayers[0] >= TR && iPlayers[1] >= CT )
        {
            for( new 
sizeofawpmapnames ) ; i++ )
            {
                if (
awp_active == 1)
                {
                    if ( 
containiszMap awpmapnames] ) !=-//Checks if map is the one mentioned in const awpmapnames
                        
return HERE;
                }
            }
            
menu_additem(menu"\yAWP su Deagle""3"0); //Menu choise/case 3
        
}
        
        
menu_setprop(menuMPROP_EXITMEXIT_ALL);
        
menu_display(idmenu0); //Displays the menu
    
}

Where is the code "return HERE;" what should I type there so it wouldn't completely stop the public showrod, but would stop the menu_additem(menu, "\yAWP su Deagle", "3", 0)?

Last edited by Unkolix; 02-09-2013 at 05:28.
Unkolix is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-09-2013 , 04:14   Re: Getting problems with return value
Reply With Quote #2

You don't return at all. use the function menu_additem() only when it is valid.
__________________
fysiks is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-09-2013 , 04:31   Re: Getting problems with return value
Reply With Quote #3

I have made this:
PHP Code:
new szMap20 ]
<...>
new const 
awpmapnames[][] =
{
    
"2x2""cs_max"
}
<...>
get_mapnameszMap charsmaxszMap ) );
for( new 
sizeofawpmapnames ) ; i++ )
{
    if ( 
containi(szMap awpmapnames]) !=-)
    {
        
menu_additem(menu"\yAWP su Deagle""3"0);
    }

This code does that if map name contains "2x2" or "cs_max" in it, it will show menu_additem. I need to make that menu_additem wouldn't show in that maps.

When I type
PHP Code:
if ( !(containi(szMap awpmapnames]) !=-1) ) 
It bugs and shows menu_additem in those maps, and show menu_additem doubled in maps that doesn't contain "2x2" and "cs_max"

Last edited by Unkolix; 02-09-2013 at 08:29.
Unkolix is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-09-2013 , 22:41   Re: Getting problems with return value
Reply With Quote #4

Try this:

PHP Code:
new bool:bAwpMap false
for( new sizeofawpmapnames ) ; i++ )
{
    if ( 
containi(szMap awpmapnames]) !=-)
    {
        
bAwpMap true
        
break
    }
}

if( !
bAwpMap )
{
    
menu_additem(menu"\yAWP su Deagle""3"0);

__________________

Last edited by fysiks; 02-09-2013 at 22:41. Reason: typo
fysiks is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-10-2013 , 03:08   Re: Getting problems with return value
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Try this:

PHP Code:
new bool:bAwpMap false
for( new sizeofawpmapnames ) ; i++ )
{
    if ( 
containi(szMap awpmapnames]) !=-)
    {
        
bAwpMap true
        
break
    }
}

if( !
bAwpMap )
{
    
menu_additem(menu"\yAWP su Deagle""3"0);

It works! Thanks a lot man! I wonder why didn't think such a thing by my self!
Unkolix 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 20:32.


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