[ZP](TUT/GUIA) Extra Items Por Nivel (NATIVE)
#1
Hola, bueno como dice el titulo yo vengo a enseñarles o darles una idea/guía/tutorial de como ustedes pueden crear sus propios extra items por niveles en el mismo menú de extra items, bueno, para comenzar, ESTE TUTORIAL/GUÍA ES PARA LA VERSIÓN 4.3/ADVANCE

Para Comenzar, debemos ir a:

Código PHP:
new Array:g_extraitem_name // caption
new Array:g_extraitem_cost // cost
new Array:g_extraitem_team // team
new g_extraitem_i // loaded extra items counter 

y agregaremos una nueva array para los niveles:

Código PHP:
new Array:g_extraitem_name // caption
new Array:g_extraitem_cost // cost
new Array:g_extraitem_team // team
new Array:g_extraitem_lvl // Nivel | Es nuestra array de nivel, IMPORTANTE
new g_extraitem_i // loaded extra items counter 

Ahora, hiriamos a

Código PHP:
public plugin_precache()
{
// debajo de
g_extraitem_cost ArrayCreate(11

y creamos la array:

Código PHP:
/*Importante!!!*/
g_extraitem_lvl ArrayCreate(11//Registramos la Array de nivel que utilizaremos 

Ahora con nuestra Array ya creada, nos dirigimos directamente al menú de extra items:

Código PHP:
show_menu_extras(id)
{
    
// Player dead?
    
if (!g_isalive[id])
        return;
    
    static 
menuidmenu[128], itemteambuffer[32]
    
    
// Title
    
formatex(menucharsmax(menu), "%L [%L]\r"id"MENU_EXTRA_TITLE"idg_zombie[id] ? g_nemesis[id] ? "CLASS_NEMESIS" "CLASS_ZOMBIE" g_survivor[id] ? "CLASS_SURVIVOR" "CLASS_HUMAN")
    
menuid menu_create(menu"menu_extras")
    
    
// Item List
    
for (item 0item g_extraitem_iitem++)
    {
        
// Retrieve item's team
        
team ArrayGetCell(g_extraitem_teamitem)
        
        
// Item not available to player's team/class
        
if ((g_zombie[id] && !g_nemesis[id] && !(team ZP_TEAM_ZOMBIE)) || (!g_zombie[id] && !g_survivor[id] && !(team ZP_TEAM_HUMAN)) || (g_nemesis[id] && !(team ZP_TEAM_NEMESIS)) || (g_survivor[id] && !(team ZP_TEAM_SURVIVOR)))
            continue;
        
        
// Check if it's one of the hardcoded items, check availability, set translated caption
        
switch (item)
        {
            case 
EXTRA_NVISION:
            {
                if (!
get_pcvar_num(cvar_extranvision)) continue;
                
formatex(buffercharsmax(buffer), "%L"id"MENU_EXTRA1")
            }
            case 
EXTRA_ANTIDOTE:
            {
                if (!
get_pcvar_num(cvar_extraantidote) || g_antidotecounter >= get_pcvar_num(cvar_antidotelimit)) continue;
                
formatex(buffercharsmax(buffer), "%L"id"MENU_EXTRA2")
            }
            case 
EXTRA_MADNESS:
            {
                if (!
get_pcvar_num(cvar_extramadness) || g_madnesscounter >= get_pcvar_num(cvar_madnesslimit)) continue;
                
formatex(buffercharsmax(buffer), "%L"id"MENU_EXTRA3")
            }
            case 
EXTRA_INFBOMB:
            {
                if (!
get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit)) continue;
                
formatex(buffercharsmax(buffer), "%L"id"MENU_EXTRA4")
            }
            default:
            {
                if (
item >= EXTRA_WEAPONS_STARTID && item <= EXTRAS_CUSTOM_STARTID-&& !get_pcvar_num(cvar_extraweapons)) continue;
                
ArrayGetString(g_extraitem_nameitembuffercharsmax(buffer))
            }
        }
        
        
// Add Item Name and Cost
        /*Aquí es donde cambiara el MENU, para mostrar de un 
        color distinto y el nivel de item, cuando no cumplimos requisitos*/
        
formatex(menucharsmax(menu), "%s \y%d %L"bufferArrayGetCell(g_extraitem_costitem), id"AMMO_PACKS2")

        
buffer[0] = item
        buffer
[1] = 0
        menu_additem
(menuidmenubuffer)
    }
    
    
// No items to display?
    
if (menu_items(menuid) <= 0)
    {
        
zp_colored_print(id"^x04[ZP]^x01 %L"id ,"CMD_NOT_EXTRAS")
        
menu_destroy(menuid)
        return;
    }
    
    
// Back - Next - Exit
    
formatex(menucharsmax(menu), "%L"id"MENU_BACK")
    
menu_setprop(menuidMPROP_BACKNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_NEXT")
    
menu_setprop(menuidMPROP_NEXTNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_EXIT")
    
menu_setprop(menuidMPROP_EXITNAMEmenu)
        
    
// If remembered page is greater than number of pages, clamp down the value
    
MENU_PAGE_EXTRAS min(MENU_PAGE_EXTRASmenu_pages(menuid)-1)
    
    
// Fix for AMXX custom menus
    
if (pev_valid(id) == PDATA_SAFE)
        
set_pdata_int(idOFFSET_CSMENUCODE0OFFSET_LINUX)
    
    
menu_display(idmenuidMENU_PAGE_EXTRAS)


y cambiamos lo siguiente:

Código PHP:
formatex(menucharsmax(menu), "%s \y%d %L"bufferArrayGetCell(g_extraitem_costitem), id"AMMO_PACKS2"

por
---->

Código PHP:
if (g_level[id] < ArrayGetCell(g_extraitem_lvlitem)) // Aqui es donde chequeamos si el nivel que le dimos al extra item es menor al nivel que tiene el jugador actualmente
    
formatex(menucharsmax(menu), "\d%s [Nivel: \r%d\d]"bufferArrayGetCell(g_extraitem_lvlitem)) // Lo bloqueamos
else // Aqui es donde chequeamos si el nivel que le dimos al extraitem es mayor o igual al nivel que tiene el jugador actualmente
    
formatex(menucharsmax(menu), "%s \y%d %L"bufferArrayGetCell(g_extraitem_costitem), id"AMMO_PACKS2"// Si el Jugador Cumple los requisitos de nivel, se le mostrara la información normal del item (Nombre, AmmoPacks) 

nos quedaría así:

Código PHP:
show_menu_extras(id)
{
    
// Player dead?
    
if (!g_isalive[id])
        return;
    
    static 
menuidmenu[128], itemteambuffer[32]
    
    
// Title
    
formatex(menucharsmax(menu), "%L [%L]\r"id"MENU_EXTRA_TITLE"idg_zombie[id] ? g_nemesis[id] ? "CLASS_NEMESIS" "CLASS_ZOMBIE" g_survivor[id] ? "CLASS_SURVIVOR" "CLASS_HUMAN")
    
menuid menu_create(menu"menu_extras")
    
    
// Item List
    
for (item 0item g_extraitem_iitem++)
    {
        
// Retrieve item's team
        
team ArrayGetCell(g_extraitem_teamitem)
        
        
// Item not available to player's team/class
        
if ((g_zombie[id] && !g_nemesis[id] && !(team ZP_TEAM_ZOMBIE)) || (!g_zombie[id] && !g_survivor[id] && !(team ZP_TEAM_HUMAN)) || (g_nemesis[id] && !(team ZP_TEAM_NEMESIS)) || (g_survivor[id] && !(team ZP_TEAM_SURVIVOR)))
            continue;
        
        
// Check if it's one of the hardcoded items, check availability, set translated caption
        
switch (item)
        {
            case 
EXTRA_NVISION:
            {
                if (!
get_pcvar_num(cvar_extranvision)) continue;
                
formatex(buffercharsmax(buffer), "%L"id"MENU_EXTRA1")
            }
            case 
EXTRA_ANTIDOTE:
            {
                if (!
get_pcvar_num(cvar_extraantidote) || g_antidotecounter >= get_pcvar_num(cvar_antidotelimit)) continue;
                
formatex(buffercharsmax(buffer), "%L"id"MENU_EXTRA2")
            }
            case 
EXTRA_MADNESS:
            {
                if (!
get_pcvar_num(cvar_extramadness) || g_madnesscounter >= get_pcvar_num(cvar_madnesslimit)) continue;
                
formatex(buffercharsmax(buffer), "%L"id"MENU_EXTRA3")
            }
            case 
EXTRA_INFBOMB:
            {
                if (!
get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit)) continue;
                
formatex(buffercharsmax(buffer), "%L"id"MENU_EXTRA4")
            }
            default:
            {
                if (
item >= EXTRA_WEAPONS_STARTID && item <= EXTRAS_CUSTOM_STARTID-&& !get_pcvar_num(cvar_extraweapons)) continue;
                
ArrayGetString(g_extraitem_nameitembuffercharsmax(buffer))
            }
        }
        
        
// Add Item Name and Cost
        
if (g_level[id] < ArrayGetCell(g_extraitem_lvlitem)) // Si el nivel es mejor al nivel que obtenemos de la Array de nivel
            
formatex(menucharsmax(menu), "\d%s [Nivel: \r%d\d]"bufferArrayGetCell(g_extraitem_lvlitem)) // Esta información aparecerá si el usuario no cumple con la condición de nivel.
        
else
            
formatex(menucharsmax(menu), "%s \y%d %L"bufferArrayGetCell(g_extraitem_costitem), id"AMMO_PACKS2"// Si el usuario cumple con la condición de nivel mostraremos normalmente el nombre del item y su precio

        
buffer[0] = item
        buffer
[1] = 0
        menu_additem
(menuidmenubuffer)
    }
    
    
// No items to display?
    
if (menu_items(menuid) <= 0)
    {
        
zp_colored_print(id"^x04[ZP]^x01 %L"id ,"CMD_NOT_EXTRAS")
        
menu_destroy(menuid)
        return;
    }
    
    
// Back - Next - Exit
    
formatex(menucharsmax(menu), "%L"id"MENU_BACK")
    
menu_setprop(menuidMPROP_BACKNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_NEXT")
    
menu_setprop(menuidMPROP_NEXTNAMEmenu)
    
formatex(menucharsmax(menu), "%L"id"MENU_EXIT")
    
menu_setprop(menuidMPROP_EXITNAMEmenu)
        
    
// If remembered page is greater than number of pages, clamp down the value
    
MENU_PAGE_EXTRAS min(MENU_PAGE_EXTRASmenu_pages(menuid)-1)
    
    
// Fix for AMXX custom menus
    
if (pev_valid(id) == PDATA_SAFE)
        
set_pdata_int(idOFFSET_CSMENUCODE0OFFSET_LINUX)
    
    
menu_display(idmenuidMENU_PAGE_EXTRAS)


Luego nos vamos a la siguiente línea para bloquear el item, si NO cumple los requisitos.

Código PHP:
buy_extra_item(iditemidignorecost 0// Este public es cuando seleccionamos el item 

Y reemplazamos:

Código PHP:
    if (!ignorecost)
    {
        
// Check that we have enough ammo packs
        
if (g_ammopacks[id] < ArrayGetCell(g_extraitem_costitemid))
        {
            
zp_colored_print(id"^x04[ZP]^x01 %L"id"NOT_ENOUGH_AMMO")
            return;
        }
        
        
// Deduce item cost
        
g_ammopacks[id] -= ArrayGetCell(g_extraitem_costitemid)
    } 

por
----->

Código PHP:
    if (!ignorecost)
    {
        
// Check that we have level required and enough ammopacks
                /*Si el nivel es mejor al obtenido de la array (<) 
                le damos un print diciéndole que no cumple requisitos*/
        
if (g_level[id] < ArrayGetCell(g_extraitem_lvlitemid) || g_ammopacks[id] < ArrayGetCell(g_extraitem_costitemid)) 
        {
                 
zp_colored_print(id"^x04[ZP]^x01 Comando no disponible.")
                 
show_menu_extras(id// Volvemos a cargar el menú de extra items.
                 
return; // return para que no continúe ninguna otra función
        
}
                
/*En el caso de que el jugador cumpla el nivel, le restamos los ammopacks correspondientes*/
                
g_ammopacks[id] -= ArrayGetCell(g_extraitem_costitemid
     } 

(Aquí es donde bloqueamos si el nivel o ammopacks no cumplen los requisitos del extra item)

Nos quedaría asi:

Código PHP:
buy_extra_item(iditemidignorecost 0)
{
    
// Retrieve item's team
    
static team
    team 
ArrayGetCell(g_extraitem_teamitemid)
    
    
// Check for team/class specific items
    
if ((g_zombie[id] && !g_nemesis[id] && !(team ZP_TEAM_ZOMBIE)) || (!g_zombie[id] && !g_survivor[id] && !(team ZP_TEAM_HUMAN)) || (g_nemesis[id] && !(team ZP_TEAM_NEMESIS)) || (g_survivor[id] && !(team ZP_TEAM_SURVIVOR)))
    {
        
zp_colored_print(id"^x04[ZP]^x01 %L"id"CMD_NOT")
        return;
    }
    
    
// Check for unavailable items
    
if ((itemid == EXTRA_NVISION && !get_pcvar_num(cvar_extranvision))
    || (
itemid == EXTRA_ANTIDOTE && (!get_pcvar_num(cvar_extraantidote) || g_antidotecounter >= get_pcvar_num(cvar_antidotelimit)))
    || (
itemid == EXTRA_MADNESS && (!get_pcvar_num(cvar_extramadness) || g_madnesscounter >= get_pcvar_num(cvar_madnesslimit)))
    || (
itemid == EXTRA_INFBOMB && (!get_pcvar_num(cvar_extrainfbomb) || g_infbombcounter >= get_pcvar_num(cvar_infbomblimit)))
    || (
itemid >= EXTRA_WEAPONS_STARTID && itemid <= EXTRAS_CUSTOM_STARTID-&& !get_pcvar_num(cvar_extraweapons)))
    {
        
zp_colored_print(id"^x04[ZP]^x01 %L"id"CMD_NOT")
        return;
    }
    
    
// Check for hard coded items with special conditions
    
if ((itemid == EXTRA_ANTIDOTE && (g_endround || g_swarmround || g_nemround || g_survround || g_plagueround || fnGetZombies() <= || (get_pcvar_num(cvar_deathmatch) && !get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() == 1)))
    || (
itemid == EXTRA_MADNESS && g_nodamage[id]) || (itemid == EXTRA_INFBOMB && (g_endround || g_swarmround || g_nemround || g_survround || g_plagueround)))
    {
        
zp_colored_print(id"^x04[ZP]^x01 %L"id"CMD_NOT_CANTUSE")
        return;
    }
    
    if (!
ignorecost)
    {
        
// Check that we have level required and enough ammopacks
        /*Detectamos si el usuario no cumple los requisitos y damos un print diciéndole que no tiene acceso aún*/
        
if (g_level[id] < ArrayGetCell(g_extraitem_lvlitemid) || g_ammopacks[id] < ArrayGetCell(g_extraitem_costitemid))
        {
                
zp_colored_print(id"^x04[ZP]^x01 Comando no disponible."// Mensaje
                
show_menu_extras(id// Volvemos a Cargar el menú
                
return; // return para que no se ejecute ninguna otra función
        
}
                
g_ammopacks[id] -= ArrayGetCell(g_extraitem_costitemid)
     }
    
    
// Check which kind of item we're buying
    
switch (itemid)
    {
        case 
EXTRA_NVISION// Night Vision
        
{
            
g_nvision[id] = true
            
            
if (!g_isbot[id])
            {
                
g_nvisionenabled[id] = true
                
                
// Custom nvg?
                
if (get_pcvar_num(cvar_customnvg))
                {
                    
remove_task(id+TASK_NVISION)
                    
set_task(0.1"set_user_nvision"id+TASK_NVISION__"b")
                }
                else
                    
set_user_gnvision(id1)
            }
            else
                
cs_set_user_nvg(id1)
        }
        case 
EXTRA_ANTIDOTE// Antidote
        
{
            
// Increase antidote purchase count for this round
            
g_antidotecounter++
            
            
humanme(id00)
        }
        case 
EXTRA_MADNESS// Zombie Madness
        
{
            
// Increase madness purchase count for this round
            
g_madnesscounter++
            
            
g_nodamage[id] = true
            set_task
(0.1"zombie_aura"id+TASK_AURA__"b")
            
set_task(get_pcvar_float(cvar_madnessduration), "madness_over"id+TASK_BLOOD)
            
            static 
sound[64]
            
ArrayGetString(zombie_madnessrandom_num(0ArraySize(zombie_madness) - 1), soundcharsmax(sound))
            
emit_sound(idCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
        }
        case 
EXTRA_INFBOMB// Infection Bomb
        
{
            
// Increase infection bomb purchase count for this round
            
g_infbombcounter++
            
            
// Already own one
            
if (user_has_weapon(idCSW_HEGRENADE))
            {
                
// Increase BP ammo on it instead
                
cs_set_user_bpammo(idCSW_HEGRENADEcs_get_user_bpammo(idCSW_HEGRENADE) + 1)
                
                
// Flash ammo in hud
                
message_begin(MSG_ONE_UNRELIABLEg_msgAmmoPickup_id)
                
write_byte(AMMOID[CSW_HEGRENADE]) // ammo id
                
write_byte(1// ammo amount
                
message_end()
                
                
// Play clip purchase sound
                
emit_sound(idCHAN_ITEMsound_buyammo1.0ATTN_NORM0PITCH_NORM)
                
                return; 
// stop here
            
}
            
            
// Give weapon to the player
            
fm_give_item(id"weapon_hegrenade")
        }
        default:
        {
            if (
itemid >= EXTRA_WEAPONS_STARTID && itemid <= EXTRAS_CUSTOM_STARTID-1// Weapons
            
{
                
// Get weapon's id and name
                
static weaponidwname[32]
                
ArrayGetString(g_extraweapon_itemsitemid EXTRA_WEAPONS_STARTIDwnamecharsmax(wname))
                
weaponid cs_weapon_name_to_id(wname)
                
                
// If we are giving a primary/secondary weapon
                
if (MAXBPAMMO[weaponid] > 2)
                {
                    
// Make user drop the previous one
                    
if ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)
                        
drop_weapons(id1)
                    else
                        
drop_weapons(id2)
                    
                    
// Give full BP ammo for the new one
                    
ExecuteHamB(Ham_GiveAmmoidMAXBPAMMO[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
                }
                
// If we are giving a grenade which the user already owns
                
else if (user_has_weapon(idweaponid))
                {
                    
// Increase BP ammo on it instead
                    
cs_set_user_bpammo(idweaponidcs_get_user_bpammo(idweaponid) + 1)
                    
                    
// Flash ammo in hud
                    
message_begin(MSG_ONE_UNRELIABLEg_msgAmmoPickup_id)
                    
write_byte(AMMOID[weaponid]) // ammo id
                    
write_byte(1// ammo amount
                    
message_end()
                    
                    
// Play clip purchase sound
                    
emit_sound(idCHAN_ITEMsound_buyammo1.0ATTN_NORM0PITCH_NORM)
                    
                    return; 
// stop here
                
}
                
                
// Give weapon to the player
                
fm_give_item(idwname)
            }
            else 
// Custom additions
            
{
                
// Item selected forward
                
ExecuteForward(g_fwExtraItemSelectedg_fwDummyResultiditemid);
                
                
// Item purchase blocked, restore buyer's ammo packs
                
if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && !ignorecost)
                    
g_ammopacks[id] += ArrayGetCell(g_extraitem_costitemid)
            }
        }
    }


Luego nos dirigimos a la native de extra items
OJO! este paso es muy importante, aquí realizamos la conexión del item con el plugin de ZP, así que si anotan mal algo, no les funcionara y posiblemente un bug gigante.

Código PHP:
public native_register_extra_item(const name[], costteam)
{
    
// ZP disabled
    
if (!g_pluginenabled)
        return -
1;
    
    
// Strings passed byref
    
param_convert(1)
    
    
// Arrays not yet initialized
    
if (!g_arrays_created)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Can't register extra item yet (%s)"name)
        return -
1;
    }
    
    if (
strlen(name) < 1)
    {
        
log_error(AMX_ERR_NATIVE"[ZP] Can't register extra item with an empty name")
        return -
1;
    }
    
    new 
indexextraitem_name[32]
    for (
index 0index g_extraitem_iindex++)
    {
        
ArrayGetString(g_extraitem_nameindexextraitem_namecharsmax(extraitem_name))
        if (
equali(nameextraitem_name))
        {
            
log_error(AMX_ERR_NATIVE"[ZP] Extra item already registered (%s)"name)
            return -
1;
        }
    }
    
    
// For backwards compatibility
    
if (team == ZP_TEAM_ANY)
        
team = (ZP_TEAM_ZOMBIE|ZP_TEAM_HUMAN)
    
    
// Add the item
    
ArrayPushString(g_extraitem_namename)
    
ArrayPushCell(g_extraitem_costcost)
    
ArrayPushCell(g_extraitem_teamteam)
    
    
// Set temporary new item flag
    
ArrayPushCell(g_extraitem_new1)
    
    
// Override extra items data with our customizations
    
new ibuffer[32], size ArraySize(g_extraitem2_realname)
    for (
0sizei++)
    {
        
ArrayGetString(g_extraitem2_realnameibuffercharsmax(buffer))
        
        
// Check if this is the intended item to override
        
if (!equal(namebuffer))
            continue;
        
        
// Remove new item flag
        
ArraySetCell(g_extraitem_newg_extraitem_i0)
        
        
// Replace caption
        
ArrayGetString(g_extraitem2_nameibuffercharsmax(buffer))
        
ArraySetString(g_extraitem_nameg_extraitem_ibuffer)
        
        
// Replace cost
        
buffer[0] = ArrayGetCell(g_extraitem2_costi)
        
ArraySetCell(g_extraitem_costg_extraitem_ibuffer[0])
        
        
// Replace team
        
buffer[0] = ArrayGetCell(g_extraitem2_teami)
        
ArraySetCell(g_extraitem_teamg_extraitem_ibuffer[0])
    }
    
    
// Increase registered items counter
    
g_extraitem_i++
    
    
// Return id under which we registered the item
    
return g_extraitem_i-1;


y cambiamos:

Código PHP:
public native_register_extra_item(const name[], costteam

por
---->

Código PHP:
public native_register_extra_item(const name[], lvlcostteam// Agregamos la constante de nivel para el extra item, muy importante 

agregamos nos niveles.

Ahora reemplazamos esto:

Código PHP:
ArrayPushString(g_extraitem_namename)
ArrayPushCell(g_extraitem_costcost)
ArrayPushCell(g_extraitem_teamteam

por
---->

Código PHP:
ArrayPushString(g_extraitem_namename)
ArrayPushCell(g_extraitem_lvllvl// Obtenemos un valor 'x' de la constante 'lvl' que tendra el item, y ese valor será el que determinará si el nivel que tiene el jugador corresponde al del item para detectar si lo deja disponible o bloqueado en el menú
ArrayPushCell(g_extraitem_costcost)
ArrayPushCell(g_extraitem_teamteam

Ahora nos dirigimos a zombieplague.inc IMPORTANTE
y reemplazamos:

Código PHP:
native zp_register_extra_item(const name[], costteams

por
---->

Código PHP:
/*Agregamos la constante de nivel para poder registrar bien el extra item*/
native zp_register_extra_item(const name[], lvlcostteams// Ahora podremos registrar el item con niveles. 

Ahora para FINALIZAR. Les enseñare como deben registrar el extra item,
que es de la siguiente manera:
--->

Código PHP:
g_item zp_register_extra_item("nombre"nivelcostoequipo

Lo que traducimos a:
--->

Código PHP:
/*Aquí es cuando conectamos el item que queremos con el plugin del ZP definiendo el nombre, nivel, valor, team*/
g_item zp_register_extra_item("Super M4A1"5100ZP_TEAM_HUMAN

No se olviden de nada!, si me falto solo díganme. Cada paso es IMPORTANTE

Así terminaría esta Guía/Tutorial de como crear Extra Items por nivel utilizando (NATIVES) Excitedeyes
Party Time! Lengua Dancing, Saludos. Gran sonrisa
(ZP Assassin) 100% | 72% (Optimizando)
Responder
#2
aclara que es para 4.3, me parece bien que vuelvas con el pawn e.e
Ingeniero agrónomo y desarrollador de Software.

tutoriales-allied
buscas un zp?

"La imitación es la forma más sincera de admiración con la que puede pagar la mediocridad a la grandeza"

Merci Alliedmodders pour m'introduire dans la programmation.
Responder
#3
(04/09/2014, 11:39 PM)roccoxx escribió: aclara que es para 4.3, me parece bien que vuelvas con el pawn e.e

Gracias amigazooo me falto ese detalle, bueno si en mi tiempo libre me dedicare al pawn jajaja este año lo tengo muy apretado con el colegio y otras cosas jajaja
Party Time! Lengua Dancing, Saludos. Gran sonrisa
(ZP Assassin) 100% | 72% (Optimizando)
Responder
#4
Me gustó , podrias explicarlo , ya que van a hacer C&P sin saber que estan haciendo...

Saludos.
NUEVO ZOMBIE PLAGUE + LVLS!! UNETE A LA COMUNIDAD
[Imagen: b_350_20_ffad41_e98100_000000_591f11.png]


Responder
#5
(05/09/2014, 08:18 AM)Evil Spiret escribió: Me gustó , podrias explicarlo , ya que van a hacer C&P sin saber que estan haciendo...

Saludos.

Gracias, bueno si lo explicare un poco mejor para que puedan entenderlo
Party Time! Lengua Dancing, Saludos. Gran sonrisa
(ZP Assassin) 100% | 72% (Optimizando)
Responder
#6
[Imagen: 141205084110290319.jpg]

Lo extraño es que si le puse
Código PHP:
native zp_register_extra_item(const name[], lvlcostteam
en el zombieplague.inc Whatever
Cereal "What's your favorite Pink Floyd song?"
Better "Oh I really like dark side of the moon"
Poker face "yea.. kill yourself"
Responder
#7
Hola todo bien hasta que llegas al final esta alpedo esa parte te explico porque

Parque que esta Mal:
Cita:Ahora nos dirigimos a zombieplague.inc IMPORTANTE
y reemplazamos:

Código PHP:
native zp_register_extra_item(const name[], cost, teams)

por
---->

Código PHP:
/*Agregamos la constante de nivel para poder registrar bien el extra item*/
native zp_register_extra_item(const name[], lvl, cost, teams) // Ahora podremos registrar el item con niveles.

Ahora para FINALIZAR. Les enseñare como deben registrar el extra item,
que es de la siguiente manera:
--->

Código PHP:
g_item = zp_register_extra_item("nombre", nivel, costo, equipo)

Lo que traducimos a:
--->

Código PHP:
/*Aquí es cuando conectamos el item que queremos con el plugin del ZP definiendo el nombre, nivel, valor, team*/
g_item = zp_register_extra_item("Super M4A1", 5, 100, ZP_TEAM_HUMAN)

Bueno ami parecer si estas creando una native para llamar a la funcion de restrinccion por lvl :S supongo que debes crear la constante para dar dicho level

Ejemplo que deben de cumplir en todos los extra items:
creas una constante o const
Código PHP:
new const item_lvl Nivel que le pondras 

Segundo Registramos los lvls en el zp_register_extra_item

ejemplo:
Código PHP:
g_item zp_register_extra_item("Super M4A1"lvl100ZP_TEAM_HUMAN

Eso seria todo la forma en que tu la hiciste no llamara la restrinccion solo pones un valor Flotante y solo causaras error Gran sonrisa pero por lo demas todo bien Gran sonrisa
Responder
#8
Me podrian ayudar me compilo bien solo que al querer abrir el menu de extra items no me habre Whatdone aqui los LOGS:

LOGS:
L 07/27/2015 - 18:51:32: Start of error session.
L 07/27/2015 - 18:51:32: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20150727.log")
L 07/27/2015 - 18:51:32: Invalid cellvector handle provided (71:4:1)
L 07/27/2015 - 18:51:32: [AMXX] Displaying debug trace (plugin "zombie_plague40_new_modes_1-5.amxx")
L 07/27/2015 - 18:51:32: [AMXX] Run time error 10: native error (native "ArrayGetCell")
L 07/27/2015 - 18:51:32: [AMXX] [0] zombie_plague40_new_modes_1-5.sma:Confundidohow_menu_extras (line 3757)
L 07/27/2015 - 18:51:32: [AMXX] [1] zombie_plague40_new_modes_1-5.sma::buy_extra_item (line 4638)
L 07/27/2015 - 18:51:32: [AMXX] [2] zombie_plague40_new_modes_1-5.sma::bot_buy_extras (line 8767)

CODIGO DONDE SALE:
Código PHP:
if (g_level[id] < ArrayGetCell(g_extraitem_lvlitem)) // Aqui es donde chequeamos si el nivel que le dimos al extra item es menor al nivel que tiene el jugador actualmente
            
formatex(menucharsmax(menu), "\d%s [Nivel: \r%d\d]"bufferArrayGetCell(g_extraitem_lvlitem)) // Lo bloqueamos
        
else // Aqui es donde chequeamos si el nivel que le dimos al extraitem es mayor o igual al nivel que tiene el jugador actualmente
            
formatex(menucharsmax(menu), "%s \y%d %L"bufferArrayGetCell(g_extraitem_costitem), id"AMMO_PACKS2"// Si el Jugador Cumple los requisitos de nivel, se le mostrara la información normal del item (Nombre, AmmoPacks) 
        
buffer[0] = item
        buffer
[1] = 0
        menu_additem
(menuidmenubuffer)
    }
------------------------------
    if (!
ignorecost)
    {
        if (
g_level[id] < ArrayGetCell(g_extraitem_lvlitemid) || g_ammopacks[id] < ArrayGetCell(g_extraitem_costitemid)) 
        {
            
zp_colored_print(id"^x04[ZP6]^x01 Comando no disponible.")
            
show_menu_extras(id
            return; 
        }
        
g_ammopacks[id] -= ArrayGetCell(g_extraitem_costitemid
    } 

COMO LO PUSE EN EL EXTRA ITEM:
Código PHP:
public plugin_init()
{
    
register_plugin("[ZP] Extra: Unlimited Clip""1.0""MeRcyLeZZ")
    
    
g_item zp_register_extra_item("Balas infinitas"5100ZP_TEAM_HUMAN)
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")

Responder
#9
supongo que es esto no?
Cita:native_register_extra_item2(const name[], cost, lvl, team)
{
// Add the item
ArrayPushString(g_extraitem_name, name)
ArrayPushCell(g_extraitem_cost, cost)
ArrayPushCell(g_extraitem_lvl, lvl)
ArrayPushCell(g_extraitem_team, team)

// Set temporary new item flag
ArrayPushCell(g_extraitem_new, 1)

// Increase registered items counter
g_extraitem_i++
}
[Imagen: zcsztw-4.png] [Imagen: 6u5fj2-4.png]
[Imagen: linkedin_thumb_image.png][Imagen: 76561198283253977.png][Imagen: linkedin_thumb_image.png]
Responder
#10
como iria eso a si o como?
Código PHP:
ArrayPushString(g_extraitem_namename)
ArrayPushCell(g_extraitem_lvllvl)
ArrayPushCell(g_extraitem_costcost)
ArrayPushCell(g_extraitem_teamteam

asi estaria bien? Gran sonrisa o cual es el error :/
Responder
#11
si no te abre el menu de extras es por que te falta la native interna de extra items ...
que es esa que pase buscala y reemplazala , luego agregas nivel a los extra de plugin_precache,


es una forma no tan linda pero sirve

Whatever
[Imagen: zcsztw-4.png] [Imagen: 6u5fj2-4.png]
[Imagen: linkedin_thumb_image.png][Imagen: 76561198283253977.png][Imagen: linkedin_thumb_image.png]
Responder
#12
y eso donde va? la native esa?
Responder
#13
buscala y reemplazala control + f y agregas el nivel en los extra items de plugin_precache
[Imagen: zcsztw-4.png] [Imagen: 6u5fj2-4.png]
[Imagen: linkedin_thumb_image.png][Imagen: 76561198283253977.png][Imagen: linkedin_thumb_image.png]
Responder
#14
Gracias parese que yaCutecry
Responder
#15
I have some problems and I can not fix them

(23/04/2018, 10:15 PM)LuXo KING Gaming escribió: I have some problems and I can not fix them


Archivos adjuntos
.sma   Descargar AMXX / ZC95.sma (Tamaño: 324.89 KB / Descargas: 14)
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)