Raised This Month: $ Target: $400
 0% 

How to open up a menu to client when he connects?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Marcin
New Member
Join Date: Jun 2008
Old 08-11-2008 , 14:28   How to open up a menu to client when he connects?
Reply With Quote #1

Like when he connects he gets a menu open

any refrences?
Marcin is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 08-11-2008 , 14:40   Re: How to open up a menu to client when he connects?
Reply With Quote #2

You would use the OnClientConnected function and then you would need to create your own menu using DisplayMenu.

Here's an example

PHP Code:
public bool:OnClientConnect(clientString:rejectmsg[], maxlen) {
    
AdminMenu(client);
}

public 
Action:AdminMenu(clientId) {
    new 
Handle:menu CreateMenu(AdminMenuHandler);
    
SetMenuTitle(menu"Menu Title");
    
AddMenuItem(menu"option1""First Option");
    
AddMenuItem(menu"option2""Second Option");
    
AddMenuItem(menu"option3""Third Option");
    
SetMenuExitButton(menutrue);
    
DisplayMenu(menuclientIdMENU_TIME_FOREVER);

    return 
Plugin_Handled;
}

public 
AdminMenuHandler(Handle:menuMenuAction:actionclientitemNum) {
    if ( 
action == MenuAction_Select ) {
        new 
String:info[32];

        
GetMenuItem(menuitemNuminfosizeof(info));

        if ( 
strcmp(info,"option1") == ) {

            
//Do stuff here

        
}
        else if ( 
strcmp(info,"option2") == ) {

            
//Do different stuff here

        
}
        else if ( 
strcmp(info,"kick") == ) {
            
//Do more different stuff here
        
}
    }
    else if ( 
action == MenuAction_End )
        
CloseHandle(menu);

__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-11-2008 , 14:46   Re: How to open up a menu to client when he connects?
Reply With Quote #3

You should use OnClientPutInGame with a delay of like 3 seconds instead of OnClientConnect.
bl4nk is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 08-11-2008 , 14:57   Re: How to open up a menu to client when he connects?
Reply With Quote #4

Quote:
Originally Posted by bl4nk View Post
You should use OnClientPutInGame with a delay of like 3 seconds instead of OnClientConnect.
Whoops. That's right... i'll fix it.


Edit: I can't get it to work. Compiler doesn't like me.
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)

Last edited by Lebson506th; 01-09-2009 at 07:35.
Lebson506th is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-11-2008 , 16:16   Re: How to open up a menu to client when he connects?
Reply With Quote #5

Try this:
PHP Code:
#include <sourcemod>

public OnClientPutInServer(client) {
    
CreateTimer(3.0AdminMenuclient);
}

public 
Action:AdminMenu(Handle:timerany:clientId) {
    new 
Handle:menu CreateMenu(AdminMenuHandler);
    
SetMenuTitle(menu"Menu Title");
    
AddMenuItem(menu"option1""First Option");
    
AddMenuItem(menu"option2""Second Option");
    
AddMenuItem(menu"option3""Third Option");
    
SetMenuExitButton(menutrue);
    
DisplayMenu(menuclientIdMENU_TIME_FOREVER);
}

public 
AdminMenuHandler(Handle:menuMenuAction:actionclientitemNum) {
    if ( 
action == MenuAction_Select ) {
        new 
String:info[32];

        
GetMenuItem(menuitemNuminfosizeof(info));

        if ( 
strcmp(info,"option1") == ) {

            
//Do stuff here

        
}
        else if ( 
strcmp(info,"option2") == ) {

            
//Do different stuff here

        
}
        else if ( 
strcmp(info,"kick") == ) {
            
//Do more different stuff here
        
}
    }
    else if ( 
action == MenuAction_End )
        
CloseHandle(menu);

bl4nk is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 08-11-2008 , 16:18   Re: How to open up a menu to client when he connects?
Reply With Quote #6

Line 4 error 100: function prototypes do not match
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-11-2008 , 16:21   Re: How to open up a menu to client when he connects?
Reply With Quote #7

Are you copy/pasting the code I posted or are you trying something on your own? I fixed that with the code you provided above by changing the timer callback to:

public Action:AdminMenu(Handle:timer, any:clientId)
bl4nk is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 08-11-2008 , 16:23   Re: How to open up a menu to client when he connects?
Reply With Quote #8

Ahh, yea. missed that change.

Works fine, thanks.
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th 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 03:20.


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