AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Call a function in a function ? (https://forums.alliedmods.net/showthread.php?t=188221)

iloverain 06-23-2012 20:23

Call a function in a function ?
 
I'm back... already. Lmfao.

So I'm trying to open a menu inside a function. So the ct types /simon and it would open a menu. but there's already a function for /simon. so how would I make it when the ct types /simon it would call one function and also another? Could you do something like:
register_clcmd( "say /simon", "Func1", "Func2", )?

Am I being too confusing? xD I think even I'm confused by my own question.

I've tried adding
Code:

EMenu( id )
in the function but no luck.
EMenu = my menu function

hornet 06-23-2012 20:33

Re: Call a function in a function ?
 
Commands can't be registered like that. Show your code.

iloverain 06-23-2012 20:36

Re: Call a function in a function ?
 
Code:

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    register_clcmd ( "say /simon", "SetSimon" )
    register_clcmd ( "say_team /simon", "SetSimon" )
    register_logevent( "Round_End", 2, "1=Round_End" )
    register_clcmd ( "jmod_menu", "EMenu" )
}

Code:

public SetSimon(id) {
    if ( cs_get_user_team( id ) == CS_TEAM_CT ) {
   
    new name[32];
    get_user_name( id, name, charsmax( name ) )
   
    if ( isSimon == true ) {
        client_print( id, print_chat, "Someone is already Simon!" )
    } else {
        client_print( 0, print_chat, "%s is now Simon!", name )
        isSimon = true
        SimonPerson = name
        EMenu( id )  // <------------------------------ no work D:
        }
    } else {
        client_print( id, print_chat, "You are not a CT!" )
    }
}

and my menu which is
Code:

public EMenu(id) {
    new menu = menu_create ( "\rJailBreak Day Menu [iloverain]", "menu_handler" )
   
    menu_additem ( menu, "\wCage Day", "1", 0 )
    menu_additem ( menu, "\wFree Day", "2", 0 )
    menu_additem ( menu, "\wNightCrawler Day [CT]", "3", 0 )
    menu_additem ( menu, "\wNightCrawler Day [T]", "4", 0 )
    menu_additem ( menu, "\wRiot Day", "5", 0 )
    menu_additem ( menu, "\wZombie Day [CT]", "6", 0 )
    menu_additem ( menu, "\wZombie Day [T]", "7", 0 )
   
    menu_setprop ( menu, MPROP_EXIT, MEXIT_ALL )
   
    menu_display ( id, menu, 0 )
   
}


YamiKaitou 06-23-2012 20:39

Re: Call a function in a function ?
 
Show us the EMenu code

iloverain 06-23-2012 20:40

Re: Call a function in a function ?
 
Ok done. I edited my post above. I didn't realize you needed it. Lawl.

Neeeeeeeeeel.- 06-23-2012 20:46

Re: Call a function in a function ?
 
Just put 'EMenu( id );' into 'SetSimon( id )'.

iloverain 06-23-2012 20:48

Re: Call a function in a function ?
 
Noo. I want /simon to call the SetSimon function. But I also want /simon to open the EMenu at the same time.

or do you mean change the "SetSimon" To "EMenu" to open 2 EMenu's? 1 menu and 1 the setsimon?

fysiks 06-23-2012 21:00

Re: Call a function in a function ?
 
I would do this for better documentation:

PHP Code:

    register_clcmd("say /simon""saySimon")
    
// ...

public saySimon(id)
{
    
SetSimon(id);
    
EMenu(id);



iloverain 06-23-2012 21:08

Re: Call a function in a function ?
 
Lmao!! I actually didn't think of that at all. I'm pretty sure that worked. But my menu won't pop up? Is there something wrong with my menu?

fysiks 06-23-2012 21:11

Re: Call a function in a function ?
 
Quote:

Originally Posted by iloverain (Post 1734827)
Lmao!! I actually didn't think of that at all. I'm pretty sure that worked. But my menu won't pop up? Is there something wrong with my menu?

I don't know, is there? Does it work on it's own when registered for it's own function? If no, then you shouldn't even be adding it to other functions because it doesn't even work. You need to make sure each of the components work alone before trying to put them together. If you do this on a regular basis it will make your life much less frustrating when something does go wrong because you will know what works and what doesn't the whole time.


All times are GMT -4. The time now is 06:09.

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