Raised This Month: $51 Target: $400
 12% 

create a menu OnPlayerSpawn - client


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MarceloLopes
New Member
Join Date: Nov 2023
Old 01-14-2024 , 19:45   create a menu OnPlayerSpawn - client
Reply With Quote #1

I'm trying to create a menu that is displayed when the client connects to the server, he will choose one of the classes that will release things to him.
But I can't in any way pass the "client" to the Menu_callback.
I need it to be done with "OnPlayerSpawn" because the client will only be able to access the menu when entering the server, or after respawning, etc.

(Left 4 dead server)

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_spawn"OnPlayerSpawnEventHookMode_Post);
}

void OnPlayerSpawn(Event e, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(e.GetInt("userid"));
    if (
client || !IsClientInGame(client))
    {
        return;
    }
    
CreateTimer(1.0ClassMenuclient);
}
public 
Action ClassMenu(Handle:timerint client)
{
    
Menu menu = new Menu(Menu_Callbackbrclient);
    
menu.SetTitle("select a class");
    
menu.AddItem("option1""team red");
    
menu.AddItem("option2""team blue");
    
menu.Display(client60);
    return 
Plugin_Handled;
}
public 
int Menu_Callbackbr(Menu menuMenuAction actionint param1int param2)
{
    switch (
action)
    {
        case 
MenuAction_Select:
        {
            
char item[32];
            
menu.GetItem(param2itemsizeof(item));
            if (
StrEqual(item"option1"))
            {
                
PrintHintText(client"team red");
                
SetEntityRenderColor(client25500255);
            }
            if (
StrEqual(item"option2"))
            {
                
PrintHintText(client"team blue");
                
SetEntityRenderColor(client00255255);
            }
        }
        case 
MenuAction_End:
        {
            
delete menu;
        }
    }


Last edited by DarkDeviL; 01-21-2024 at 20:49. Reason: Added CODE tag
MarceloLopes is online now
Alienmario
Senior Member
Join Date: Aug 2013
Old 01-15-2024 , 17:14   Re: create a menu OnPlayerSpawn - client
Reply With Quote #2

The client is usually in param1.
Alienmario 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 14:58.


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