Code:
/*
----------------------------------------------
##############################################
----------------------------------------------
It's only the Warlock were I added a weapon,
dunno why it is bugged.
V 0.2
Realese 2008 3. January
Note :
Only the rouge class have somthing more than
extra health.
Warlock - 150 health
Mage - 150 health
Warrior - 200 health
Rouge - 100 health + 250 % extra speed,
and the half gravity
Added :
Added a hudmsg that tells you wich class you
are, every spawn.
Added a new command 'showchar', when used,
you can se your class!
Added a new command 'clearchar'. when used,
you clear you class
Fixed :
Fixed a lot of small bugs, only 1 error when
compiling. Classes isen't used.
Fixed major problem with the class menu,
know you can chance race without bugs!
----------------------------------------------
##############################################
----------------------------------------------
V 0.1
MOD REALESE 2007 December
----------------------------------------------
##############################################
----------------------------------------------
World of Warcraft TBC Mod
By Alexander Mathiasen
Thanks to
XunTric & PM Class creation
EMP' Menu tutorail
purple_pixie On_spawn funktion
V3X give_weapon
And all other helpfull people at <a href="http://www.forum.alliedmods.net" target="_blank" rel="nofollow noopener">http://www.forum.alliedmods.net</a>
thanks to every one that helped :D
Ive made this mainly on Xuntric XP based tutorial, and EMP's
Menu tutorial. I have looked at the other's code, to find out
things (or be sure), so woulden't be fair if I diden't put them
on the list :-)
*/
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#define PLUGIN "World of Warcraft TBC mod"
#define VERSION "0.2"
#define AUTHOR "AlexanderM"
// Here I create all the class's. I make the 'Nothing' class, so the plugin can se if a client hasen't choosen a class.
#define CLASS_NOTHING 0
#define CLASS_WARLOCK 1
#define CLASS_MAGE 2
#define CLASS_WARRIOR 3
#define CLASS_ROUGE 4
// This is so you don't see, for instance CLASS_WARLOCK in the game.
#define MAXCLASSES 5
#define TASK_REGEN 999
new PlayerClass[33]
new curweapon[33]
// This is where I add other names.
new const CLASSES[MAXCLASSES][] = {
"None",
"Warlock",
"Mage",
"Warrior",
"Rouge"
}
public plugin_init() {
register_plugin("World of Warcraft TBC mod", "0.2", "AlexanderM")
// Makes a cvar, so the host/admin can type sv_wow 0 to turn off.
register_cvar("sv_wow","1")
// Allows a client to write 'Change' and tells the plugin to read 'Change'.
register_clcmd("say /change", "Change")
register_clcmd("say change", "Change")
register_clcmd("say_team /change", "Change")
register_clcmd("say_team change", "Change")
register_concmd("/change", "Change")
register_concmd("change", "Change")
// Allows a client to write 'ShowChar' and tells the plugin to read 'ShowChar'.
register_clcmd("say /showchar", "ShowChar")
register_clcmd("say showchar", "ShowChar")
register_clcmd("say_team /showchar", "ShowChar")
register_clcmd("say_team showchar", "ShowChar")
register_concmd("/showchar", "ShowChar")
register_concmd("showchar", "ShowChar")
// Allows a client to write 'ClearChar' and tells the plugin to read 'ClearChar'
register_clcmd("say /clearchar", "ClearChar")
register_clcmd("say clearchar", "ClearChar")
register_clcmd("say_team /clearchar", "ClearChar")
register_clcmd("say_team clearchar", "ClearChar")
register_concmd("/clearchar", "ClearChar")
register_concmd("clearchar", "ClearChar")
// This is for the rouge's speed. The speed of a client reset's every time you
// chance weapon. So it should be called every time the client chance weapon.
register_event("CurWeapon", "Event_Rouge_Speed", "be","1=1")
// This event is called on spawn. I can use this to give people health or weapons,
// when they spawn.
register_event("ResetHUD","on_spawn","be")
}
public client_connect(id)
{
if(get_cvar_num("sv_wow") == 1)
{
// When a client connect's, I give him the class 'Nothing'.
PlayerClass[id] = CLASS_NOTHING
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
public Change(id)
{
// Should only make this if 'sv_wow' is equal to 1.
if(get_cvar_num("sv_wow") == 1)
{
//I create the menu, and give it a title. I also tells
// the plugin, it should look under 'menu_handler'.
new menu = menu_create("\r[WOW] Character Menu!:", "menu_handler")
// Here I create the options in the menu, give it the number it should be displayed.
// The last '0' is wich admin flag you should be. It is set to 0 becurs every one should
// be able to use this menu.
menu_additem(menu, "\wWarlock", "1", 0)
menu_additem(menu, "\wMage", "2", 0)
menu_additem(menu, "\wWarrior", "3", 0)
menu_additem(menu, "\wRouge", "4", 0)
// Here I create the exit option
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
// Then after all, the menu gets displayed.
menu_display(id, menu, 0)
}
}
public menu_handler(id, menu, item)
{
if (item == MENU_EXIT) {
menu_destroy(menu)
return PLUGIN_HANDLED;
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
new key = str_to_num(data)
switch(key) {
// If client takes option 1, we have to be sure he isen't allready a Warlock.
case 1:{
if(PlayerClass[id] == CLASS_WARLOCK) {
// If the client is a Warlock, I would tell the client.
client_print(id, print_chat, "[WOW] You are allready a Warlock!")
menu_destroy(menu)
// And just to be kind, I open the menu for him again.
Change(id)
return PLUGIN_HANDLED;
}
// Here I tell the plugin to run 'Clear', and it should do it
// for the client who opened the menu '(id)'.
Clear(id)
// Know can I set the client's class to Warlock..
PlayerClass[id] = CLASS_WARLOCK
// Here I show's the client's class with a HUD msg.
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: Warlock")
return PLUGIN_HANDLED;
}
// Know the whole thing comes again, so I haven't commented it.
case 2:{
if(PlayerClass[id] == CLASS_MAGE) {
client_print(id, print_chat, "[WOW] You are allready a Mage!")
menu_destroy(menu)
Change(id)
return PLUGIN_HANDLED;
}
Clear(id)
PlayerClass[id] = CLASS_MAGE
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: Mage")
return PLUGIN_HANDLED;
}
case 3:{
if(PlayerClass[id] == CLASS_WARRIOR) {
client_print(id, print_chat, "[WOW] You are allready a Warrior!")
menu_destroy(menu)
Change(id)
return PLUGIN_HANDLED;
}
Clear(id)
PlayerClass[id] = CLASS_WARRIOR
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: Warrior")
return PLUGIN_HANDLED;
}
case 4:{
if(PlayerClass[id] == CLASS_ROUGE) {
client_print(id, print_chat, "[WOW] You are allready a Rouge!")
menu_destroy(menu)
Change(id)
return PLUGIN_HANDLED;
}
Clear(id)
PlayerClass[id] = CLASS_ROUGE
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: Rouge")
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
public ClearChar(id) {
if(get_cvar_num("sv_wow") == 1) {
// If the client already haven't choosen a class. I don't want to reset it.
if ( PlayerClass[id] == CLASS_NOTHING) {
// Here I write a msg telling him he hasen't choosen a class.
client_print(id, print_chat, "[WOW] You can't clear you character when you havent choosen one!")
// And again I am so kind to open the class menu for the client.
Change(id)
return PLUGIN_HANDLED;
}
// Here I change the client's class to 'Nothing'
PlayerClass[id] = CLASS_NOTHING
// Here I let the client know that the class was succesful reset.
client_print(id, print_chat, "[WOW] You had your character succesful reset!")
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
public Clear(id) {
if(get_cvar_num("sv_wow") == 1) {
// This is sort of the same as above, but I make this with no msg.
// I call this every time a client choose's a class in the 'Change' command.
if ( PlayerClass[id] == CLASS_NOTHING) {
// Again I don't want to reset the class, if the client already
// hasen't choosen a class.
return PLUGIN_HANDLED;
}
// Here I change the class to 'Nothing',
PlayerClass[id] = CLASS_NOTHING
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
public on_spawn(id)
{
if(get_cvar_num("sv_wow") == 0 || !is_user_alive(id))
return PLUGIN_HANDLED
switch(PlayerClass[id])
{
case CLASS_NOTHING:
{
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: None")
Change(id)
}
case CLASS_WARLOCK:
{
fm_give_item(id, "weapon_awp")
fm_set_user_health(id, 150)
// Then I write wich class the client is, always usefull
// to know.
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: Warlock");
}
case CLASS_MAGE:
{
fm_set_user_health(id,150)
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: Mage")
}
case CLASS_WARRIOR:
{
fm_set_user_health(id,200)
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: Warrior")
}
case CLASS_ROUGE:
{
// And here I set the gravity to the half.
fm_set_user_gravity(id,0.5)
// Here I change the client's speed. This only last to the client
// changes weapon. The event below change's the client's speed every
// time the client change's weapon.
fm_set_user_maxspeed(id,(fm_get_user_maxspeed(id)*2.5))
set_hudmessage(0, 255, 255, 0.01, 0.91, 0, 6.0, 3.0)
show_hudmessage(id, "Class: Rouge")
}
}
return PLUGIN_HANDLED
}
public Event_Rouge_Speed(id)
{
if(get_cvar_num("sv_wow") == 1)
{
if ( PlayerClass[id] == CLASS_ROUGE)
{
new dummy;
new tempweapon = get_user_weapon(id,dummy,dummy)
if ( tempweapon != curweapon[id] )
{
curweapon[id] = tempweapon
fm_set_user_maxspeed(id,(fm_get_user_maxspeed(id)*10.5))
}
}
}
}
public ShowChar(id) {
if(get_cvar_num("sv_wow") == 1) {
// Here I se wich class the client is. It is the same code all the way down.
// The only different is, that I open the menu, if the client is the 'Nothing'
// class.
if ( PlayerClass[id] == CLASS_NOTHING) {
Change(id)
set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 12.0)
show_hudmessage(id, "[WOW] You haven't choosen a class !")
return PLUGIN_HANDLED;
}
// As I wrote above, this is just the same code again and again.
if ( PlayerClass[id] == CLASS_WARLOCK) {
set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 12.0)
show_hudmessage(id, "[WOW] You are a Warlock !")
return PLUGIN_HANDLED;
}
if ( PlayerClass[id] == CLASS_MAGE) {
set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 12.0)
show_hudmessage(id, "[WOW] You are a Mage !")
return PLUGIN_HANDLED;
}
if ( PlayerClass[id] == CLASS_WARRIOR) {
set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 12.0)
show_hudmessage(id, "[WOW] You are a Warrior !")
return PLUGIN_HANDLED;
}
if ( PlayerClass[id] == CLASS_ROUGE) {
set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 12.0)
show_hudmessage(id, "[WOW] You are a Rouge !")
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
// Functions below are copied from Fakemeta_Util.inc by VEN
stock fm_give_item(index, const item[])
{
if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
return 0;
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,item))
if (!pev_valid(ent))
return 0;
new Float:origin[3];
pev(index, pev_origin, origin);
set_pev(ent, pev_origin, origin);
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
dllfunc(DLLFunc_Spawn, ent);
new save = pev(ent, pev_solid);
dllfunc(DLLFunc_Touch, ent, index);
if (pev(ent, pev_solid) != save)
return ent;
engfunc(EngFunc_RemoveEntity, ent);
return -1;
}
stock fm_set_user_health(index, health) {
health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);
return 1;
}
stock fm_set_user_gravity(index, Float:gravity = 1.0) {
set_pev(index, pev_gravity, gravity);
return 1;
}
stock fm_set_user_maxspeed(index, Float:speed = -1.0) {
engfunc(EngFunc_SetClientMaxspeed, index, speed);
set_pev(index, pev_maxspeed, speed);
return 1;
}
stock Float:fm_get_user_maxspeed(index) {
new Float:speed;
pev(index, pev_maxspeed, speed);
return speed;
}
It uses Fakemeta instead of fun, so make sure you have the fakemeta module running.