AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu / 0 (exit doesn't dwork) (https://forums.alliedmods.net/showthread.php?t=128545)

Mifuntm 06-02-2010 09:41

Menu / 0 (exit doesn't dwork)
 
I have plugin for show menu for connected players and four options open correct txt file in MOTD window. Plugin seems to be work however i cant close menu at all! After Connect if you type 0 menu will close, but if you choose 1, 2, 3 or 4 and then 0 nothing happens.

I'll be appreciated if someone look into code.




Code:

#include <amxmodx>
#define TASK 2376

public plugin_init() {
    register_plugin("Join menu","0.1","unknown")
}
public showmenu(id)
{
    new menu=menu_create("Welcome to server","menu_funkcja")
    menu_additem(menu,"Rules")
    menu_additem(menu,"Admins")
    menu_additem(menu,"Commands")
    menu_additem(menu,"Slot Reservation")
    menu_setprop(menu,MPROP_EXITNAME,"Exit")
    menu_display(id,menu)
    return PLUGIN_CONTINUE
}
public menu_funkcja(id,menu,item)
{
    switch(item)
    {
        case 0:show_motd(id,"join_menu/rules.txt","Rules.")
        case 1:show_motd(id,"join_menu/admins.txt","Admins.")
        case 2:show_motd(id,"join_menu/commands.txt","Commands.")
        case 3:show_motd(id,"join_menu/slot.txt","Slot Reservation.")
    }
    if((item==-3)&&(task_exists(TASK+id)))
    {
        remove_task(TASK+id)
        menu_destroy(menu)
    }
    else
        showmenu(id)
       
    return PLUGIN_CONTINUE
}
public client_connect(id)
{
    new i[1]
    i[0]=id
    set_task(5.0,"check",TASK+id,i,1,"b")
}
public check(id[])
{
    showmenu(id[0])
}




sorry about my english.

drekes 06-02-2010 09:45

Re: Menu / 0 (exit doesn't dwork)
 
PHP Code:

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



Mifuntm 06-02-2010 11:24

Re: Menu / 0 (exit doesn't dwork)
 
thanks, but where i'm supposed write this code?


If You can please give me full code.

drekes 06-02-2010 12:34

Re: Menu / 0 (exit doesn't dwork)
 
PHP Code:

public menu_funkcja(id,menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    

    switch(
item)
    {
        case 
0:show_motd(id,"join_menu/rules.txt","Rules.")
        case 
1:show_motd(id,"join_menu/admins.txt","Admins.")
        case 
2:show_motd(id,"join_menu/commands.txt","Commands.")
        case 
3:show_motd(id,"join_menu/slot.txt","Slot Reservation.")
    }
    if((
item==-3)&&(task_exists(TASK+id)))
    {
        
remove_task(TASK+id)
        
menu_destroy(menu)
    }
    else
        
showmenu(id)
        
    return 
PLUGIN_CONTINUE



Mifuntm 06-02-2010 13:21

Re: Menu / 0 (exit doesn't dwork)
 
PHP Code:

#include <amxmodx>
#define TASK 2376

public plugin_init() {
    
register_plugin("Join menu","0.1","unknown")
}
public 
showmenu(id)
{
    new 
menu=menu_create("Welcome to server","menu_funkcja")
    
menu_additem(menu,"Rules")
    
menu_additem(menu,"Admins")
    
menu_additem(menu,"Commands")
    
menu_additem(menu,"Slot Reservation")
    
menu_setprop(menu,MPROP_EXITNAME,"Exit")
    
menu_display(id,menu)
    return 
PLUGIN_CONTINUE
}
public 
menu_funkcja(id,menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    

    switch(
item)
    {
        case 
0:show_motd(id,"join_menu/rules.txt","Rules.")
        case 
1:show_motd(id,"join_menu/admins.txt","Admins.")
        case 
2:show_motd(id,"join_menu/commands.txt","Commands.")
        case 
3:show_motd(id,"join_menu/slot.txt","Slot Reservation.")
    }
    if((
item==-3)&&(task_exists(TASK+id)))
    {
        
remove_task(TASK+id)
        
menu_destroy(menu)
    }
    else
        
showmenu(id)
        
    return 
PLUGIN_CONTINUE



With that menu doesn't show up at all!

drekes 06-02-2010 13:42

Re: Menu / 0 (exit doesn't dwork)
 
How do you trigger the menu? Is that your full code?

Mifuntm 06-02-2010 14:12

Re: Menu / 0 (exit doesn't dwork)
 
Menu show up automaticly after player connect.



PHP Code:

#include <amxmodx>
#define TASK 2376

public plugin_init() {
    
register_plugin("Join menu","0.1","grankee")
}
public 
showmenu(id)
{
    new 
menu=menu_create("Welcome to server","menu_funkcja")
    
menu_additem(menu,"Rules")
    
menu_additem(menu,"Admins")
    
menu_additem(menu,"Commands")
    
menu_additem(menu,"Slot")
    
menu_setprop(menu,MPROP_EXITNAME,"Close")
    
menu_display(id,menu)
    return 
PLUGIN_CONTINUE
}
public 
menu_funkcja(id,menu,item)
{
    switch(
item)
    {
        case 
0:show_motd(id,"join_menu/rules.txt","Rules.")
        case 
1:show_motd(id,"join_menu/admins.txt","Admins.")
        case 
2:show_motd(id,"join_menu/commands.txt","Commands.")
        case 
3:show_motd(id,"join_menu/slot.txt","Slot.")
    }
    if((
item==-3)&&(task_exists(TASK+id)))
    {
        
remove_task(TASK+id)
        
menu_destroy(menu)
    }
    else
        
showmenu(id)
        
    return 
PLUGIN_CONTINUE
}
public 
client_connect(id)
{
    new 
i[1]
    
i[0]=id
    set_task
(5.0,"check",TASK+id,i,1,"b")
}
public 
check(id[])
{
    
showmenu(id[0])


This its full code! menu work and show txt files in MOTD window, however you can not disable menu (option "0" Exit just doesn't work)

drekes 06-02-2010 14:22

Re: Menu / 0 (exit doesn't dwork)
 
now it works.
It didn't showed up because you didn't have the client connect stuff. I only posted the function of the menu_handler above
This is the full code
PHP Code:

#include <amxmodx>
#define TASK 2376

public plugin_init() {
    
register_plugin("Join menu","0.1","grankee")
}
public 
showmenu(id)
{
    new 
menu=menu_create("Welcome to server","menu_funkcja")
    
menu_additem(menu,"Rules")
    
menu_additem(menu,"Admins")
    
menu_additem(menu,"Commands")
    
menu_additem(menu,"Slot")
    
menu_setprop(menu,MPROP_EXITNAME,"Close")
    
menu_display(id,menu)
    return 
PLUGIN_HANDLED
}
public 
menu_funkcja(id,menu,item)
{
    if(
item == MENU_EXIT)
    {    
        
menu_destroy(menu)
        
remove_task(TASK id)
        return 
PLUGIN_HANDLED
    
}
    
    switch(
item)
    {
        case 
0:show_motd(id,"join_menu/rules.txt","Rules.")
        case 
1:show_motd(id,"join_menu/admins.txt","Admins.")
        case 
2:show_motd(id,"join_menu/commands.txt","Commands.")
        case 
3:show_motd(id,"join_menu/slot.txt","Slot.")
    }
    if((
item==-3)&&(task_exists(TASK+id)))
    {
        
remove_task(TASK+id)
        
menu_destroy(menu)
    }
    else
        
showmenu(id)
        
    return 
PLUGIN_HANDLED
}
public 
client_connect(id)
{
    new 
i[1]
    
i[0]=id
    set_task
(5.0,"check",TASK+id,i,1,"b")
}
public 
check(id[])
{
    
showmenu(id[0])



Mifuntm 06-02-2010 14:56

Re: Menu / 0 (exit doesn't dwork)
 
Quote:

Originally Posted by drekes (Post 1198147)
now it works.
It didn't showed up because you didn't have the client connect stuff. I only posted the function of the menu_handler above
This is the full code
PHP Code:

#include <amxmodx>
#define TASK 2376

public plugin_init() {
    
register_plugin("Join menu","0.1","grankee")
}
public 
showmenu(id)
{
    new 
menu=menu_create("Welcome to server","menu_funkcja")
    
menu_additem(menu,"Rules")
    
menu_additem(menu,"Admins")
    
menu_additem(menu,"Commands")
    
menu_additem(menu,"Slot")
    
menu_setprop(menu,MPROP_EXITNAME,"Close")
    
menu_display(id,menu)
    return 
PLUGIN_HANDLED
}
public 
menu_funkcja(id,menu,item)
{
    if(
item == MENU_EXIT)
    {    
        
menu_destroy(menu)
        
remove_task(TASK id)
        return 
PLUGIN_HANDLED
    
}
    
    switch(
item)
    {
        case 
0:show_motd(id,"join_menu/rules.txt","Rules.")
        case 
1:show_motd(id,"join_menu/admins.txt","Admins.")
        case 
2:show_motd(id,"join_menu/commands.txt","Commands.")
        case 
3:show_motd(id,"join_menu/slot.txt","Slot.")
    }
    if((
item==-3)&&(task_exists(TASK+id)))
    {
        
remove_task(TASK+id)
        
menu_destroy(menu)
    }
    else
        
showmenu(id)
        
    return 
PLUGIN_HANDLED
}
public 
client_connect(id)
{
    new 
i[1]
    
i[0]=id
    set_task
(5.0,"check",TASK+id,i,1,"b")
}
public 
check(id[])
{
    
showmenu(id[0])




Work perfect :)
Thanks! :crab:


All times are GMT -4. The time now is 05:21.

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