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(id, keys, menu, -1, "menu_ChooseAnimal")
}
Aquí le mandará mensajes al jugador según la clase de animal que escoja.
PHP Code:
public MenuAction_ChooseAnimal(id, pclass:key)
{
if (key == g_PlayerClass[id])
{
client_print(id, print_chat, "[Animal Mod] You are already a %s! Choose something else!", CLASS_NAMES[key]);
ChooseAnimal(id);
return;
}
client_print(id, print_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(HUD, 50, "[%s]Level: %i XP: %i", CLASS_NAMES[g_PlayerClass[id]], g_PlayerLevel[id], g_PlayerXP[id])
message_begin(MSG_ONE, gmsgStatusText, {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.