AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu issue (https://forums.alliedmods.net/showthread.php?t=131989)

#8 SickneSS 07-10-2010 18:26

Menu issue
 
I have made a menu and in Exit option I want to make other option (Do random),but when I use them,debug shows me...

Code:

L 07/10/2010 - 19:13:56: Plugin called menu_display when item=MENU_EXIT
L 07/10/2010 - 19:13:56: [AMXX] Displaying debug trace (plugin "Untitled.amxx")
L 07/10/2010 - 19:13:56: [AMXX] Run time error 10: native error (native "menu_display")

How I can make the option using the EXIT option?
is new menu

wrecked_ 07-11-2010 00:14

Re: Menu issue
 
Show us your code, please.

#8 SickneSS 07-11-2010 07:56

Re: Menu issue
 
PHP Code:

public MenuWinner(Winner) {
    
    new 
Menu menu_create("\r[AMXX]\y Elige un teammate :","MenuWinnerHandler")
    
    new 
Players[32
    new 
Num
    get_players
(Players,Num)
    
    for(new 
0;<= Num;i++)
    {
        if(
is_user_connected(i) && cs_get_user_team(i) == CS_TEAM_SPECTATOR)
        {
            new 
name[32]
            
get_user_name(i,name,31)
            
            new 
temp[32]
            
num_to_str(i,temp,31)
            
            
menu_additem(Menu,name,temp,_,menu_makecallback("WinnerCallback"))
        }
    }
    
    
menu_setprop(Menu,MPROP_BACKNAME,"Atras")
    
menu_setprop(Menu,MPROP_NEXTNAME,"Siguiente^n")
    
menu_setprop(Menu,MPROP_EXITNAME,"Random")
    
    
menu_display(Winner,Menu)
}
//----------------------------------------------------------//
public WinnerCallback(Winner,Menu,item
    return 
Choosing[Winner] ? ITEM_ENABLED ITEM_DISABLED

//----------------------------------------------------------//
public MenuWinnerHandler(Winner,Menu,item) {
    
    new 
name[32]
    
get_user_name(Winner,name,31)
    
    if(
item == MENU_EXIT)
    {
        
RandomPlayer(Winner)
        
ChatColor(0,"!y[!gAMXX!y] %s hizo una eleccion random",name)
    }
    
    new 
iData[6]
    new 
iName[64]
    new 
Access
    
new Callback
    menu_item_getinfo
(Menu,item,Access,iData,5,iName,63,Callback)
    
    new 
Choosed str_to_num(iData)
    
    if(
Choosed)
    {
        
cs_set_user_team(Choosed,cs_get_user_team(Winner))
        
ChatColor(0,"!y[!gAMXX!y] %s eligio a %s como su teammate",name,iName)
    }
    
    if(
item == MENU_EXIT)
    {
        
RandomPlayer(Winner)
        
ChatColor(0,"!y[!gAMXX!y] %s hizo una eleccion random",name)
    }
        
    
Choosing[Winner] = false
    
    Choosing
[Looser] = true
    MenuLooser
(Looser)
    
    
menu_display(Winner,Menu)
    return 
PLUGIN_HANDLED



fezh 07-11-2010 13:44

Re: Menu issue
 
Dunno about your error, I'm lazy to read, but in the first view I noticed this (see highlighted lines):
Code:
public MenuWinner(Winner) {         new Menu = menu_create("\r[AMXX]\y Elige un teammate :","MenuWinnerHandler")         new Players[32]     new Num     get_players(Players,Num)         for(new i = 0;i <= Num;i++)     {         if(is_user_connected(i) && cs_get_user_team(i) == CS_TEAM_SPECTATOR)         {             new name[32]             get_user_name(i,name,31)                         new temp[32]             num_to_str(i,temp,31)                         menu_additem(Menu,name,temp,_,menu_makecallback("WinnerCallback"))         }     }         menu_setprop(Menu,MPROP_BACKNAME,"Atras")     menu_setprop(Menu,MPROP_NEXTNAME,"Siguiente^n")     menu_setprop(Menu,MPROP_EXITNAME,"Random")         menu_display(Winner,Menu) }
It's a major error creating variables in loops.

#8 SickneSS 07-11-2010 14:01

Re: Menu issue
 
Quote:

Originally Posted by fezh (Post 1235585)
Dunno about your error, I'm lazy to read, but in the first view I noticed this (see highlighted lines)
It's a major error creating variables in loops.

Okay Thanks!


All times are GMT -4. The time now is 07:04.

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