[ M E N U ] Kill Fade
#1
Simple screen fade, con menu y diferentes colores como opcion
PD: SIMPLE
Código PHP:
/* Kill Fade MDSIGN */

#include <amxmodx>
#include <fvault> 

new gz_Plugin [ ] [ ] = { "KillFade Menu""v1.0""|Alejandro-." }

new 
guardar_datos [ ] = "ColorSelecionado";

public 
plugin_init()
{

    
register_plugin(gz_Plugin ], gz_Plugin ], gz_Plugin ])
    
register_clcmd("say /screen""Menu_Screen")
    
register_event"DeathMsg""DeathMsg""a" );

}

enum _:Data_Color
{
    
Name 32 ],
    
red,
    
green,
    
blue
}

new 
gz_Colores [ ] [Data_Color] = 
{
    {   
"Blanco",     255,    255,    255    },
    {   
"Negro",      0,      0,      0      },
    {   
"Amarillo",   255,    255,    0      },
    {   
"Rojo",       255,    0,      0      },
    {   
"Verde",      0,      255,    0      }



new 
g_select 33 ];

public 
DeathMsg()
{
    new 
Atacante read_data(1);

/* \\\ S C R E E N   F A D E /// */
    
if(!is_user_alive(Atacante)) return PLUGIN_HANDLED;
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("ScreenFade"), _Atacante)
    
write_short(<< 12)
    
write_short(<< 12)
    
write_short(0x0000)
    
write_byte(gz_Colores g_select Atacante ] ] [red]) //rojo
    
write_byte(gz_Colores g_select Atacante ] ] [green]) //verde
    
write_byte(gz_Colores g_select Atacante ] ] [blue]) //azul
    
write_byte(100)
    
message_end()
    return 
PLUGIN_HANDLED;
/* \\\ S C R E E N   F A D E /// */




/* \\\ M E N U /// */

public Menu_Screen (id) {
    new 
menuSelect 200 ];
    
menu menu_create("\wScrenn Fade^nBy: |Alejandro-.""Items"

    for(new 
0sizeof gz_Coloresi++) {

    if( 
g_selectid ] == )
    {
    
formatexSelectcharsmax(Select), "\w%s \r[ \yACTUAL \r]"gz_Colores ] [Name] );
    
menu_additemmenuSelect);
    }
    else 
menu_additem(menugz_Colores ] [Name])
    }
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
Items(idmenuitem) {

    if ( 
item == MENU_EXIT ) {

        
menu_destroymenu )
    return 
PLUGIN_HANDLED;
    }

    if( 
g_select id ] == item )
    {
        
client_printidprint_center"* Ya elegiste este color *");
        return 
PLUGIN_HANDLED;
    }

    
g_select id ] = item;
    return 
PLUGIN_HANDLED;



/* \\\ M E N U /// */

/* \\\ G U A R D A D O /// */
vault_guardar_datos(id)
{
        new 
data[4]; formatex(datacharsmax(data), "%d"g_select[id]) // ponemos sus puntos en un string
        
new iName[33]; get_user_name(idiNamecharsmax(iName)) //obtenemos su nombre y lo almacenamos en iName
        
fvault_set_data(guardar_datosiNamedata// Guardamos el nombre y los dato de la variable creada (vault_variable)


vault_cargar_datos(id)
{
        new 
data[4], iName[33]; get_user_name(idiNamecharsmax(iName))
        if(
fvault_get_data(guardar_datosiNamedatacharsmax(data))) 
        
g_select[id] = str_to_num(data)


public 
client_putinserver(id)
{
        
g_select id ] = 0
        vault_cargar_datos
(id)


public 
client_disconnect(id)
{
        
vault_guardar_datos(id)

Responder
#2
Cutecry
"Cada golpe es una lección, y cada lección te hace mejor."

[Imagen: b_350_20_000000_8a7300_ffffff_eeff00.png]
[Imagen: 76561198371193937.png]
Responder
#3
(24/11/2018, 11:56 PM)rojedafeik escribió: Cutecry

Whatdone
Responder
#4
Código:
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), _, Atacante)

Mejor en plugin_init() ->
Código:
g_iMsgScreenFade = get_user_msgid("ScreenFade");
o en la misma función:
Código:
static iMsgScreenFade; if(!iMsgScreenFade) iMsgScreenFade = get_user_msgid("ScreenFade");
Simpificamos:
Código:
message_begin(MSG_ONE_UNRELIABLE, iMsgScreenFade, .player = Atacante)

En
Código:
vault_guardar_datos(id)
->
Código:
new iName[33];
No es un número entero, más bien sería szName[33]. Además, el máximo debe ser de 32 para el nombre del jugador, y mejor, usar
Código:
MAX_NAME_LENGTH
->
Código:
new szName[MAX_NAME_LENGTH]
Plugins:
En GitHub
Responder
#5
Código PHP:
if ( item == MENU_EXIT ) {

        
menu_destroymenu )

    } 
->
Código PHP:
if ( item == MENU_EXIT ) {

        
menu_destroymenu )
        return 
PLUGIN_HANDLED;
    } 

es posible que le piques a salir y te de index of bounds Whatever
[Imagen: zcsztw-4.png] [Imagen: 6u5fj2-4.png]
[Imagen: linkedin_thumb_image.png][Imagen: 76561198283253977.png][Imagen: linkedin_thumb_image.png]
Responder
#6
+ a lo de antes:
Código:
new g_select [ 33 ]
Mejor usar constantes:
Código:
new g_select [MAX_PLAYERS+1];
Plugins:
En GitHub
Responder
#7
(25/11/2018, 02:32 PM)w0w escribió:
Código:
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), _, Atacante)

Mejor en plugin_init() ->
Código:
g_iMsgScreenFade = get_user_msgid("ScreenFade");
o en la misma función:
Código:
static iMsgScreenFade; if(!iMsgScreenFade) iMsgScreenFade = get_user_msgid("ScreenFade");
Simpificamos:
Código:
message_begin(MSG_ONE_UNRELIABLE, iMsgScreenFade, .player = Atacante)

En
Código:
vault_guardar_datos(id)
->
Código:
new iName[33];
No es un número entero, más bien sería szName[33]. Además, el máximo debe ser de 32 para el nombre del jugador, y mejor, usar
Código:
MAX_NAME_LENGTH
->
Código:
new szName[MAX_NAME_LENGTH]

Para que registrar el mensaje si solo lo ocupa en una sola función (?)

Responder
#8
(26/11/2018, 01:38 AM)Skylar escribió:
(25/11/2018, 02:32 PM)w0w escribió:
Código:
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("ScreenFade"), _, Atacante)

Mejor en plugin_init() ->
Código:
g_iMsgScreenFade = get_user_msgid("ScreenFade");
o en la misma función:
Código:
static iMsgScreenFade; if(!iMsgScreenFade) iMsgScreenFade = get_user_msgid("ScreenFade");
Simpificamos:
Código:
message_begin(MSG_ONE_UNRELIABLE, iMsgScreenFade, .player = Atacante)

En
Código:
vault_guardar_datos(id)
->
Código:
new iName[33];
No es un número entero, más bien sería szName[33]. Además, el máximo debe ser de 32 para el nombre del jugador, y mejor, usar
Código:
MAX_NAME_LENGTH
->
Código:
new szName[MAX_NAME_LENGTH]

Para que registrar el mensaje si solo lo ocupa en una sola función (?)

DeathMsg() no se usa solo una vez. Tiene sentido sacar el ID del mensaje una vez para no estar sacándolo constantemente.
Plugins:
En GitHub
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)