AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Spanish (https://forums.alliedmods.net/forumdisplay.php?f=135)
-   -   [ES][TUT] Crear un XP Mod (https://forums.alliedmods.net/showthread.php?t=113875)

Zapdos1 12-30-2009 22:38

[ES][TUT] Crear un XP Mod
 
Bueno, ese tutorial lo encontré recién (a las 12:10 de la noche horario chileno xD). Está en inglés y lo traduciré, ya que compila perfecto y pensé que tal vez les sirva a muchas personas :)

Post original: http://forums.alliedmods.net/showpos...57&postcount=6

Para empezar:

Debemos agregar estos includes al plugin, ya que estos includes son parte fundamental, sin estos, el plugin no puede funcionar.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun> 

Para hacer este plugin algo así como, "divertido", le pondremos clases de animales.

PHP Code:

enum pclass
{
    
CLASS_NOTHING=0,
    
CLASS_DOG,
    
CLASS_CAT,
    
CLASS_HORSE,
    
CLASS_COW,

    
NUM_OF_CLASSES


Despues hacemos 3 variables, que indicarán las clases, xp y level.
PHP Code:

new pclass:g_PlayerClass[33];
new 
g_PlayerXP[33];
new 
g_PlayerLevel[33]; 

Ahora una constante con la cantidad máxima de clases, y con los nombre que tendrán en el juego.

PHP Code:

new const CLASS_NAMES[NUM_OF_CLASSES][] = {
    
"None",
    
"Dog",
    
"Cat",
    
"Horse",
    
"Cow"


Aquí hablaremos parte de los levels.
PHP Code:

#define NUM_OF_LEVELS 6 //Esta es la cantidad de levels que tendrémos en nuestro mod 

PHP Code:

new const LEVELS[NUM_OF_LEVELS] = {
    
100//100 XP necesarios para el Level 1
    
200//200 XP necesarios para el Level 2
    
400//Etc..
    
800,
    
1600,
    
3200


Esto es un mensaje que se mostrará:

PHP Code:

new gmsgStatusText

Ahora vamos a plugin_init:

PHP Code:

public plugin_init()
{
    
register_plugin("Animal Mod""1.0""XunTric")
    
    
register_cvar("sv_animalmod""1"//El XP Mod estará activado
    
    
register_event("DeathMsg""DeathMsg""a")
    
    
register_cvar("XP_per_kill""20"//La cantidad de XP que uno recibira al matar gente

    
register_menucmd(register_menuid("menu_ChooseAnimal"),1023,"MenuAction_ChooseAnimal");
    
    
register_event("ResetHUD""ResetHud""b")
    
    
gmsgStatusText get_user_msgid("StatusText")


PHP Code:

ChooseAnimal(id//Aquí el jugador escojera su clase
{
    new 
menu[] = "Animal Mod: Choose Animal^n^n1. Dog^n2. Cat^n3. Horse^n4. Cow^n^n0. Exit" // I think this should be better than doing format, in case it works Wink
    
new keys MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
    
    show_menu
(idkeysmenu, -1"menu_ChooseAnimal")    


Aquí le mandará mensajes al jugador según la clase de animal que escoja.

PHP Code:

public MenuAction_ChooseAnimal(idpclass:key)
{
    if (
key == g_PlayerClass[id])
    {
        
client_print(idprint_chat"[Animal Mod] You are already a %s! Choose something else!"CLASS_NAMES[key]);
        
ChooseAnimal(id);
        return;
    }
    
client_print(idprint_chat"[Animal Mod] You are now a %s!"key);
    
g_PlayerClass[id] = key;      
    
ShowHUD(id);
}

public 
ResetHUD(id)
{
    if (
g_PlayerClass[id] == CLASS_NOTHING)
         
ChooseAnimal(id);


Aquí pondremos el code que hará que el jugador gane experiencia:

PHP Code:

public DeathMsg()
{
    if (!
get_cvar_num("sv_animalmod")) //Esto significa que si la cvar "sv_animalmod" esta activada, el plugin funcionará como queremos
         
return;
    
    new 
attacker read_data(1)
    
    if (
g_PlayerClass[attacker] == CLASS_NOTHING)
         return;
    
    if(
g_PlayerLevel[attacker] == NUM_OF_LEVELS)
         return;
    
    
g_PlayerXP[attacker] += get_cvar_num("XP_per_kill")
    
    if(
g_PlayerXP[attacker] >= LEVELS[g_PlayerLevel[attacker]])
    {
        ++
g_PlayerLevel[attacker];
         
        
client_print(attacker_:print_chat"[Animal Mod] Congratulations! You are now level %i!"g_PlayerLevel[attacker])
    }
    
ShowHUD(attacker);


Este es un mensaje que le mostrará al jugador su nivel y xp:

PHP Code:

ShowHUD(id)    
{
    new 
HUD[51]
    
format(HUD50"[%s]Level: %i XP: %i"CLASS_NAMES[g_PlayerClass[id]], g_PlayerLevel[id], g_PlayerXP[id])

    
message_begin(MSG_ONEgmsgStatusText, {0,0,0}, id)
    
write_byte(0)
    
write_string(HUD)
    
message_end()


Y finalmente aquí hará que cuando entre otro jugador al servidor, este no obtenga el level o xp de otro.

PHP Code:

public client_connect(id)
{
    
g_PlayerClass[id] = CLASS_NOTHING;
    
g_PlayerXP[id] = 0;
    
g_PlayerLevel[id] = 0;


Espero que les haya gustado, este tutorial NO es mío, solo lo TRADUCÍ.
Crédito al autor.

Si tienen las ganas de postear para burlarse o algo que no tenga que ver con el tutorial por favor no lo hagan.

Fraancooo-. 12-30-2009 22:57

Re: [ES][TUT] Crear un XP Mod
 
Esto ya lo traduci yo y antes qe yo larito xDD
EDIT: http://forums.alliedmods.net/showthread.php?t=103031
EDIT2: Aunqe el mio esta mal traducido O_O

TucanN# 12-30-2009 23:13

Re: [ES][TUT] Crear un XP Mod
 
y de que sirve XP MOD?

Fraancooo-. 12-30-2009 23:15

Re: [ES][TUT] Crear un XP Mod
 
Quote:

Originally Posted by TucanN# (Post 1037265)
y de que sirve XP MOD?

Modo de experienciaa... con distintas cosas .. :P

tomjz 12-30-2009 23:22

Re: [ES][TUT] Crear un XP Mod
 
Quote:

Originally Posted by Fraancooo-. (Post 1037253)
Esto ya lo traduci yo y antes qe yo larito xDD
EDIT: http://forums.alliedmods.net/showthread.php?t=103031
EDIT2: Aunqe el mio esta mal traducido O_O

JAJAJAJAJAJAJA como un pajaro y un pez JAJJAJAJJJAJAJAJAJAJJA

Zapdos1 12-31-2009 07:51

Re: [ES][TUT] Crear un XP Mod
 
Quote:

Originally Posted by Fraancooo-. (Post 1037253)
Esto ya lo traduci yo y antes qe yo larito xDD
EDIT: http://forums.alliedmods.net/showthread.php?t=103031
EDIT2: Aunqe el mio esta mal traducido O_O

xD, bueno, me fije que el que tu usaste es este: http://forums.alliedmods.net/showthread.php?t=66497

este yo ya lo usé y me da muchos errores, no es muy eficiente. en cambio el que subí yo compila perfecto xD.

Quote:

Originally Posted by tomjz
JAJAJAJAJAJAJA como un pajaro y un pez JAJJAJAJJJAJAJAJAJAJJA

con ganas de spammear???

Zapdos1 12-31-2009 09:10

Re: [ES][TUT] Crear un XP Mod
 
Quote:

Originally Posted by TucanN# (Post 1037265)
y de que sirve XP MOD?

El XP Mod es un Sistema de Levels que muchos han querido hacer xD, pero una gran parte de esos XP Mods que hacen terminan con errores, etc. =/

Quote:

Originally Posted by Hasler5
buen tuto :)

gracias ^^

Dio 01-03-2010 12:08

Re: [ES][TUT] Crear un XP Mod
 
Ya hice todo lo del tuto y lo compile, y muy bien todo pero a la hora de ponerlo en el server me tira esto:
Code:

L 01/03/2010 - 18:04:52: Function "ResetHud" was not found
L 01/03/2010 - 18:04:52: [AMXX] Run time error 19 (plugin "animal.amxx") - debug not enabled!
L 01/03/2010 - 18:04:52: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes

Luego despues le pongo lo del debug en el plugins.ini y me sale esto otro:
Code:

L 01/03/2010 - 18:06:53: Function "ResetHud" was not found
L 01/03/2010 - 18:06:53: [AMXX] Displaying debug trace (plugin "animal.amxx")
L 01/03/2010 - 18:06:53: [AMXX] Run time error 19: function not found
L 01/03/2010 - 18:06:53: [AMXX]    [0] animal.sma::plugin_init (line


vazmar 01-03-2010 12:11

Re: [ES][TUT] Crear un XP Mod
 
Capaz que me mando cualquiera, pero lei hace poco, no me acuerdo d quien, que la funcion no tenga el mismo nombre q el evento.. osea, resetHUD
cambia esto, no se si ssera pero proba
si me mande cualquiera diganme :P

pone asi
register_event("ResetHUD", "Reset_Hud", "b")

Dio 01-03-2010 12:21

Re: [ES][TUT] Crear un XP Mod
 
Quote:

Originally Posted by vazmar (Post 1041524)
Capaz que me mando cualquiera, pero lei hace poco, no me acuerdo d quien, que la funcion no tenga el mismo nombre q el evento.. osea, resetHUD
cambia esto, no se si ssera pero proba
si me mande cualquiera diganme :P

pone asi
register_event("ResetHUD", "Reset_Hud", "b")

Si le quito eso al .sma no me sale el error pero el mod no funciona, se queda igual.


All times are GMT -4. The time now is 11:04.

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