Raised This Month: $ Target: $400
 0% 

"Menu" dont works


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 06-25-2014 , 09:50   "Menu" dont works
Reply With Quote #1

i made one menu for my server , i don't see any error :/

Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("alienmodon","Go_Menu")     register_event( "DeathMsg" , "DeathMsgEvent" , "a" );     register_event("HLTV", "event_new_round", "a", "1=0", "2=0")       register_event("CurWeapon" , "Event_CurWeapon" , "be" , "1=1" );     RegisterHam(Ham_TakeDamage, "player", "TakeDamage");     maxplayers = get_maxplayers()     alien_actived = false } public Go_Menu(id) {     if(get_user_flags(id) & ADMIN_MENU)     {         alienmenu(id)     }     client_print_color(id, RED, "No tienes acceso a este Menu") } public alienmenu(id) {     new temp1[32]     new temp2[2]     new Menu = menu_create("Players:","Alien_Menu")           for (new i = 1; i <= maxplayers; i++){         if (is_user_connected(i))         {         get_user_name(i,temp1,32);         num_to_str(i,temp2,2);         menu_additem(Menu, temp1,temp2);         }     }     menu_display(id, Menu, 0);   }     public Alien_Menu(id, Menu, item) {     if (item == MENU_EXIT)     {         menu_destroy(Menu)         return PLUGIN_HANDLED     }         new iData[6];     new iAccess;     new iCallback;     new iName[64];     menu_item_getinfo(Menu, item, iAccess, iData, 5, iName, 63, iCallback)         new iplayer = str_to_num(iData)     PlayerAlien = iplayer     alien_actived = true     empezarrondaalien(iplayer)     client_print(id,print_chat,"Hiciste alien a %s",iName)                       return PLUGIN_HANDLED }
Porta0123 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-25-2014 , 11:14   Re: "Menu" dont works
Reply With Quote #2

Explain what doesn't work.
HamletEagle is offline
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 06-25-2014 , 11:24   Re: "Menu" dont works
Reply With Quote #3

i find where is the error but i dont know what is wrong

the line is:
Code:
for (new i = 1; i <= maxplayers; i++)     {         if (is_user_connected(i))         {         get_user_name(i,temp1,32);         num_to_str(i,temp2,2);         menu_additem(Menu, temp1,temp2);         }     }
the menu dont open

Last edited by Porta0123; 06-25-2014 at 11:25.
Porta0123 is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 06-25-2014 , 16:05   Re: "Menu" dont works
Reply With Quote #4

Next time please tell us the error so people that want to help you don't have to guess.

If your array is 32 large it only fits 31 characters because you need to include the null terminator at the end of the string. You need to use 31 and 1 as your array size parameters for get_user_name and num_to_str (and the temp2 array is therefore too small to hold your double digit integers). Please use the charsmax macro to avoid simple mistakes like this in the future:

PHP Code:
get_user_name(i,temp1charsmax(temp1));         
num_to_str(i,temp2charsmax(temp2)); 
charsmax(variable) expands to sizeof(variable)-1 and will always give you the correct integer to pass into string handling functions.
__________________
In Flames we trust!
Nextra is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-26-2014 , 15:59   Re: "Menu" dont works
Reply With Quote #5

Have a look at this example
mottzi is offline
Send a message via MSN to mottzi
devilicioux
Veteran Member
Join Date: Jun 2013
Location: Delhi,India
Old 06-27-2014 , 03:07   Re: "Menu" dont works
Reply With Quote #6

Quote:
Next time please tell us the error so people that want to help you don't have to guess.
+ You can find the actual error in amxmodx/logs folder.
__________________
You keep bringing ANTICHRISTUS down .. He will rise again and kick asses !

#RespectList ANTICHRISTUS fysiks Bugsy

Most Common Errors You Can Encounter Every Now and Then
devilicioux is offline
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 06-30-2014 , 10:34   Re: "Menu" dont works
Reply With Quote #7

fixed Ty
Porta0123 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 21:05.


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