AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   "Menu" dont works (https://forums.alliedmods.net/showthread.php?t=242817)

Porta0123 06-25-2014 09:50

"Menu" dont works
 
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 }

HamletEagle 06-25-2014 11:14

Re: "Menu" dont works
 
Explain what doesn't work.

Porta0123 06-25-2014 11:24

Re: "Menu" dont works
 
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

Nextra 06-25-2014 16:05

Re: "Menu" dont works
 
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.

mottzi 06-26-2014 15:59

Re: "Menu" dont works
 
Have a look at this example

devilicioux 06-27-2014 03:07

Re: "Menu" dont works
 
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.

Porta0123 06-30-2014 10:34

Re: "Menu" dont works
 
fixed :3 Ty


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

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