Code:
/*------------------------------------------------------------------------------------------------*/
// Created by Sphinx on June 16, 2006.
// Version 1.0.a.0 - Basic coding done.
/*------------------------------------------------------------------------------------------------*/
//Included//
#include <amxmodx>
#include <amxmisc>
/*------------------------------------------------------------------------------------------------*/
//Defined//
#define PLUGIN "Everquest"
#define VERSION "1.0.a.0"
#define AUTHOR "Sphinx"
/*------------------------------------------------------------------------------------------------*/
//Number of Levels//
#define NUM_OF_LEVELS 5
//Defining Classes
enum pclass
{
CLASS_NOTHING=0,
CLASS_WARRIOR,
CLASS_MAGICIAN,
CLASS_ROGUE,
CLASS_CLERIC,
NUM_OF_CLASSES
}
/*------------------------------------------------------------------------------------------------*/
//New Variables//
new pclass:g_PlayerClass[33];
new g_PlayerXP[33];
new g_PlayerLevel[33];
new gmsgStatusText;
new const LEVELS[NUM_OF_LEVELS] = {
// ThisLevelXP+(50*Level) = NextLevelXP
0, // 0 + (50 * 1) = 50
50, // 50 + (50 * 2) = 150
150, // 150 + (50 * 3) = 300
300, // 300 + (50 * 4) = 500
500
}
new const CLASS_NAMES[NUM_OF_CLASSES][] ={
"None",
"Warrior",
"Magician",
"Rogue",
"Cleric"
}
/*------------------------------------------------------------------------------------------------*/
public plugin_init() {
//Plugin
register_plugin("EverQuest Mod", "1.0.a.0", "Sphinx")
//Events
register_event("DeathMsg", "DeathMsg", "a")
register_event("ResetHUD", "ResetHud", "b")
//Cvars
register_cvar("sv_everquest", "1")
register_cvar("XP_per_kill", "20")
//Menu
register_menucmd(register_menuid("menu_ChooseClass"),1023,"MenuAction_ChooseClass");
//Misc
gmsgStatusText = get_user_msgid("StatusText")
}
/*------------------------------------------------------------------------------------------------*/
ChooseClass(id)
{
//The Menu!!
new menu[] = "Everquest: Choose Your Class^n^n1. Warrior^n2. Magician^n3. Rogue^n4. Cleric^n0. Exit"
new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
show_menu(id, keys, menu, -1, "menu_ChooseClass")
}
/*------------------------------------------------------------------------------------------------*/
public MenuAction_ChooseClass(id, pclass:key)
{
if (key == g_PlayerClass[id])
{
client_print(id, print_chat, "[Everquest] You are already a %s! Choose something else!", CLASS_NAMES[key]);
ChooseClass(id);
return;
}
client_print(id, print_chat, "[Everquest] You are now a %s!", key);
g_PlayerClass[id] = key;
ShowHUD(id);
}
/*------------------------------------------------------------------------------------------------*/
public ResetHUD(id)
{
if (g_PlayerClass[id] == CLASS_NOTHING)
{
ChooseClass(id);
}
}
/*------------------------------------------------------------------------------------------------*/
public DeathMsg() {
//Makes sure the mod is on.
if (!get_cvar_num("sv_everquest"))
return;
//Makes sure only the attack gets the exp, and not the whole map.
new attacker = read_data(1)
//Can't get exp unless you are a class
if (g_PlayerClass[attacker] == CLASS_NOTHING)
return;
//You don't get exp if your maxed
if (g_PlayerLevel[attacker] == NUM_OF_LEVELS)
return;
//How Much Xp! Yay!
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, "[Everquest] Congratultaions! You are now level %i!", g_PlayerLevel[attacker])
}
ShowHUD(attacker);
}
/*------------------------------------------------------------------------------------------------*/
public 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
}
/*------------------------------------------------------------------------------------------------*/
public client_connect(id)
{
//Clear previous variables so he does not get the same stats as the person before him.
g_PlayerClass[id] = CLASS_NOTHING;
g_PlayerXP[id] = 0;
g_PlayerLevel[id] = 0;
}
/*------------------------------------------------------------------------------------------------*/
edit: the HUD doesn't show in the game, even after multiple respawns. and I can't get into the menu.