AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting problems with return value (https://forums.alliedmods.net/showthread.php?t=208015)

Unkolix 02-09-2013 03:44

Getting problems with return value
 
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)?

fysiks 02-09-2013 04:14

Re: Getting problems with return value
 
You don't return at all. use the function menu_additem() only when it is valid.

Unkolix 02-09-2013 04:31

Re: Getting problems with return value
 
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"

fysiks 02-09-2013 22:41

Re: Getting problems with return value
 
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);



Unkolix 02-10-2013 03:08

Re: Getting problems with return value
 
Quote:

Originally Posted by fysiks (Post 1891303)
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! :D


All times are GMT -4. The time now is 20:32.

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