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

[ZP] Crear niveles por Experiencia [SIN BUGS]


  
 
 
Thread Tools Display Modes
Author Message
AdNPrO
Senior Member
Join Date: Feb 2012
Location: Santiago, Chile
Old 04-11-2012 , 16:57   [ZP] Crear niveles por Experiencia [SIN BUGS]
#1

PHP Code:
// Nos Vamos a [[Global Variables]] y agregamos 2 variables 

new g_level[33]
new 
g_exp[33]

// Abajo de las variables que creamos agregaremos un const: 

new const LEVELS[] = {010203549

// Nos vamos al siguiente Forward: 

public fw_PlayerKilled(victimattackershouldgib

// Agregaremos lo siguiente: 

if(!g_zombie[attacker] && g_zombie[victim]) // Si el humano es el atacante ganara 10 frags 

g_exp[attacker] += 10 
zp_colored_print
(attacker"^x04[ZP]^x01 Ganaste^x04 10^x01 de^x04 Exp^x01 por:^x04 Matar Zombie^x01." )
check_level(attacker


// Debajo de este agregaremos otro: 

if(g_zombie[attacker] && !g_zombie[victim]) // Si el zombie es el atacante ganara 8 frags 

g_exp[attacker] += 
zp_colored_print
(attacker"^x04[ZP]^x01 Ganaste^x04 8^x01 de^x04 Exp^x01 por:^x04 Matar Humano^x01." )
check_level(attacker


// Nos vamos a esta línea: 

if (resetall

// Agregaremos: 
g_exp[id] = 
g_level
[id] = 

// Esto Significa que cuando un jugador nuevo entre al servidor sus frags comenzarán en 0 y su nivel sera 1 

// Nos vamos al final del scripting y agregamos el siguiente public: 

public check_level(id

    if (
g_exp[id] > LEVELS[sizeof LEVELS 1] - 1
        return 
PLUGIN_HANDLED
     
    if (
g_exp[id] >= LEVELS[g_level[id]]) 
           { 
                 
g_level[id]++ // Esto es para chequee cuando subes de nivel 
         
                
zp_colored_print(id"^x04[ZP]^x01 Felicitaciones Has Subido de Nivel Ahora eres Nivel:^x04 %d^x01."g_level[id]) // Cuando subas de nivel te enviara este mensaje diciendote a que nivel subiste 
           


    return 
PLUGIN_HANDLED


// Si quieren que en el hud salgan los niveles nos vamos a:  

public ShowHUD(taskid

// Buscamos lo siguiente 

set_hudmessage(redgreenblueHUD_STATS_XHUD_STATS_Y06.01.10.00.0, -1
ShowSyncHudMsg(ID_SHOWHUDg_MsgSync2"%L: %d - %L %s - %L %d"id"ZOMBIE_ATTRIB1"pev(ID_SHOWHUDpev_health), ID_SHOWHUD"CLASS_CLASS", class, ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[ID_SHOWHUD]) 

// Lo reemplazamos por esto: 

set_hudmessage(redgreenblueHUD_STATS_XHUD_STATS_Y06.01.10.00.0, -1
ShowSyncHudMsg(ID_SHOWHUDg_MsgSync2"%L: %d - %L %s - %L %d ^n Nivel: %d - Frags: %d / %d"id"ZOMBIE_ATTRIB1"pev(ID_SHOWHUDpev_health), ID_SHOWHUD"CLASS_CLASS", class, ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[ID_SHOWHUD], g_level[ID_SHOWHUD], g_exp[ID_SHOWHUD], LEVELS[g_level[ID_SHOWHUD]]) 
Lo hice en version ZP Advanced, 4.3, 4.2

Last edited by AdNPrO; 04-21-2012 at 14:55.
AdNPrO is offline
Send a message via MSN to AdNPrO
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 04-11-2012 , 18:29   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#2

PHP Code:
while (g_exp[id] >= LEVELS[g_level[id]]) 
==>

PHP Code:
if (g_exp[id] >= LEVELS[g_level[id]]) 

Last edited by XINLEI; 04-11-2012 at 18:29.
XINLEI is offline
xLeoNNN
Veteran Member
Join Date: Sep 2010
Location: de_dust2
Old 04-11-2012 , 18:46   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#3

mejora la tabulación.
según mi opinion es mejor hacer macros si es que tienes muchos niveles, si tienes 30 o menos estaría bien con const =)
__________________
xLeoNNN is offline
Send a message via MSN to xLeoNNN
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 04-11-2012 , 21:00   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#4

Quote:
Originally Posted by xLeoNNN View Post
mejora la tabulación.
según mi opinion es mejor hacer macros si es que tienes muchos niveles, si tienes 30 o menos estaría bien con const =)
depende de cuanto variae la experiencia de 1 level del siguiente..
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
xLeoNNN
Veteran Member
Join Date: Sep 2010
Location: de_dust2
Old 04-11-2012 , 21:33   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#5

también
__________________
xLeoNNN is offline
Send a message via MSN to xLeoNNN
Sidix
Senior Member
Join Date: Feb 2011
Location: Limbo City
Old 04-11-2012 , 22:37   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#6

PHP Code:
new const LEVELS[] = {010203549


PHP Code:
#define LEVELS 100 // cantidad de niveles... 

es mejor así en mi opinión... ! con un macro...
__________________
[IMG]http://img839.**************/img839/1879/dmcdanteprofile.png[/IMG]
Sidix is offline
fearAR
Veteran Member
Join Date: Oct 2010
Old 04-11-2012 , 23:48   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#7

Sidix me parece que no entendistes la función del Array "LEVELS", por sí el nombre de este en cuanto a su relación con su contenido no esta bien orientado, pero si uno lee su contenido se da cuenta que esos valores se refieren a los punto de "EXPERIENCIA", requeridos.

Saludos.
__________________
~~~~ NPC AI ~~~~

[ Pathfinding - OK ]
[ Citizen AI - OK ]
[ Handle Weapons - --- ]
fearAR is offline
Send a message via MSN to fearAR
xLeoNNN
Veteran Member
Join Date: Sep 2010
Location: de_dust2
Old 04-12-2012 , 12:41   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#8

el macro vendría siendo una formula para conseguir la exp necesaria para el proximo nivel, ejemplo:

#define next_level(%1) (%1 * 30)

lo que haria seria multiplicar el level por 30, si tiene level 1 seria 30 obvio, si es level 2 seria 2 * 30 = 60, si es level 30 seria 90 y así.

se usaria next_level(PlayerLevel[id])
__________________
xLeoNNN is offline
Send a message via MSN to xLeoNNN
Sidix
Senior Member
Join Date: Feb 2011
Location: Limbo City
Old 04-12-2012 , 16:42   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#9

PHP Code:
if(!g_zombie[attacker] && g_zombie[victim]) // Si el humano es el atacante ganara 10 frags  

    
zp_colored_print(attacker"^x04[ZP]^x01 Ganaste^x04 10^x01 de^x04 Exp^x01 por:^x04 Matar Zombie^x01.")
    
// Si todo se cumple, le aumento 10 puntos de experiencia al atacante
    
check_level(attacker10)
}
    
if(
g_zombie[attacker] && !g_zombie[victim]) // Si el zombie es el atacante ganara 8 frags
{
    
zp_colored_print(attacker"^x04[ZP]^x01 Ganaste^x04 8^x01 de^x04 Exp^x01 por:^x04 Matar Humano^x01.")
    
// Si todo se cumple, le aumento 8 puntos de experiencia al atacante
    
check_level(attacker8)

__________________
[IMG]http://img839.**************/img839/1879/dmcdanteprofile.png[/IMG]

Last edited by Sidix; 04-12-2012 at 16:44.
Sidix is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 04-13-2012 , 17:21   Re: [ZP] Crear niveles por Experiencia [SIN BUGS]
#10

Quote:
Originally Posted by XINLEI View Post
PHP Code:
while (g_exp[id] >= LEVELS[g_level[id]]) 
==>

PHP Code:
if (g_exp[id] >= LEVELS[g_level[id]]) 
Si usas "if" y ganas una cantidad que cubra lo necesario para dos o más niveles solo te subiría un nivel, en cambio con el while aumentaría como debe ser.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
 


Thread Tools
Display Modes

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 10:02.


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