Allied Modders en español
[ZP][TUT] Crear Happy Hour para ZP 4.2 - Versión para impresión

+- Allied Modders en español (https://amxmodx-es.com)
+-- Foro: AMX Mod X - Scripting (https://amxmodx-es.com/Forum-AMX-Mod-X-Scripting)
+--- Foro: Tutoriales / Guias (https://amxmodx-es.com/Forum-Tutoriales-Guias)
+--- Tema: [ZP][TUT] Crear Happy Hour para ZP 4.2 (/Thread-ZP-TUT-Crear-Happy-Hour-para-ZP-4-2)



[ZP][TUT] Crear Happy Hour para ZP 4.2 - ShaDow^ - 10/12/2013

Nota antes de empezar: Este tutorial esta hecho para ZP 4.2 y 4.3

Empezemos.

Abajo de los Includes y arriba de Plugin Customization agregamos las siguientes variables:

Código PHP:
new const horas[] = { 0001020304050607, 08 ,09, 10 // Aca estamos diciendo que el Happy Hour empezara a las 12 AM y terminara a las 10 AM. Modifiquenlo a su gusto.
new boolg_happytime // Este bool sirve para dar la ganancia x2 en el Happy Hour 

Vamos al public event_round_start y abajo del { agregamos:

Código PHP:
// [HV] Hora Vico
set_task(0.1,"happyhour"// Aca definimos que cada 1 segundo se llame al bool happy hour para checkear si estamos en happy hour. 

Ahora vamos al public fw_TakeDamage y buscamos:

Código PHP:
// Reward ammo packs for every [ammo damage] dealt 

Y modifican esto:

Código PHP:
while (g_damagedealt[attacker] >= ammodamage

Por Esto:

Código PHP:
while (g_damagedealt[attacker] >= (ammodamage / (g_happytime 3)) ) 

Ahora vamos al final del plugin y agregamos

Código PHP:
public happyhour(id)
{
    new 
data[12]
    
get_time("%H"data12)
    new 
Tiempo str_to_num(data)
 
    for(new 
i=0;<= sizeof horas 1;i++)
    {
        if(
Tiempo != horas[i]) continue
        
g_happytime true
        
break;
    }
    if(
g_happytime)
    {
        
zp_colored_print(0"^x04[ZP]^x01 Estas en^x04 Happy Hour^x01 disfruta mientas ganas el^x04 Doble^x01 de AmmoPacks")
    }


Y eso fue todo para crear Happy Hour.

Saludos, Atte. ShaDow^


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - cLAANS - 11/12/2013

Código:
public event_round_start
{
static data[ 9 ];
    get_time( "%H", data, 8 );
    
    new Hora = str_to_num( data );
    
    if( Hora >= 00 && Hora < 10 )
    {
        g_happytime = true;
         zp_colored_print(0, "^x04[ZP]^x01 Estas en^x04 Happy Hour^x01 disfruta mientas ganas el^x04 Doble^x01 de AmmoPacks")
    }
}

No seria mejor ?

Saludos,
cLAANS.-


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - RauliTop - 11/12/2013

para empezar que este tutorial no lo hiciste tú y ni siquiera dejas los créditos.

http://forums.alliedmods.net/showthread.php?t=113547

hay varias cosas mal, viendo esto
Código PHP:
public happyhour(id

me quedé Yao ming


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - ShaDow^ - 11/12/2013

(11/12/2013, 10:59 AM)RauliTop escribió: para empezar que este tutorial no lo hiciste tú y ni siquiera dejas los créditos.

http://forums.alliedmods.net/showthread.php?t=113547

hay varias cosas mal, viendo esto
Código PHP:
public happyhour(id

me quedé Yao ming

Para empezar nunca dije que este tutorial era mio. Ni que lo hice yo, tengo esto en mi zp hace mucho tiempo. Y como hay gente que no puede entrar a la web de alliedmods. Decidi postearlo aca.


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - alan_el_more - 11/12/2013

(11/12/2013, 01:00 AM)cLAANS escribió:
Código:
public event_round_start
{
static data[ 9 ];
    get_time( "%H", data, 8 );
    
    new Hora = str_to_num( data );
    
    if( Hora >= 00 && Hora < 10 )
    {
        g_happytime = true;
         zp_colored_print(0, "^x04[ZP]^x01 Estas en^x04 Happy Hour^x01 disfruta mientas ganas el^x04 Doble^x01 de AmmoPacks")
    }
}

No seria mejor ?

Saludos,
cLAANS.-

Si pero hay gente que puede querer dejar intervalos de tiempo


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - [R]ak - 11/12/2013

pls..

Código PHP:
public event_round_start() {
    
    static 
Date[3], Time
    
    get_time
("%H"Datecharsmax(Date))
    
    
Time str_to_num(Date)
    
    static const 
TIME_HAPPY 12 13 14
    
    
if(TIME_HAPPY Time) {
        
        
g_happytime true
        
        zp_colored_print
(0"^x04[ZP]^x01 Estas en^x04 Happy Hour^x01 disfruta mientas ganas el^x04 Doble^x01 de AmmoPacks")
        
    }
    else
        
g_happytime false
        




RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - RauliTop - 11/12/2013

(11/12/2013, 12:50 PM)[R]ak escribió: pls..

Código PHP:
public event_round_start() {
    
    static 
Date[3], Time
    
    get_time
("%H"Datecharsmax(Date))
    
    
Time str_to_num(Date)
    
    static const 
TIME_HAPPY 12 13 14
    
    
if(TIME_HAPPY Time) {
        
        
g_happytime true
        
        zp_colored_print
(0"^x04[ZP]^x01 Estas en^x04 Happy Hour^x01 disfruta mientas ganas el^x04 Doble^x01 de AmmoPacks")
        
    }
    else
        
g_happytime true
        


siempre true Crab


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - roccoxx - 11/12/2013

esta mal medicado rak.


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - [R]ak - 11/12/2013

sabes lo difícil que es armar un code prolijo desde un celular? ¬¬ copie y pegue esa parte

Whatever

pd: happy para todos! (?


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - RauliTop - 12/12/2013

(11/12/2013, 11:57 AM)ShaDow^ escribió:
(11/12/2013, 10:59 AM)RauliTop escribió: para empezar que este tutorial no lo hiciste tú y ni siquiera dejas los créditos.

http://forums.alliedmods.net/showthread.php?t=113547

hay varias cosas mal, viendo esto
Código PHP:
public happyhour(id

me quedé Yao ming

Para empezar nunca dije que este tutorial era mio. Ni que lo hice yo, tengo esto en mi zp hace mucho tiempo. Y como hay gente que no puede entrar a la web de alliedmods. Decidi postearlo aca.
pues deberías a ver puesto los créditos de donde lo sacaste.

no es exclusivo para zp 4.2


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - xPecie - 13/12/2013

Una cosa, hay un lugar que dice modificar esto:

Código PHP:
while (g_damagedealt[attacker] >= ammodamage

Por Esto:

Código PHP:
while (g_damagedealt[attacker] >= (ammodamage / (g_happytime 3))) 

Y yo en ese lugar tengo:

Código PHP:
while (g_damagedealt_human[attacker] > get_pcvar_num(cvar_ammodamage_human)) 



RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - ShaDow^ - 13/12/2013

(13/12/2013, 03:15 PM)xPecie escribió: Una cosa, hay un lugar que dice modificar esto:

Código PHP:
while (g_damagedealt[attacker] >= ammodamage

Por Esto:

Código PHP:
while (g_damagedealt[attacker] >= (ammodamage / (g_happytime 3))) 

Y yo en ese lugar tengo:

Código PHP:
while (g_damagedealt_human[attacker] > get_pcvar_num(cvar_ammodamage_human)) 

Mira tienes que crear arriba de

Código PHP:
// Reward ammo packs for every [ammo damage] dealt 

Esto:

Código PHP:
static damagehuman
damagehuman 
get_pcvar_num(cvar_ammodamage_human

Y luego cambias esto:

Código PHP:
while (g_damagedealt_human[attacker] > get_pcvar_num(cvar_ammodamage_human)) 
[/quote]

Por esto:

Código PHP:
while (g_damagedealt_human[attacker] >= (damagehuman / (g_happytime 3))) 

Espero averte ayudado. ShaDow^


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - xPecie - 14/12/2013

Gracias por contestar tan rápido, ehm...hice lo que me dijiste y me sale lo siguiente que no consigo arreglar:

Warning: Tag mismatch on line 2123

Código PHP:
while (g_damagedealt_human[attacker] >= (damagehuman / (g_happytime 3)) ) 

Lo tengo así:

Código PHP:
// Ham Take Damage Forward
public fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_valid_connected(attacker))
        return 
HAM_IGNORED;
    
    
// New round starting or round ended
    
if (g_newround || g_endround)
        return 
HAM_SUPERCEDE;
    
    
// Victim shouldn't take damage or victim is frozen
    
if (g_nodamage[victim] || g_frozen[victim])
        return 
HAM_SUPERCEDE;
    
    
// Prevent friendly fire
    
if (g_zombie[attacker] == g_zombie[victim])
        return 
HAM_SUPERCEDE;
    
    
// Attacker is human...
    
if (!g_zombie[attacker])
    {
        
// Armor multiplier for the final damage on normal zombies
        
if (!g_nemesis[victim])
        {
            
damage *= get_pcvar_float(cvar_zombiearmor)
            
SetHamParamFloat(4damage)
        }
        
        
// Reward ammo packs to humans for damaging zombies?
        
if ((get_pcvar_num(cvar_ammodamage_human) > 0) && (!g_survivor[attacker] || !get_pcvar_num(cvar_survignoreammo)))
        {
            
// Store damage dealt
            
g_damagedealt_human[attacker] += floatround(damage)
            
            
// happy hour
            
static damagehuman
            damagehuman 
get_pcvar_num(cvar_ammodamage_human)
            
            
// Reward ammo packs for every [ammo damage] dealt
            // happy hour
            
while (g_damagedealt_human[attacker] >= (damagehuman / (g_happytime 3)))
            {
                
g_ammopacks[attacker]++
                
g_damagedealt_human[attacker] -= get_pcvar_num(cvar_ammodamage_human)
            }
        }
        
        return 
HAM_IGNORED;
    }
    
    
// Attacker is zombie...
    
    // Prevent infection/damage by HE grenade (bugfix)
    
if (damage_type DMG_HEGRENADE)
        return 
HAM_SUPERCEDE;
    
    
// Nemesis?
    
if (g_nemesis[attacker])
    {
        
// Ignore nemesis damage override if damage comes from a 3rd party entity
        // (to prevent this from affecting a sub-plugin's rockets e.g.)
        
if (inflictor == attacker)
        {
            
// Set nemesis damage
            
SetHamParamFloat(4get_pcvar_float(cvar_nemdamage))
        }
        
        return 
HAM_IGNORED;
    }
    
    
// Reward ammo packs to zombies for damaging humans?
    
if (get_pcvar_num(cvar_ammodamage_zombie) > 0)
    {
        
// Store damage dealt
        
g_damagedealt_zombie[attacker] += floatround(damage)
        
        
// Reward ammo packs for every [ammo damage] dealt
        
while (g_damagedealt_zombie[attacker] > get_pcvar_num(cvar_ammodamage_zombie))
        {
            
g_ammopacks[attacker]++
            
g_damagedealt_zombie[attacker] -= get_pcvar_num(cvar_ammodamage_zombie)
        }
    }
    
    
// Last human or not an infection round
    
if (g_survround || g_nemround || g_swarmround || g_plagueround || fnGetHumans() == 1)
        return 
HAM_IGNORED// human is killed
    
    // Does human armor need to be reduced before infecting?
    
if (get_pcvar_num(cvar_humanarmor))
    {
        
// Get victim armor
        
static Float:armor
        pev
(victimpev_armorvaluearmor)
        
        
// If he has some, block the infection and reduce armor instead
        
if (armor 0.0)
        {
            
emit_sound(victimCHAN_BODYsound_armorhit1.0ATTN_NORM0PITCH_NORM)
            if (
armor damage 0.0)
                
set_pev(victimpev_armorvaluearmor damage)
            else
                
cs_set_user_armor(victim0CS_ARMOR_NONE)
            return 
HAM_SUPERCEDE;
        }
    }
    
    
// Infection allowed
    
zombieme(victimattacker001// turn into zombie
    
return HAM_SUPERCEDE;


Si yo tengo esto así:
n
Código PHP:
ew const horas[] = { 0001020304050607, 08 ,09, 10111213 
Entiendo que es de 12 de la NOCHE a 1 del MEDIODIA (hora de comer + o menos) cierto?

P.D.: Se me olvidaba, como puedo ponerle una cvar para activarlo y desactivarlo cuando quiera? por ejemplo: amx_horafeliz "1" activado "0" desactivado, sin tener que cambiar el .amxx cada vez.

Saludos!


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - RauliTop - 14/12/2013

(14/12/2013, 06:12 AM)xPecie escribió: Gracias por contestar tan rápido, ehm...hice lo que me dijiste y me sale lo siguiente que no consigo arreglar:

Warning: Tag mismatch on line 2123

Código PHP:
while (g_damagedealt_human[attacker] >= (damagehuman / (g_happytime 3)) ) 

prueba
Código PHP:
while (g_damagedealt_human[attacker] >= floatround(damagehuman / (g_happytime 3)) ) 



RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - xPecie - 14/12/2013

No, ahora me dice:

Warning: Tag mismatch on line 2123
Warning: Tag mismatch on line 2123

2 veces...en esa misma linea


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - RauliTop - 14/12/2013

prueba de nuevo:
Código PHP:
while (g_damagedealt_human[attacker] >= floatround(float(damagehuman) / float(g_happytime 3)) ) 



RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - xPecie - 14/12/2013

Diós, tampoco se arregla, probe lo que me dijiste también de:

Código PHP:
while (g_damagedealt_human[attacker] >= floatround(float(damagehuman) / float(g_happytime 3)) ) 


Y no hay manera...


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - UnrealT - 14/12/2013

(14/12/2013, 09:40 AM)xPecie escribió: Diós, tampoco se arregla, probe lo que me dijiste también de:

Código PHP:
while (g_damagedealt_human[attacker] >= floatround(float(damagehuman) / float(g_happytime 3)) ) 


Y no hay manera...

No seria mejor hacer asi?

Código PHP:
while (g_damagedealt[attacker] >= ammodamage)
{
                
g_ammopacks[attacker]+= g_happytime 1
                g_damagedealt
[attacker] -= ammodamage




RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - ShaDow^ - 14/12/2013

(14/12/2013, 11:21 AM)UnrealT escribió:
(14/12/2013, 09:40 AM)xPecie escribió: Diós, tampoco se arregla, probe lo que me dijiste también de:

Código PHP:
while (g_damagedealt_human[attacker] >= floatround(float(damagehuman) / float(g_happytime 3)) ) 


Y no hay manera...

No seria mejor hacer asi?

Código PHP:
while (g_damagedealt[attacker] >= ammodamage)
{
                
g_ammopacks[attacker]+= g_happytime 1
                g_damagedealt
[attacker] -= ammodamage


Y esta seria una buena manera. No la habia pensado nunca. Gracias unreal Sonrisa

Saludos, ShaDow^


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - [R]ak - 14/12/2013

no.. es mala esa manera.. lo mejor seria usar una variable global llamada.. q se yo...

g_happybonus

y si es happy le asignas el valor q quieras.. 1, 2, 3.. etc.. y solo le pones donde recibe AP; + g_happybonus


RE: [ZP][TUT] Crear Happy Hour para ZP 4.2 - ShiobanX - 04/01/2015

Y si quiero que sea de exp?