Raised This Month: $51 Target: $400
 12% 

[TUT] Como hacer un Menu con un For.


  
 
 
Thread Tools Display Modes
Author Message
Kiske
Veteran Member
Join Date: May 2009
Old 11-22-2009 , 07:52   [TUT] Como hacer un Menu con un For.
#1

Tutorial: Como hacer un Menu con un For.
Descripcion: Les voy a enseñar como crear un Menu con un For (Loop).
Tiempo Estimado en Hacerlo: Entre 10 y 15 Minutos.

PHP Code:
#include <amxmodx>

#define PLUGIN "Menu con For"
#define AUTHOR "Kiske"
#define VERSION "1.0"

#define LISTA_ANIMALES 10 // Ponemos que LISTA_ANIMALES es Igual a 10.
new const Rank[LISTA_ANIMALES][] = { "Cerdo""Pajaro""Pinguino""Elefante""Chancho""Perro""Gato""Loro""Cacatua""Dinosaurio" // Lista de Animales. Tiene que tener la misma cantidad de Lugares, que le asignamos a "LISTA_ANIMALES". En este caso 10.

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /menu""MenuConFor")
    
register_clcmd("say_team /menu""MenuConFor")
}

public 
MenuConFor(id)
{
    new 
Animales[50], Posicion[10// Creamos 2 Variables.
    
new menu menu_create("\yLista de Animales""MenuAnimales"// Creamos el Menu con su Nombre.
    
    
for(new 0LISTA_ANIMALESi++) // Creamos el Loop, y ponemos: "i = 0 [i es igual a 0]", "i < LISTA_ANIMALES [si i es menor a LISTA_ANIMALES(10)]", "i++ [i aumenta en 1]".
    
{
        
formatex(Animalescharsmax(Animales), "Animal %d: \y%s\w!"iRank[i]) // Creamos un Formatex poniendo que la Variable "Animales" va a ser igual a el TEXTO escrito ahi.
        
num_to_str(iPosicioncharsmax(Posicion)) // Pasamos un Numero a un String: "i(num) lo pasamos a Posicion(string)".
        
menu_additem(menuAnimalesPosicion// Creamos un nuevo Item en el Menu, con el Texto y la Posicion.
    
}
    
    
menu_setprop(menuMPROP_NEXTNAME"Pagina Siguiente"// Nombre para pasar la a la Pagina Siguiente.
    
menu_setprop(menuMPROP_BACKNAME"Pagina Anterior"// Nombre para pasar la a la Pagina Anterior.
    
menu_setprop(menuMPROP_EXITNAME"Salir"// Nombre para Salir del Menu.
    
    
menu_display(idmenu0// Ponemos que cuando abra el Menu, aparesca en la Pagina 0. DEFAULT!.
    
return PLUGIN_HANDLED// Ponemos esto para que no de noticia en el Say que escribimos algo para abrir el menu.
}

public 
MenuAnimales(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
    switch(
str_to_num(data))
    {
        case 
1..10: return PLUGIN_HANDLED
    
}
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED



Si tuvimos exito, nuestro Menu se tendria que ver asi:
[IMG]http://img72.**************/img72/1120/123vp.png[/IMG]


Gracias larito ya sabes el porque ^^.
__________________


Last edited by Kiske; 11-22-2009 at 07:57.
Kiske is offline
Send a message via Skype™ to Kiske
Fraancooo-.
BANNED
Join Date: Aug 2009
Location: CLICK HERE
Old 11-22-2009 , 07:55   Re: [ES][TUT] Como hacer un Menu con un For.
#2

Excelente tutorial
@Kiske: esta bastante bien explicado cosa qe no vi muchos tutoriales asi ;O
Pregunta:
Quote:
%d: \y%s\w!
para qe es eso?:E
Fraancooo-. is offline
Send a message via MSN to Fraancooo-.
fechu
BANNED
Join Date: Sep 2009
Location: aliedmod
Old 11-22-2009 , 07:56   Re: [ES][TUT] Como hacer un Menu con un For.
#3

que beun tuto kiske,
grax por ayudar
fechu is offline
Send a message via MSN to fechu Send a message via Skype™ to fechu
Kiske
Veteran Member
Join Date: May 2009
Old 11-22-2009 , 07:57   Re: [ES][TUT] Como hacer un Menu con un For.
#4

Quote:
Originally Posted by Fraancooo-. View Post
Excelente tutorial
@Kiske: esta bastante bien explicado cosa qe no vi muchos tutoriales asi ;O
Pregunta:

para qe es eso?:E
%d: Inidica que lo que va a reemplazar eso va a ser un NUMERO ENTERO.
\y: El texto que siga despues de eso, va a estar en COLOR AMARILLO.
%s: Inidica que lo que va a reemplazar eso va a ser un STRING (Texto).
\w: El texto que siga despues de eso, va a estar en COLOR BLANCO (Default).
__________________

Kiske is offline
Send a message via Skype™ to Kiske
Fraancooo-.
BANNED
Join Date: Aug 2009
Location: CLICK HERE
Old 11-22-2009 , 07:58   Re: [ES][TUT] Como hacer un Menu con un For.
#5

Quote:
Originally Posted by Kiske View Post
%d: Inidica que lo que va a reemplazar eso va a ser un NUMERO ENTERO.
\y: El texto que siga despues de eso, va a estar en COLOR AMARILLO.
%s: Inidica que lo que va a reemplazar eso va a ser un STRING (Texto).
\w: El texto que siga despues de eso, va a estar en COLOR BLANCO (Default).
Oka gracias kiske
lo del texto ya lo sabia nada más qe no me lo acordaba u.u
Fraancooo-. is offline
Send a message via MSN to Fraancooo-.
Raddish
BANNED
Join Date: Jul 2008
Location: Argentina
Old 11-22-2009 , 08:02   Re: [ES][TUT] Como hacer un Menu con un For.
#6

Exelente.. groso=D
Raddish is offline
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 11-22-2009 , 08:11   Re: [ES][TUT] Como hacer un Menu con un For.
#7

Es mas optimizado hacerlo asi que de la manera normal ?
__________________
Javivi is offline
Kiske
Veteran Member
Join Date: May 2009
Old 11-22-2009 , 08:13   Re: [ES][TUT] Como hacer un Menu con un For.
#8

Quote:
Originally Posted by Javivi View Post
Es mas optimizado hacerlo asi que de la manera normal ?
No se si MAS OPTIMIZADO, pero menos trabajo seguro ^^!
__________________

Kiske is offline
Send a message via Skype™ to Kiske
Javivi
AlliedModders Donor
Join Date: Dec 2008
Old 11-22-2009 , 09:08   Re: [ES][TUT] Como hacer un Menu con un For.
#9

Si, es mas cómodo

PHP Code:
#include <amxmodx>

#define PLUGIN "Menu de redireccion"
#define VERSION "1.0"
#define AUTHOR ""

new cvar_sv0cvar_sv1cvar_sv2cvar_sv3


#define SERVIDORES_MAX 4
new const Rank[SERVIDORES_MAX][] = { "GunGame""Hide n Seek""Publico""Deathrun"

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /server""MenuServidores")
    
    
cvar_sv0 register_cvar("amx_ip_sv0""1.0.0.1")
    
cvar_sv1 register_cvar("amx_ip_sv1""0.1.1.0")
    
cvar_sv2 register_cvar("amx_ip_sv2""0.1.1.0")
    
cvar_sv3 register_cvar("amx_ip_sv3""1.0.0.1")
}

public 
MenuServidores(id)
{
    static  
Servidores[50], Posicion[10]
    new 
menu menu_create("\yLista de servidores""MenuServers")
    
    for(new 
0SERVIDORES_MAXi++) 
    {
        
formatex(Servidorescharsmax(Servidores), "Servidor %d: \y%s"iRank[i])
        
num_to_str(iPosicioncharsmax(Posicion)) 
        
menu_additem(menuServidoresPosicion)
    }
    
    
menu_setprop(menuMPROP_NEXTNAME"Siguiente")
    
menu_setprop(menuMPROP_BACKNAME"Anterior")
    
menu_setprop(menuMPROP_EXITNAME"Salir")
    
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED
}

public 
MenuServers(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
    switch(
str_to_num(data))
    {
        case 
0client_cmd(id"Connect %s"cvar_sv0)
        case 
1client_cmd(id"Connect %s"cvar_sv1)
        case 
2client_cmd(id"Connect %s"cvar_sv2)
        case 
3client_cmd(id"Connect %s"cvar_sv3)
    }
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED

__________________
Javivi is offline
Raddish
BANNED
Join Date: Jul 2008
Location: Argentina
Old 11-22-2009 , 09:09   Re: [ES][TUT] Como hacer un Menu con un For.
#10

Quote:
Originally Posted by Javivi View Post
Si, es mas cómodo

PHP Code:
#include <amxmodx>

#define PLUGIN "Menu de redireccion"
#define VERSION "1.0"
#define AUTHOR "Javivi"

new cvar_sv0cvar_sv1cvar_sv2cvar_sv3


#define SERVIDORES_MAX 4
new const Rank[SERVIDORES_MAX][] = { "GunGame""Hide n Seek""Publico""Deathrun"

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /server""MenuServidores")
    
    
cvar_sv0 register_cvar("amx_ip_sv0""1.0.0.1")
    
cvar_sv1 register_cvar("amx_ip_sv1""0.1.1.0")
    
cvar_sv2 register_cvar("amx_ip_sv2""0.1.1.0")
    
cvar_sv3 register_cvar("amx_ip_sv3""1.0.0.1")
}

public 
MenuServidores(id)
{
    static  
Servidores[50], Posicion[10]
    new 
menu menu_create("\yLista de servidores""MenuServers")
    
    for(new 
0SERVIDORES_MAXi++) 
    {
        
formatex(Servidorescharsmax(Servidores), "Servidor %d: \y%s"iRank[i])
        
num_to_str(iPosicioncharsmax(Posicion)) 
        
menu_additem(menuServidoresPosicion)
    }
    
    
menu_setprop(menuMPROP_NEXTNAME"Siguiente")
    
menu_setprop(menuMPROP_BACKNAME"Anterior")
    
menu_setprop(menuMPROP_EXITNAME"Salir")
    
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED
}

public 
MenuServers(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
    switch(
str_to_num(data))
    {
        case 
0client_cmd(id"Connect %s"cvar_sv0)
        case 
1client_cmd(id"Connect %s"cvar_sv1)
        case 
2client_cmd(id"Connect %s"cvar_sv2)
        case 
3client_cmd(id"Connect %s"cvar_sv3)
    }
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED

te falto las screenshot xD,

pd:las ip son binarios o.O
Raddish 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 03:46.


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