Raised This Month: $ Target: $400
 0% 

menu with spaces and crooked text


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
alexbomjovem
New Member
Join Date: Jul 2018
Location: brasil
Old 01-19-2021 , 20:10   menu with spaces and crooked text
Reply With Quote #1




can someone help me fix it


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

new gFileName[] = "menu.ini";   //Definimos el nombre de nuestro archivo.

#define MAXITEMS    10    //Definimos la cantidad de items que tendrá nuestro menú.
#define ITEMSLEN    32   //Definimos la cantidad de caracteres que podrá poseer el nombre de cada item del menu.

/* Items */
new gItems[MAXITEMS+1][ITEMSLEN+1]; //Aquí guardaremos los items de nuestro menú.

public plugin_init()
{
    
/* Plugin Registration */
    
register_plugin("[GUIA] Menu by *.ini file""0.0.1""SicknessArG");
    
    
/* Command */
    
register_clcmd("say /menu""cmdMenu");
}


public 
cmdMenu(id)
{
    new 
menu menu_create("\yMenu\w""cmdMenuHandler");   //Creamos el menú.
    
    
new Path[256];  //Creamos esta variable para luego usarla para obtener la ruta de la carpeta configs.
    
get_configsdir(Pathcharsmax(Path));   //Que RÁPIDO! ... Obtenemos la ruta a la carpeta configs.
    
formatex(Pathcharsmax(Path),"%s/%s"PathgFileName);    //Declaramos que Path ahora es la ruta a nuestro archivo.
    
    
if(!file_exists(Path))  //Chequeamos si nuestro archivo existe.
    
{
        
client_print(idprint_chat"[AMXX] El archivo %s no existe"gFileName);
        return 
PLUGIN_HANDLED;  //Sino, paramos ahí y no hacemos mas nada y seguís leyendo al pedo.
    
}
    
    new 
fopen(Path"rt");  //Si existe, leemos el texto del archivo (r = read) (t = text).
    
    
new iName[ITEMSLEN+1];  //Creamos una variable para el nombre de cada item del menu.
    
new Item;   //Creamos una variable para el numero de cada item.
    
    
while(!feof(f)) //Mientras que nuestro archivo este abierto...
    
{
        
fgets(fiNamecharsmax(iName));   //Obtenemos el nombre de cada item y lo guardamos dentro de la variable iName.

        
if(!iName[0] || iName[0] == ';'   //(No necesario, pero sirve), esto es para que si en el archivo un texto comienza con
        
|| iName[0] == '/' && iName[1] == '/' ) continue;   // ; o // no sea leído y por lo tanto no aparezca en nuestro menú.
        
        
copy(gItems[Item], charsmax(gItems), iName);    //Copiamos cada item dentro de la variable gItems.
        
Item++;      //Aumentamos la cantidad de items, cuyo valor es igual a la cantidad puesta en el archivo ini
                            //pero menor o igual a la cantidad definida en MAXITEMS.
                                    
        
if(Item >= MAXITEMS) break;   //Porque si la cantidad de items supera a MAXITEMS se rompe el loop y no continua nuestro plugin.
        
        
menu_additem(menuiNamegItems[Item]);        //Pero sino, adherimos cada item en el menú.
    
}
    
fclose(f);  //Cerramos nuestro archivo.
    
    
menu_display(idmenu); //Mostramos el menú.
    
return PLUGIN_HANDLED;
}

public 
cmdMenuHandler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
iData[6];
    new 
iName[ITEMSLEN+1];
    new 
Access;
    new 
Callback;
    
menu_item_getinfo(menuitemAccessiDatacharsmax(iData), iNamecharsmax(iName), Callback);

    
client_print(idprint_chat"Haz elegido %s"iName);  //Y al elegir un item se mostrará el nombre en el chat.
        
    
menu_destroy(menu);  //Cerramos el menú.
    
return PLUGIN_HANDLED;  //FIN.

file.ini where the menu fetches the items to add
PHP Code:
ORIGINAL
amarela
BRANCA
LARANJA
FACÃO
MACHADO 

Last edited by alexbomjovem; 01-19-2021 at 23:53.
alexbomjovem is offline
 



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 10:37.


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