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

Solved Displaying a menu on user's connect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WHOOHOO
Junior Member
Join Date: Aug 2016
Old 04-05-2019 , 14:26   Displaying a menu on user's connect
Reply With Quote #1

Hello there!
I require to display a menu when the user connects, I tried two methods, but sadly none of them worked so far

Method one:
Verifying if the user is a bot or not, Then I made a task, and after all of that I wrote menu name on task's public, This method will display the menu on the user's connect, but none of the menu options is functional unless I recall menu using it's clcmd
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

public plugin_init()
{
    
register_plugin("Test menu""1.0""WHOOHOO");
    
register_clcmd("say /menu""Menu"_"Simple menu");
}

public 
client_putinserver(id)
{
    if (
is_user_bot(id))
        return
        
    
set_task(0.0"Entermenu"id)
}

public 
client_disconnect(id)
{
    
remove_task(id)
}

public 
Entermenu(id)
{
Menu(id);
}

public 
Menu(id)
{
    new 
menu menu_create("Simple menu""Menu_Handler");

    
menu_additem(menu"Option 1"""0); // case 0
    
menu_additem(menu"Option 2"""0); // case 1

    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_setprop(menuMPROP_NOCOLORS1);

    
menu_display(idmenu0);

    return 
PLUGIN_HANDLED;
}

public 
Menu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_cancel(id);
        return 
PLUGIN_HANDLED;
    }

    new 
command[6], name[64], accesscallback;

    
menu_item_getinfo(menuitemaccesscommandsizeof command 1namesizeof name 1callback);

    switch(
item)
    {
        case 
0:
        {
            
set_hudmessage(25500, -1.00.01)
            
show_hudmessage(id"Option 1")
            
Menu(id);
        }
        
        case 
1:
        {
            
set_hudmessage(25500, -1.00.01)
            
show_hudmessage(id"Option 2")
            
Menu(id);
        }
    }

    
menu_destroy(menu);

    return 
PLUGIN_HANDLED;

Method two:
I made a Boolean (To keep count of user's first spawn), then I registered a Ham (Ham_Spawn) on the plugin_init, then I made a public and called that Ham and I wrote menu name on task's public, This method won't display menu at all.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <colorchat>

new bool:firsttime[33]

public 
plugin_init()
{
    
register_plugin("Test menu""1.0""WHOOHOO");
    
register_clcmd("say /menu""Menu"_"Simple menu");
    
    
RegisterHamHam_Spawn"player""PlayerSpawn")
}

public 
PlayerSpawnid )
{
    if( !
is_user_aliveid ) )
        return;
        
    if(
firsttime[id])
    {
        
Menu(id);
    }
    
firstspawn[id] = false
}

public 
Menu(id)
{
    new 
menu menu_create("Simple menu""Menu_Handler");

    
menu_additem(menu"Option 1"""0); // case 0
    
menu_additem(menu"Option 2"""0); // case 1

    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_setprop(menuMPROP_NOCOLORS1);

    
menu_display(idmenu0);

    return 
PLUGIN_HANDLED;
}

public 
Menu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_cancel(id);
        return 
PLUGIN_HANDLED;
    }

    new 
command[6], name[64], accesscallback;

    
menu_item_getinfo(menuitemaccesscommandsizeof command 1namesizeof name 1callback);

    switch(
item)
    {
        case 
0:
        {
            
set_hudmessage(25500, -1.00.01)
            
show_hudmessage(id"Option 1")
            
Menu(id);
        }
        
        case 
1:
        {
            
set_hudmessage(25500, -1.00.01)
            
show_hudmessage(id"Option 2")
            
Menu(id);
        }
    }

    
menu_destroy(menu);

    return 
PLUGIN_HANDLED;

Thanks in advance

Last edited by WHOOHOO; 04-06-2019 at 07:18. Reason: ITS SOLVED
WHOOHOO is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-05-2019 , 15:36   Re: Displaying a menu on user's connect
Reply With Quote #2

The two methods should work, try registering RegisterHam (Ham_Spawn, "player", "PlayerSpawn") as post "RegisterHam (Ham_Spawn," player "," PlayerSpawn ", 1)"
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
JocAnis
Veteran Member
Join Date: Jun 2010
Old 04-05-2019 , 18:03   Re: Displaying a menu on user's connect
Reply With Quote #3

when you go:

Code:
new bool:firsttime[33]
that means its false to all players...so:
Code:
if(firsttime[id]) 
{ 
       Menu(id); 
}
wont be ever executed..i guess (but ye also i think post for spawn is better)
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 04-05-2019 at 18:04.
JocAnis is offline
WHOOHOO
Junior Member
Join Date: Aug 2016
Old 04-05-2019 , 18:26   Re: Displaying a menu on user's connect
Reply With Quote #4

Quote:
Originally Posted by iceeedr View Post
The two methods should work, try registering RegisterHam (Ham_Spawn, "player", "PlayerSpawn") as post "RegisterHam (Ham_Spawn," player "," PlayerSpawn ", 1)"
Thanks for your answer, I tried that and It didn't brought any menu at all, Same result as before

Quote:
Originally Posted by JocAnis View Post
when you go:

Code:
new bool:firsttime[33]
that means its false to all players...so:
Code:
if(firsttime[id]) 
{ 
       Menu(id); 
}
wont be ever executed..i guess (but ye also i think post for spawn is better)
I removed that Boolean to see if it works or not, It didn't
I guess there is a problem with my RegisterHam
WHOOHOO is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-05-2019 , 20:55   Re: Displaying a menu on user's connect
Reply With Quote #5

Try

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <colorchat>

new bool:firsttime[33]

