25/04/2020, 12:39 AM
(Última modificación: 25/04/2020, 12:40 AM por Nazy.-. Edited 1 time in total.)
TEMA ORIGINAL (SIN NIVELES NI NADA)
https://amxmodx-es.com/Thread-ZP-Menu-de-Hats
Quiero aclarar que yo solo le agregué un sistema de niveles y reset, por si alguien lo quiere.
Paso 1.
Paso 2.
Paso 3.
Paso 4.
Paso final
Si quieren que suba todos los hats me avisan, pero el link por mega ya que creo que no puedo subir tanto archivos xD o si no lo subo en .rar, recuerden que si tienen algún error revisen el POST ORIGINAL, esto es igualmente el tutorial desde 0 pero con los niveles y eso, si lo quieren SIN NIVELES/RESET vayan al post original, para quitar niveles o reset es muy fácil, si no saben les digo xD
https://amxmodx-es.com/Thread-ZP-Menu-de-Hats
Quiero aclarar que yo solo le agregué un sistema de niveles y reset, por si alguien lo quiere.
Paso 1.
Nos vamos a dirigir a poner todas las variables y constantes, hagan esto antes de todos los public y ponganlo en un lugar donde se vea organizado, en mi opinión pa que no se enreden
Código PHP:
new g_hat[33], g_ent[33]
enum _:Hat_Info { Hat_Name[90] , Hat_Model[90], Hat_Level[90], Hat_Reset[90] }
new const Hats[][Hat_Info] =
{
// Nombre // Mdl //Nivel-Reset
{ "Ninguno", "default", 0, 0 },
{ "Bomba", "models/wkz_zombiexterminio/wkz_hats/bomba.mdl", 10, 0 },
{ "Clon", "models/wkz_zombiexterminio/wkz_hats/clon_1.mdl", 20, 0 },
{ "Mario Bros", "models/wkz_zombiexterminio/wkz_hats/mario.mdl", 30, 0 },
{ "Mr. Cerebron", "models/wkz_zombiexterminio/wkz_hats/marsjanin.mdl", 40, 0 },
{ "Mono", "models/wkz_zombiexterminio/wkz_hats/monin.mdl", 50, 0 },
{ "Perro", "models/wkz_zombiexterminio/wkz_hats/rotwaila.mdl", 60, 0 },
{ "The Scream", "models/wkz_zombiexterminio/wkz_hats/scream.mdl", 80, 0 },
{ "Sonic Uganda", "models/wkz_zombiexterminio/wkz_hats/uganda.mdl", 90, 0 },
{ "Oso Polar", "models/wkz_zombiexterminio/wkz_hats/polarbear_back.mdl", 100, 0 },
{ "Minecraft", "models/wkz_zombiexterminio/wkz_hats/minecraft.mdl", 130, 0 },
{ "Gazowa", "models/wkz_zombiexterminio/wkz_hats/gazowa.mdl", 160, 0 },
{ "Egypto", "models/wkz_zombiexterminio/wkz_hats/egypt_back.mdl", 200, 0 },
{ "Dr. Doom", "models/wkz_zombiexterminio/wkz_hats/drdoom.mdl", 250, 0 },
{ "Fantasma", "models/wkz_zombiexterminio/wkz_hats/fantasma.mdl", 300, 0 },
{ "Sting-Finger", "models/wkz_zombiexterminio/wkz_hats/fantasma.mdl", 350, 0 },
{ "Bicho", "models/wkz_zombiexterminio/wkz_hats/fantasma.mdl", 400, 0 },
{ "Bomba Infeccion", "models/wkz_zombiexterminio/wkz_hats/fantasma.mdl", 450, 0 },
// HATS POR NIVEL + RESET
{ "Sombrero Pirata", "models/wkz_zombiexterminio/wkz_hats/pirata-r1.mdl", 5, 1 },
{ "Angelito", "models/wkz_zombiexterminio/wkz_hats/angel-r2.mdl", 10, 2 },
{ "Diablillo", "models/wkz_zombiexterminio/wkz_hats/diablo-r3.mdl", 15, 3 },
{ "Calabazin", "models/wkz_zombiexterminio/wkz_hats/calabaza-r4.mdl", 20, 4 },
{ "Capa Heroica", "models/wkz_zombiexterminio/wkz_hats/capa-r5.mdl", 25, 5 }
}
Paso 2.
Nos vamos a donde dice
Justo abajo de
Ponemos
Quedaría asi:
Código PHP:
// Ham Player Spawn Post Forward
Justo abajo de
Código PHP:
g_isalive[id] = true
Ponemos
Código PHP:
SetHat(id, 0)
Quedaría asi:
Código PHP:
// Ham Player Spawn Post Forward
public fw_PlayerSpawn_Post(id)
{
// Not alive or didn't join a team yet
if (!is_user_alive(id) || !fm_cs_get_user_team(id))
return;
// Player spawned
g_isalive[id] = true
// Hat - Si/No
SetHat(id, 0)
// EL RESTO DEL CODIGO
Paso 3.
Nos vamos a dirigir a public plugin_precache y abajo de:
Vamos a agregar lo siguiente:
De tal forma que va a quedar un resultado asi:
Código PHP:
new i, buffer[100]
Vamos a agregar lo siguiente:
Código PHP:
// Hats
for(new i = 0 ;i < sizeof Hats; i++)
{
if(!(equal(Hats[i][Hat_Model] , "default")))
precache_model(Hats[i][Hat_Model])
}
De tal forma que va a quedar un resultado asi:
Código PHP:
// Allow registering stuff now
g_arrays_created = true
// Load customization data
load_customization_from_files()
new i, buffer[100]
// Hats
for(new i = 0 ;i < sizeof Hats; i++)
{
if(!(equal(Hats[i][Hat_Model] , "default")))
precache_model(Hats[i][Hat_Model])
}
Paso 4.
Vamos al finar de todo el plugin y agregamos el siguiente codigo:
Y luego abajo de esa función agregamos el resto del código:
ATENCIÓN:
Cambien "kReset" y "kNivel" por su variable de niveles y reset, ya puede ser "g_level", "g_reset" y también para que no les salte error el "ColorChat" cambienlo por "client_print" o su variable para agregar un mensaje de color algo asi:
Código PHP:
// Hat - Colocar/Quitar
public SetHat(id, quit)
{
if(!is_user_alive(id))
return
new ent = g_ent[id];
new infotarget = engfunc(EngFunc_AllocString, "info_target");
engfunc(EngFunc_RemoveEntity, ent);
g_ent[id] = ent = engfunc (EngFunc_CreateNamedEntity, infotarget);
set_pev(ent, pev_movetype, MOVETYPE_FOLLOW);
set_pev(ent, pev_aiment, id);
if((equal(Hats[g_hat[id]][Hat_Model] , "default")) || quit == 1)
engfunc(EngFunc_SetModel, ent, "");
else
engfunc(EngFunc_SetModel, ent, Hats[g_hat[id]][Hat_Model]);
}
Y luego abajo de esa función agregamos el resto del código:
Código PHP:
public MenuHats(id)
{
new len[999] , temp[22]
static Item[64]
formatex(Item, charsmax(Item), "\r[ZEX] \yMenu de Sombreros\r")
new menu_hats2 = menu_create(Item, "hats_menu")
for(new i = 0 ; i < sizeof Hats; i++)
{
// Si el jugador no cumple con el nivel de este, el nombre del hat se vera oscuro
if(kNivel[id] < Hats[i][Hat_Level]) formatex(len , charsmax(len) , "\d%s \r(N: %d - R: %d)" , Hats[i][Hat_Name], Hats[i][Hat_Level], Hats[i][Hat_Reset])
else formatex(len , charsmax(len) , "\w%s \r(N: %d - R: %d)" , Hats[i][Hat_Name], Hats[i][Hat_Level], Hats[i][Hat_Reset])
// Si el jugador no cumple con el reset de este, el nombre del hat se vera oscuro
if(kReset[id] < Hats[i][Hat_Reset]) formatex(len , charsmax(len) , "\d%s \r(N: %d - R: %d)" , Hats[i][Hat_Name], Hats[i][Hat_Level], Hats[i][Hat_Reset])
else formatex(len , charsmax(len) , "\w%s \r(N: %d - R: %d)" , Hats[i][Hat_Name], Hats[i][Hat_Level], Hats[i][Hat_Reset])
if(g_hat[id] == i) formatex(len , charsmax(len) , "\w%s \r[\yEQUIPADO\r]" , Hats[i][Hat_Name])
else formatex(len , charsmax(len) , "\w%s \r(N: %d - R: %d)" , Hats[i][Hat_Name], Hats[i][Hat_Level], Hats[i][Hat_Reset])
num_to_str(i,temp, 2)
menu_additem(menu_hats2 , len , temp)
}
formatex(Item, charsmax(Item), "\yVolver")
menu_setprop(menu_hats2 , MPROP_BACKNAME, Item)
formatex(Item, charsmax(Item), "\ySiguiente")
menu_setprop(menu_hats2 , MPROP_NEXTNAME, Item)
formatex(Item, charsmax(Item), "\ySalir")
menu_setprop(menu_hats2 , MPROP_EXITNAME, Item)
menu_display(id, menu_hats2 , 0)
return PLUGIN_HANDLED
}
public hats_menu(id , menu_hats2 , item)
{
new page , buffer
player_menu_info(id , menu_hats2 , buffer , page)
if(g_hat[id] == item)
{
MenuHats(id)
return PLUGIN_HANDLED;
}else{
if(kNivel[id] < Hats[item][Hat_Level])
{
ColorChat(id, print_chat, "%s !yNo cumples con el !gNIVEL NECESARIO!y para equiparte el hat !g(!y%s!g)", szPrefix, Hats[item][Hat_Name])
return PLUGIN_HANDLED;
}
if(kReset[id] < Hats[item][Hat_Reset])
{
ColorChat(id, print_chat, "%s !yNo cumples con el !gRESET NECESARIO!y para equiparte el hat !g(!y%s!g)", szPrefix, Hats[item][Hat_Name])
return PLUGIN_HANDLED;
}
g_hat[id] = item
ColorChat(id, print_chat, "%s !yHas equipado el !gHAT !y(!g%s!y).", szPrefix, Hats[item][Hat_Name])
//zp_colored_print(id , "^x04[ZP]^x01 Hat: ^x03%s^x01 Equipado!.", Hats[item][Hat_Name])
SetHat(id, 0)
}
MenuHats(id)
return PLUGIN_HANDLED;
}
ATENCIÓN:
Cambien "kReset" y "kNivel" por su variable de niveles y reset, ya puede ser "g_level", "g_reset" y también para que no les salte error el "ColorChat" cambienlo por "client_print" o su variable para agregar un mensaje de color algo asi:
Código PHP:
zp_colored_print(id , "^x04 Verde - ^x03 Team - ^x01 Amarillo") // si no me equivoco es asi los codigos xD
Paso final
Y luego ya se van a dirigir a plugin_init y agregan en conjunto a todos los menus y todo eso esto:
Debería quedar asi:
Código PHP:
register_clcmd("say /hats", "MenuHats")
Código PHP:
// Client commands
register_clcmd("say zpmenu", "clcmd_saymenu")
register_clcmd("say /zpmenu", "clcmd_saymenu")
register_clcmd("say unstuck", "clcmd_sayunstuck")
register_clcmd("say /unstuck", "clcmd_sayunstuck")
register_clcmd("nightvision", "clcmd_nightvision")
register_clcmd("drop", "clcmd_drop")
register_clcmd("buyammo1", "clcmd_buyammo")
register_clcmd("buyammo2", "clcmd_buyammo")
register_clcmd("chooseteam", "clcmd_changeteam")
register_clcmd("jointeam", "clcmd_changeteam")
register_clcmd("say /hats", "MenuHats")
Si quieren que suba todos los hats me avisan, pero el link por mega ya que creo que no puedo subir tanto archivos xD o si no lo subo en .rar, recuerden que si tienen algún error revisen el POST ORIGINAL, esto es igualmente el tutorial desde 0 pero con los niveles y eso, si lo quieren SIN NIVELES/RESET vayan al post original, para quitar niveles o reset es muy fácil, si no saben les digo xD