Raised This Month: $ Target: $400
 0% 

Call a function in a function ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iloverain
Junior Member
Join Date: Jun 2012
Old 06-23-2012 , 20:23   Call a function in a function ?
Reply With Quote #1

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
__________________
Just A n00b Learning. ^-^

Last edited by iloverain; 06-23-2012 at 20:26.
iloverain is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-23-2012 , 20:33   Re: Call a function in a function ?
Reply With Quote #2

Commands can't be registered like that. Show your code.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
iloverain
Junior Member
Join Date: Jun 2012
Old 06-23-2012 , 20:36   Re: Call a function in a function ?
Reply With Quote #3

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 )
    
}
__________________
Just A n00b Learning. ^-^

Last edited by iloverain; 06-23-2012 at 20:39.
iloverain is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 06-23-2012 , 20:39   Re: Call a function in a function ?
Reply With Quote #4

Show us the EMenu code
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 06-23-2012 at 20:39.
YamiKaitou is offline
iloverain
Junior Member
Join Date: Jun 2012
Old 06-23-2012 , 20:40   Re: Call a function in a function ?
Reply With Quote #5

Ok done. I edited my post above. I didn't realize you needed it. Lawl.
__________________
Just A n00b Learning. ^-^
iloverain is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 06-23-2012 , 20:46   Re: Call a function in a function ?
Reply With Quote #6

Just put 'EMenu( id );' into 'SetSimon( id )'.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
iloverain
Junior Member
Join Date: Jun 2012
Old 06-23-2012 , 20:48   Re: Call a function in a function ?
Reply With Quote #7

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?
__________________
Just A n00b Learning. ^-^

Last edited by iloverain; 06-23-2012 at 20:52.
iloverain is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2012 , 21:00   Re: Call a function in a function ?
Reply With Quote #8

I would do this for better documentation:

PHP Code:
    register_clcmd("say /simon""saySimon")
    
// ...

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

__________________
fysiks is offline
iloverain
Junior Member
Join Date: Jun 2012
Old 06-23-2012 , 21:08   Re: Call a function in a function ?
Reply With Quote #9

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?
__________________
Just A n00b Learning. ^-^

Last edited by iloverain; 06-23-2012 at 21:09. Reason: fail spelling
iloverain is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-23-2012 , 21:11   Re: Call a function in a function ?
Reply With Quote #10

Quote:
Originally Posted by iloverain View Post
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.
__________________
fysiks 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 06:09.


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