public 
plugin_init()
{
    
register_plugin("Test menu""1.0""WHOOHOO");
    
register_clcmd("say /menu""Menu""Simple menu");
    
    
RegisterHamHam_Spawn"player""PlayerSpawn"1)
}

public 
client_putinserver(id)
{
    
firsttime[id] = true
}

public 
client_disconnect(id)
{
    
firsttime[id] = true
}

public 
PlayerSpawnid )
{
    if( !
is_user_aliveid ) )
        return 
HAM_IGNORED
        
    
if(firsttime[id])
    {
        
Menu(id)
        
firstspawn[id] = false
    
}
    return 
HAM_IGNORED
}

public 
Menu(id)
{
    new 
menu menu_create("Simple menu""Menu_Handler");

    
menu_additem(menu"Option 1"""0); // case 0
    
menu_additem(menu"Option 2"""0); // case 1

    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_setprop(menuMPROP_NOCOLORS1);

    
menu_display(idmenu0);

    return 
PLUGIN_HANDLED;
}

public 
Menu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
         
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    switch(
item)
    {
        case 
0:
        {
            
set_hudmessage(25500, -1.00.01)
            
show_hudmessage(id"Option 1")
        }
        
        case 
1:
        {
            
set_hudmessage(25500, -1.00.01)
            
show_hudmessage(id"Option 2")
        }
    }
    
    
Menu(id);
    
menu_destroy(menu);

    return 
PLUGIN_HANDLED;

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 04-06-2019 at 10:09.
iceeedr is offline
Send a message via Skype™ to iceeedr
WHOOHOO
Junior Member
Join Date: Aug 2016
Old 04-06-2019 , 07:18   Re: Displaying a menu on user's connect
Reply With Quote #6

Quote:
Originally Posted by iceeedr View Post
Try

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <colorchat>

new bool:firsttime[33]

public 
plugin_init()
{
    
register_plugin("Test menu""1.0""WHOOHOO");
    
register_clcmd("say /menu""Menu""Simple menu");
    
    
RegisterHamHam_Spawn"player""PlayerSpawn"1)
}

public 
client_putinserver(id)
{
    
firsttime[id] = true
}

public 
client_disconnect(id)
{
    
firsttime[id] = true
}

public 
PlayerSpawnid )
{
    if( !
is_user_aliveid ) )
        return 
HAM_IGNORED
        
    
if(firsttime[id])
    {
        
Menu(id)
        
firstspawn[id] = false
    
}
}

public 
Menu(id)
{
    new 
menu menu_create("Simple menu""Menu_Handler");

    
menu_additem(menu"Option 1"""0); // case 0
    
menu_additem(menu"Option 2"""0); // case 1

    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_setprop(menuMPROP_NOCOLORS1);

    
menu_display(idmenu0);

    return 
PLUGIN_HANDLED;
}

public 
Menu_Handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
         
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    switch(
item)
    {
        case 
0:
        {
            
set_hudmessage(25500, -1.00.01)
            
show_hudmessage(id"Option 1")
        }
        
        case 
1:
        {
            
set_hudmessage(25500, -1.00.01)
            
show_hudmessage(id"Option 2")
        }
    }
    
    
Menu(id);
    
menu_destroy(menu);

    return 
PLUGIN_HANDLED;

It worked! Bless you
It returns a warning while compiling (warning 209: function "PlayerSpawn" should return a value) but as long as it works, I have no complaints
Thank you, guys.
WHOOHOO is offline
thEsp
BANNED
Join Date: Aug 2017
Old 04-06-2019 , 08:31   Re: Displaying a menu on user's connect
Reply With Quote #7

PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <hamsandwich> 
#include <colorchat> 

new bool:firsttime[33

public 
plugin_init() 

    
register_plugin("Test menu""1.0""WHOOHOO"); 
    
register_clcmd("say /menu""Menu""Simple menu"); 
     
    
RegisterHamHam_Spawn"player""PlayerSpawn"1


public 
client_putinserver(id

    
firsttime[id] = true 


public 
client_disconnect(id

    
firsttime[id] = true 


public 
PlayerSpawnid 

    if( !
is_user_aliveid ) ) 
        return 
HAM_IGNORED 
         
    
if(firsttime[id]) 
    { 
        
Menu(id
        
firstspawn[id] = false 
    

    return 
PLUGIN_CONTINUE


public 
Menu(id

    new 
menu menu_create("Simple menu""Menu_Handler"); 

    
menu_additem(menu"Option 1"""0); // case 0 
    
menu_additem(menu"Option 2"""0); // case 1 

    
menu_setprop(menuMPROP_EXITMEXIT_ALL); 
    
menu_setprop(menuMPROP_NOCOLORS1); 

    
menu_display(idmenu0); 

    return 
PLUGIN_HANDLED


public 
Menu_Handler(idmenuitem

    if(
item == MENU_EXIT
    { 
         
menu_destroy(menu); 
        return 
PLUGIN_HANDLED
    } 

    switch(
item
    { 
        case 
0
        { 
            
set_hudmessage(25500, -1.00.01
            
show_hudmessage(id"Option 1"
        } 
         
        case 
1
        { 
            
set_hudmessage(25500, -1.00.01
            
show_hudmessage(id"Option 2"
        } 
    } 
     
    
Menu(id); 
    
menu_destroy(menu); 

    return 
PLUGIN_HANDLED

This should do it just right without any warnings.
thEsp is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 04-06-2019 , 10:10   Re: Displaying a menu on user's connect
Reply With Quote #8

Quote:
Originally Posted by WHOOHOO View Post
It worked! Bless you
It returns a warning while compiling (warning 209: function "PlayerSpawn" should return a value) but as long as it works, I have no complaints
Thank you, guys.
Edited to solve the warn.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
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 18:05.


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