add some includes I use

This commit is contained in:
Jackzie 2021-01-21 16:56:10 -06:00
parent 81337fe89f
commit 266f2ed081
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
7 changed files with 5494 additions and 0 deletions

1015
scripting/include/dhooks.inc Normal file

File diff suppressed because it is too large Load diff

499
scripting/include/l4d2.inc Normal file
View file

@ -0,0 +1,499 @@
/**
* ___ _______ _______ _______ _ ___ ______ _______ _______ ______
* | | | || || | | | | | | | | || _ || |
* | | | ___|| ___||_ _| | |_| | | _ || ___|| |_| || _ |
* | | | |___ | |___ | | | | | | | || |___ | || | | |
* | |___ | ___|| ___| | | |___ | | |_| || ___|| || |_| |
* | || |___ | | | | | | | || |___ | _ || |
* |_______||_______||___| |___| |___| |______| |_______||__| |__||______|
*
* This include contains a ton of useful stocks and functions you can use for Left 4 Dead (2).
* Author: Keith Warren (Drixevel)
* https://github.com/Drixevel
*
* NOTE: The best way to use this include is to copy and paste into your projects manually.
* Credits:
**/
#if defined _misc_l4d_included
#endinput
#endif
#define _misc_l4d_included
enum L4DGame
{
L4DGame_L4D = 0,
L4DGame_L4D2 = 1
}
enum L4DTeam
{
L4DTeam_Unassigned = 0,
L4DTeam_Spectator = 1,
L4DTeam_Survivors = 2,
L4DTeam_Infected = 3
}
enum L4DSurvivor
{
L4DSurvivor_Bill = 0,
L4DSurvivor_Zoey = 1,
L4DSurvivor_Louis = 2,
L4DSurvivor_Francis = 3
}
enum L4D2Survivor
{
L4D2Survivor_Nick = 0,
L4D2Survivor_Rochelle = 1,
L4D2Survivor_Coach = 2,
L4D2Survivor_Ellis = 3
}
enum L4DInfected
{
L4DInfected_None = 0,
L4DInfected_Smoker = 1,
L4DInfected_Boomer = 2,
L4DInfected_Hunter = 3,
L4DInfected_Witch = 4,
L4DInfected_Tank = 5
}
enum L4D2Infected
{
L4D2Infected_None = 0,
L4D2Infected_Smoker = 1,
L4D2Infected_Boomer = 2,
L4D2Infected_Hunter = 3,
L4D2Infected_Spitter = 4,
L4D2Infected_Jockey = 5,
L4D2Infected_Charger = 6,
L4D2Infected_Witch = 7,
L4D2Infected_Tank = 8
}
/**
* Gets a client's current team.
*
* @param client Client index.
* @return Current L4DTeam of client.
* @error Invalid client index.
*/
stock L4DTeam L4D_GetClientTeam(int client)
{
return view_as<L4DTeam>(GetClientTeam(client));
}
/**
* Gets the current group of survivors assigned to the map.
* @return L4DGame enum index.
*/
stock L4DGame L4D_GetSurvivorGroup()
{
int entity = -1; char sCharacter[32];
while ((entity = FindEntityByClassname(entity, "info_survivor_position")) != -1)
{
GetEntPropString(entity, Prop_Data, "m_iszSurvivorName", sCharacter, sizeof(sCharacter));
if (strlen(sCharacter) > 0 && (StrEqual(sCharacter, "Bill") || StrEqual(sCharacter, "Zoey") || StrEqual(sCharacter, "Louis") || StrEqual(sCharacter, "Francis")))
return L4DGame_L4D;
}
return L4DGame_L4D2;
}
/**
* Checks if the survivor is incapped.
*
* @param client Players index.
* @return True if player is incapacitated, false otherwise.
*/
stock bool L4D_IsClientIncapacitated(int client)
{
return view_as<bool>(GetEntProp(client, Prop_Send, "m_isIncapacitated"));
}
stock bool L4D_IsClientIncapped(int client)
{
return view_as<bool>(GetEntProp(client, Prop_Send, "m_isIncapacitated"));
}
/**
* Checks if the survivor is capped.
*
* @param client Players index.
* @return True if the player is capped, false otherwise.
*/
stock bool L4D_IsPlayerCapped(int client)
{
if(GetEntPropEnt(client, Prop_Send, "m_pummelAttacker") > 0 ||
GetEntPropEnt(client, Prop_Send, "m_carryAttacker") > 0 ||
GetEntPropEnt(client, Prop_Send, "m_pounceAttacker") > 0 ||
GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker") > 0 ||
GetEntPropEnt(client, Prop_Send, "m_pounceAttacker") > 0 ||
GetEntPropEnt(client, Prop_Send, "m_tongueOwner") > 0)
return true;
return false;
}
/*********************************************************************/
/*********************************************************************/
//Survivors
/*********************************************************************/
/*********************************************************************/
/**
* Retrieves the survivor ID of the client for L4D.
*
* @param client Players index.
* @return Index of the survivor, -1 otherwise.
*/
stock L4DSurvivor L4D_GetClientSurvivorId(int client)
{
int offset = FindSendPropInfo("CTerrorPlayer", "m_survivorCharacter");
return view_as<L4DSurvivor>(GetEntData(client, offset, 1));
}
/**
* Retrieves the survivor ID of the client for L4D2.
*
* @param client Players index.
* @return Index of the survivor, -1 otherwise.
*/
stock L4D2Survivor L4D2_GetClientSurvivorId(int client)
{
int offset = FindSendPropInfo("CTerrorPlayer", "m_survivorCharacter");
return view_as<L4D2Survivor>(GetEntData(client, offset, 1));
}
/**
* Retrieves the survivor name of the client for L4D.
*
* @param client Players index.
* @return True if found, false otherwise.
*/
stock bool L4D_GetClientSurvivorName(int client, char[] name, int size)
{
return L4D_GetSurvivorName(L4D_GetClientSurvivorId(client), name, size);
}
/**
* Retrieves the survivor name of the client for L4D2.
*
* @param client Players index.
* @return True if found, false otherwise.
*/
stock bool L4D2_GetClientSurvivorName(int client, char[] name, int size)
{
return L4D2_GetSurvivorName(L4D2_GetClientSurvivorId(client), name, size);
}
/**
* Retrieves the ID of any of the L4D survivors.
*
* @param name Name of the survivor.
* @return The ID of the survivor, -1 for not found.
*/
stock L4DSurvivor L4D_GetSurvivorID(const char[] name)
{
if (StrEqual(name, "bill", false))
return L4DSurvivor_Bill;
else if (StrEqual(name, "zoey", false))
return L4DSurvivor_Zoey;
else if (StrEqual(name, "louis", false))
return L4DSurvivor_Louis;
else if (StrEqual(name, "francis", false))
return L4DSurvivor_Francis;
return -1;
}
/**
* Retrieves the ID of any of the L4D2 survivors.
*
* @param name Name of the survivor.
* @return The ID of the survivor, -1 for not found.
*/
stock L4D2Survivor L4D2_GetSurvivorID(const char[] name)
{
if (StrEqual(name, "nick", false))
return L4D2Survivor_Nick;
else if (StrEqual(name, "rochelle", false))
return L4D2Survivor_Rochelle;
else if (StrEqual(name, "coach", false))
return L4D2Survivor_Coach;
else if (StrEqual(name, "ellis", false))
return L4D2Survivor_Ellis;
return -1;
}
/**
* Retrieves the name of any of the L4D survivors.
*
* @param id ID of the survivor.
* @return True if found and buffer filled, false otherwise.
*/
stock bool L4D_GetSurvivorName(L4DSurvivor id, char[] name, int size, bool capitalize = false)
{
switch (id)
{
case L4DSurvivor_Bill:
{
strcopy(name, size, capitalize ? "Bill" : "bill");
return true;
}
case L4DSurvivor_Zoey:
{
strcopy(name, size, capitalize ? "Zoey" : "zoey");
return true;
}
case L4DSurvivor_Louis:
{
strcopy(name, size, capitalize ? "Louis" : "louis");
return true;
}
case L4DSurvivor_Francis:
{
strcopy(name, size, capitalize ? "Francis" : "francis");
return true;
}
}
return false;
}
/**
* Retrieves the name of any of the L4D2 survivors.
*
* @param id ID of the survivor.
* @return True if found and buffer filled, false otherwise.
*/
stock bool L4D2_GetSurvivorName(L4D2Survivor id, char[] name, int size, bool capitalize = false)
{
switch (id)
{
case L4D2Survivor_Nick:
{
strcopy(name, size, capitalize ? "Nick" : "nick");
return true;
}
case L4D2Survivor_Rochelle:
{
strcopy(name, size, capitalize ? "Rochelle" : "rochelle");
return true;
}
case L4D2Survivor_Coach:
{
strcopy(name, size, capitalize ? "Coach" : "coach");
return true;
}
case L4D2Survivor_Ellis:
{
strcopy(name, size, capitalize ? "Ellis" : "ellis");
return true;
}
}
return false;
}
/*********************************************************************/
/*********************************************************************/
//Infected
/*********************************************************************/
/*********************************************************************/
/**
* Retrieves the infected ID of the client for L4D.
*
* @param client Players index.
* @return Index of the infected, -1 otherwise.
*/
stock L4DInfected L4D_GetClientInfectedId(int client)
{
return view_as<L4DInfected>(GetEntProp(client, Prop_Send, "m_zombieClass"));
}
/**
* Retrieves the infected ID of the client for L4D2.
*
* @param client Players index.
* @return Index of the infected, -1 otherwise.
*/
stock L4D2Infected L4D2_GetClientInfectedId(int client)
{
return view_as<L4D2Infected>(GetEntProp(client, Prop_Send, "m_zombieClass"));
}
/**
* Retrieves the infected name of the client for L4D.
*
* @param client Players index.
* @return True if found, false otherwise.
*/
stock bool L4D_GetClientInfectedName(int client, char[] name, int size)
{
return L4D_GetInfectedName(L4D_GetClientInfectedId(client), name, size);
}
/**
* Retrieves the infected name of the client for L4D2.
*
* @param client Players index.
* @return True if found, false otherwise.
*/
stock bool L4D2_GetClientInfectedName(int client, char[] name, int size)
{
return L4D2_GetInfectedName(L4D2_GetClientInfectedId(client), name, size);
}
/**
* Retrieves the ID of any of the L4D infected.
*
* @param name Name of the infected.
* @return The ID of the infected, -1 for not found.
*/
stock L4DInfected L4D_GetInfectedID(const char[] name)
{
if (StrEqual(name, "smoker", false))
return L4DInfected_Smoker;
else if (StrEqual(name, "boomer", false))
return L4DInfected_Boomer;
else if (StrEqual(name, "hunter", false))
return L4DInfected_Hunter;
else if (StrEqual(name, "witch", false))
return L4DInfected_Witch;
else if (StrEqual(name, "tank", false))
return L4DInfected_Tank;
return L4DInfected_None;
}
/**
* Retrieves the ID of any of the L4D2 infected.
*
* @param name Name of the infected.
* @return The ID of the infected, -1 for not found.
*/
stock L4D2Infected L4D2_GetInfectedID(const char[] name)
{
if (StrEqual(name, "smoker", false))
return L4D2Infected_Smoker;
else if (StrEqual(name, "boomer", false))
return L4D2Infected_Boomer;
else if (StrEqual(name, "hunter", false))
return L4D2Infected_Hunter;
else if (StrEqual(name, "spitter", false))
return L4D2Infected_Spitter;
else if (StrEqual(name, "charger", false))
return L4D2Infected_Charger;
else if (StrEqual(name, "jockey", false))
return L4D2Infected_Jockey;
else if (StrEqual(name, "witch", false))
return L4D2Infected_Witch;
else if (StrEqual(name, "tank", false))
return L4D2Infected_Tank;
return L4D2Infected_None;
}
/**
* Retrieves the name of any of the L4D infected.
*
* @param id ID of the infected.
* @return True if found and buffer filled, false otherwise.
*/
stock bool L4D_GetInfectedName(L4DInfected id, char[] name, int size, bool capitalize = false)
{
switch (id)
{
case L4DInfected_None:
return false;
case L4DInfected_Smoker:
{
strcopy(name, size, capitalize ? "Smoker" : "smoker");
return true;
}
case L4DInfected_Boomer:
{
strcopy(name, size, capitalize ? "Boomer" : "boomer");
return true;
}
case L4DInfected_Hunter:
{
strcopy(name, size, capitalize ? "Hunter" : "hunter");
return true;
}
case L4DInfected_Witch:
{
strcopy(name, size, capitalize ? "Witch" : "witch");
return true;
}
case L4DInfected_Tank:
{
strcopy(name, size, capitalize ? "Tank" : "tank");
return true;
}
}
return false;
}
/**
* Retrieves the name of any of the L4D2 infected.
*
* @param id ID of the infected.
* @return True if found and buffer filled, false otherwise.
*/
stock bool L4D2_GetInfectedName(L4D2Infected id, char[] name, int size, bool capitalize = false)
{
switch (id)
{
case L4D2Infected_None:
return false;
case L4D2Infected_Smoker:
{
strcopy(name, size, capitalize ? "Smoker" : "smoker");
return true;
}
case L4D2Infected_Boomer:
{
strcopy(name, size, capitalize ? "Boomer" : "boomer");
return true;
}
case L4D2Infected_Hunter:
{
strcopy(name, size, capitalize ? "Hunter" : "hunter");
return true;
}
case L4D2Infected_Spitter:
{
strcopy(name, size, capitalize ? "Spitter" : "spitter");
return true;
}
case L4D2Infected_Jockey:
{
strcopy(name, size, capitalize ? "Jockey" : "jockey");
return true;
}
case L4D2Infected_Charger:
{
strcopy(name, size, capitalize ? "Charger" : "charger");
return true;
}
case L4D2Infected_Witch:
{
strcopy(name, size, capitalize ? "Witch" : "witch");
return true;
}
case L4D2Infected_Tank:
{
strcopy(name, size, capitalize ? "Tank" : "tank");
return true;
}
}
return false;
}

View file

@ -0,0 +1,629 @@
#if defined l4d2_weapons_inc_
#endinput
#endif
#define l4d2_weapons_inc_
#define GETWEAPONNAME(%0) (IsValidWeaponId(WeaponId:(%0)) ? (WeaponNames[_:(%0)]) : "")
#define GETLONGWEAPONNAME(%0) (IsValidWeaponId(WeaponId:(%0)) ? (LongWeaponNames[_:(%0)]) : "")
#define GETMELEEWEAPONNAME(%0) (IsValidWeaponId(MeleeWeaponId:(%0)) ? (MeleeWeaponNames[_:(%0)]) : "")
#define GETLONGMELEEWEAPONNAME(%0) (IsValidWeaponId(MeleeWeaponId:(%0)) ? (LongMeleeWeaponNames[_:(%0)]) : "")
#define GETWEAPONMODEL(%0) (HasValidWeaponModel(WeaponId:(%0)) ? (WeaponModels[_:(%0)]) : "")
#define GETMELEEWEAPONMODEL(%0) (HasValidWeaponModel(MeleeWeaponId:(%0)) ? (MeleeWeaponModels[_:(%0)]) : "")
// Weapon ID enumerations.
// These values are *NOT* arbitrary!
// They are used in game as the weaponid for weapon_spawn entities
enum WeaponId {
WEPID_NONE, // 0
WEPID_PISTOL, // 1
WEPID_SMG, // 2
WEPID_PUMPSHOTGUN, // 3
WEPID_AUTOSHOTGUN, // 4
WEPID_RIFLE, // 5
WEPID_HUNTING_RIFLE, // 6
WEPID_SMG_SILENCED, // 7
WEPID_SHOTGUN_CHROME, // 8
WEPID_RIFLE_DESERT, // 9
WEPID_SNIPER_MILITARY, // 10
WEPID_SHOTGUN_SPAS, // 11
WEPID_FIRST_AID_KIT, // 12
WEPID_MOLOTOV, // 13
WEPID_PIPE_BOMB, // 14
WEPID_PAIN_PILLS, // 15
WEPID_GASCAN, // 16
WEPID_PROPANE_TANK, // 17
WEPID_OXYGEN_TANK, // 18
WEPID_MELEE, // 19
WEPID_CHAINSAW, // 20
WEPID_GRENADE_LAUNCHER, // 21
WEPID_AMMO_PACK, // 22
WEPID_ADRENALINE, // 23
WEPID_DEFIBRILLATOR, // 24
WEPID_VOMITJAR, // 25
WEPID_RIFLE_AK47, // 26
WEPID_GNOME_CHOMPSKI, // 27
WEPID_COLA_BOTTLES, // 28
WEPID_FIREWORKS_BOX, // 29
WEPID_INCENDIARY_AMMO, // 30
WEPID_FRAG_AMMO, // 31
WEPID_PISTOL_MAGNUM, // 32
WEPID_SMG_MP5, // 33
WEPID_RIFLE_SG552, // 34
WEPID_SNIPER_AWP, // 35
WEPID_SNIPER_SCOUT, // 36
WEPID_RIFLE_M60, // 37
WEPID_TANK_CLAW, // 38
WEPID_HUNTER_CLAW, // 39
WEPID_CHARGER_CLAW, // 40
WEPID_BOOMER_CLAW, // 41
WEPID_SMOKER_CLAW, // 42
WEPID_SPITTER_CLAW, // 43
WEPID_JOCKEY_CLAW, // 44
WEPID_MACHINEGUN, // 45
WEPID_VOMIT, // 46
WEPID_SPLAT, // 47
WEPID_POUNCE, // 48
WEPID_LOUNGE, // 49
WEPID_PULL, // 50
WEPID_CHOKE, // 51
WEPID_ROCK, // 52
WEPID_PHYSICS, // 53
WEPID_AMMO, // 54
WEPID_UPGRADE_ITEM // 55
};
// These values are arbitrary
enum MeleeWeaponId
{
WEPID_MELEE_NONE,
WEPID_KNIFE,
WEPID_BASEBALL_BAT,
WEPID_CHAINSAW,
WEPID_CRICKET_BAT,
WEPID_CROWBAR,
WEPID_DIDGERIDOO,
WEPID_ELECTRIC_GUITAR,
WEPID_FIREAXE,
WEPID_FRYING_PAN,
WEPID_GOLF_CLUB,
WEPID_KATANA,
WEPID_MACHETE,
WEPID_RIOT_SHIELD,
WEPID_TONFA
};
// Weapon names for each of the weapons, used in identification.
const char WeaponNames[WeaponId][] =
{
"weapon_none", "weapon_pistol", "weapon_smg", // 0
"weapon_pumpshotgun", "weapon_autoshotgun", "weapon_rifle", // 3
"weapon_hunting_rifle", "weapon_smg_silenced", "weapon_shotgun_chrome", // 6
"weapon_rifle_desert", "weapon_sniper_military", "weapon_shotgun_spas", // 9
"weapon_first_aid_kit", "weapon_molotov", "weapon_pipe_bomb", // 12
"weapon_pain_pills", "weapon_gascan", "weapon_propanetank", // 15
"weapon_oxygentank", "weapon_melee", "weapon_chainsaw", // 18
"weapon_grenade_launcher", "weapon_ammo_pack", "weapon_adrenaline", // 21
"weapon_defibrillator", "weapon_vomitjar", "weapon_rifle_ak47", // 24
"weapon_gnome", "weapon_cola_bottles", "weapon_fireworkcrate", // 27
"weapon_upgradepack_incendiary", "weapon_upgradepack_explosive", "weapon_pistol_magnum", // 30
"weapon_smg_mp5", "weapon_rifle_sg552", "weapon_sniper_awp", // 33
"weapon_sniper_scout", "weapon_rifle_m60", "weapon_tank_claw", // 36
"weapon_hunter_claw", "weapon_charger_claw", "weapon_boomer_claw", // 39
"weapon_smoker_claw", "weapon_spitter_claw", "weapon_jockey_claw", // 42
"weapon_machinegun", "vomit", "splat", // 45
"pounce", "lounge", "pull", // 48
"choke", "rock", "physics", // 51
"ammo", "upgrade_item" // 54
};
// Long weapon names
const char LongWeaponNames[WeaponId][] =
{
"None", "Pistol", "Uzi", // 0
"Pump", "Autoshotgun", "M-16", // 3
"Hunting Rifle", "Mac", "Chrome", // 6
"Desert Rifle", "Military Sniper", "SPAS Shotgun", // 9
"First Aid Kit", "Molotov", "Pipe Bomb", // 12
"Pills", "Gascan", "Propane Tank", // 15
"Oxygen Tank", "Melee", "Chainsaw", // 18
"Grenade Launcher", "Ammo Pack", "Adrenaline", // 21
"Defibrillator", "Bile Bomb", "AK-47", // 24
"Gnome", "Cola Bottles", "Fireworks", // 27
"Incendiary Ammo Pack", "Explosive Ammo Pack", "Deagle", // 30
"MP5", "SG552", "AWP", // 33
"Scout", "M60", "Tank Claw", // 36
"Hunter Claw", "Charger Claw", "Boomer Claw", // 39
"Smoker Claw", "Spitter Claw", "Jockey Claw", // 42
"Turret", "vomit", "splat", // 45
"pounce", "lounge", "pull", // 48
"choke", "rock", "physics", // 51
"ammo", "upgrade_item" // 54
};
// Internal names for melee weapons
char MeleeWeaponNames[MeleeWeaponId][] =
{
"",
"knife",
"baseball_bat",
"chainsaw",
"cricket_bat",
"crowbar",
"didgeridoo",
"electric_guitar",
"fireaxe",
"frying_pan",
"golfclub",
"katana",
"machete",
"riotshield",
"tonfa"
};
// Long melee weapon names
const char LongMeleeWeaponNames[MeleeWeaponId][] =
{
"None",
"Knife",
"Baseball Bat",
"Chainsaw",
"Cricket Bat",
"Crowbar",
"didgeridoo", // derp
"Guitar",
"Axe",
"Frying Pan",
"Golf Club",
"Katana",
"Machete",
"Riot Shield",
"Tonfa"
};
// World weapon models for each of the weapons. Useful for making new weapon spawns.
// Some models are left blank because no single model can be given, the model is known or none exist.
const char WeaponModels[WeaponId][] =
{
"",
"/w_models/weapons/w_pistol_B.mdl",
"/w_models/weapons/w_smg_uzi.mdl",
"/w_models/weapons/w_shotgun.mdl",
"/w_models/weapons/w_autoshot_m4super.mdl",
"/w_models/weapons/w_rifle_m16a2.mdl",
"/w_models/weapons/w_sniper_mini14.mdl",
"/w_models/weapons/w_smg_a.mdl",
"/w_models/weapons/w_pumpshotgun_a.mdl",
"/w_models/weapons/w_desert_rifle.mdl", // "/w_models/weapons/w_rifle_b.mdl"
"/w_models/weapons/w_sniper_military.mdl",
"/w_models/weapons/w_shotgun_spas.mdl",
"/w_models/weapons/w_eq_medkit.mdl",
"/w_models/weapons/w_eq_molotov.mdl",
"/w_models/weapons/w_eq_pipebomb.mdl",
"/w_models/weapons/w_eq_painpills.mdl",
"/props_junk/gascan001a.mdl",
"/props_junk/propanecanister001.mdl",
"/props_equipment/oxygentank01.mdl",
"",
"/weapons/melee/w_chainsaw.mdl",
"/w_models/weapons/w_grenade_launcher.mdl",
"",
"/w_models/weapons/w_eq_adrenaline.mdl",
"/w_models/weapons/w_eq_defibrillator.mdl",
"/w_models/weapons/w_eq_bile_flask.mdl",
"/w_models/weapons/w_rifle_ak47.mdl",
"/props_junk/gnome.mdl",
"/w_models/weapons/w_cola.mdl",
"/props_junk/explosive_box001.mdl",
"/w_models/weapons/w_eq_incendiary_ammopack.mdl",
"/w_models/weapons/w_eq_explosive_ammopack.mdl",
"/w_models/weapons/w_desert_eagle.mdl",
"/w_models/weapons/w_smg_mp5.mdl",
"/w_models/weapons/w_rifle_sg552.mdl",
"/w_models/weapons/w_sniper_awp.mdl",
"/w_models/weapons/w_sniper_scout.mdl",
"/w_models/weapons/w_m60.mdl",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""
};
const char MeleeWeaponModels[MeleeWeaponId][] =
{
"",
"/w_models/weapons/w_knife_t.mdl",
"/weapons/melee/w_bat.mdl",
"/weapons/melee/w_chainsaw.mdl",
"/weapons/melee/w_cricket_bat.mdl",
"/weapons/melee/w_crowbar.mdl",
"/weapons/melee/w_didgeridoo.mdl",
"/weapons/melee/w_electric_guitar.mdl",
"/weapons/melee/w_fireaxe.mdl",
"/weapons/melee/w_frying_pan.mdl",
"/weapons/melee/w_golfclub.mdl",
"/weapons/melee/w_katana.mdl",
"/weapons/melee/w_machete.mdl",
"/weapons/melee/w_riotshield.mdl",
"/weapons/melee/w_tonfa.mdl"
};
const int WeaponSlots[WeaponId] =
{
-1, // WEPID_NONE
1, // WEPID_PISTOL
0, // WEPID_SMG
0, // WEPID_PUMPSHOTGUN
0, // WEPID_AUTOSHOTGUN
0, // WEPID_RIFLE
0, // WEPID_HUNTING_RIFLE
0, // WEPID_SMG_SILENCED
0, // WEPID_SHOTGUN_CHROME
0, // WEPID_RIFLE_DESERT
0, // WEPID_SNIPER_MILITARY
0, // WEPID_SHOTGUN_SPAS
3, // WEPID_FIRST_AID_KIT
2, // WEPID_MOLOTOV
2, // WEPID_PIPE_BOMB
4, // WEPID_PAIN_PILLS
-1, // WEPID_GASCAN
-1, // WEPID_PROPANE_TANK
-1, // WEPID_OXYGEN_TANK
1, // WEPID_MELEE
1, // WEPID_CHAINSAW
0, // WEPID_GRENADE_LAUNCHER
3, // WEPID_AMMO_PACK
4, // WEPID_ADRENALINE
3, // WEPID_DEFIBRILLATOR
2, // WEPID_VOMITJAR
0, // WEPID_RIFLE_AK47
-1, // WEPID_GNOME_CHOMPSKI
-1, // WEPID_COLA_BOTTLES
-1, // WEPID_FIREWORKS_BOX
3, // WEPID_INCENDIARY_AMMO
3, // WEPID_FRAG_AMMO
1, // WEPID_PISTOL_MAGNUM
0, // WEPID_SMG_MP5
0, // WEPID_RIFLE_SG552
0, // WEPID_SNIPER_AWP
0, // WEPID_SNIPER_SCOUT
0, // WEPID_RIFLE_M60
-1, // WEPID_TANK_CLAW
-1, // WEPID_HUNTER_CLAW
-1, // WEPID_CHARGER_CLAW
-1, // WEPID_BOOMER_CLAW
-1, // WEPID_SMOKER_CLAW
-1, // WEPID_SPITTER_CLAW
-1, // WEPID_JOCKEY_CLAW
-1, // WEPID_MACHINEGUN
-1, // WEPID_FATAL_VOMIT
-1, // WEPID_EXPLODING_SPLAT
-1, // WEPID_LUNGE_POUNCE
-1, // WEPID_LOUNGE
-1, // WEPID_FULLPULL
-1, // WEPID_CHOKE
-1, // WEPID_THROWING_ROCK
-1, // WEPID_TURBO_PHYSICS
-1, // WEPID_AMMO
-1 // WEPID_UPGRADE_ITEM
};
enum L4D2WeaponSlot
{
L4D2WeaponSlot_Primary,
L4D2WeaponSlot_Secondary,
L4D2WeaponSlot_Throwable,
L4D2WeaponSlot_HeavyHealthItem,
L4D2WeaponSlot_LightHealthItem
};
static Handle hWeaponNamesTrie = INVALID_HANDLE;
static Handle hMeleeWeaponNamesTrie = INVALID_HANDLE;
static Handle hMeleeWeaponModelsTrie = INVALID_HANDLE;
stock void InitWeaponNamesTrie() {
hWeaponNamesTrie = CreateTrie();
for(new i = 0; i < _:WeaponId; i++)
{
SetTrieValue(hWeaponNamesTrie, WeaponNames[WeaponId:i], i);
}
hMeleeWeaponNamesTrie = CreateTrie();
hMeleeWeaponModelsTrie = CreateTrie();
for (new i = 0; i < _:MeleeWeaponId; ++i)
{
SetTrieValue(hMeleeWeaponNamesTrie, MeleeWeaponNames[MeleeWeaponId:i], i);
SetTrieString(hMeleeWeaponModelsTrie, MeleeWeaponModels[MeleeWeaponId:i], MeleeWeaponNames[MeleeWeaponId:i]);
}
}
/**
* Performs bounds checking to determine if a WeaponId is valid
* @remark Simple check to see if wepid has a garbage value
*
* @param wepid WeaponId to check for validity
* @return True if wepid is valid, false otherwise.
*/
stock bool IsValidWeaponId({WeaponId, MeleeWeaponId} wepid, tagType = tagof(wepid))
{
if (tagType == tagof(MeleeWeaponId))
{
return MeleeWeaponId:wepid >= WEPID_MELEE_NONE && MeleeWeaponId:wepid < MeleeWeaponId;
}
return wepid >= WEPID_NONE && wepid < WeaponId;
}
/**
* Get the player weapon slot used by the given WeaponId.
*
* @param wepid WeaponId to get the slot for.
* @return Slot number (0-4) or -1 for invalid WeaponId or no slot
*/
stock int GetSlotFromWeaponId(WeaponId wepid)
{
return IsValidWeaponId(wepid) ? WeaponSlots[wepid] : -1;
}
/**
* Checks to see if a given weaponid has a known WeaponModel in this file's model array
* @remark Some weapons (like weapon_melee) have multiple valid models, and this will report false for them.
*
* @param wepid WeaponId to check for a known weapon model for.
* @return True if a valid weapon model exists for wepid, false otherwise.
*/
stock bool:HasValidWeaponModel({WeaponId, MeleeWeaponId}:wepid, tagType = tagof(wepid))
{
if (tagType == tagof(MeleeWeaponId))
{
return IsValidWeaponId(MeleeWeaponId:wepid) && MeleeWeaponModels[MeleeWeaponId:wepid][0] != '\0';
}
return IsValidWeaponId(wepid) && WeaponModels[wepid][0] != '\0';
}
/**
* Tries to look up a WeaponId for a given Weapon Name.
*
* @param weaponName Weapon name string to look up Id from
* @return The corresponding WeaponId if found, else WEPID_NONE
*/
stock WeaponId WeaponNameToId(const char weaponName[])
{
new WeaponID:id;
if(hWeaponNamesTrie == INVALID_HANDLE)
{
InitWeaponNamesTrie();
}
if(GetTrieValue(hWeaponNamesTrie, weaponName, id))
{
return WeaponId:id;
}
return WEPID_NONE;
}
/**
* Tries to look up L4D2's internal weapon name for a given WeaponId.
*
* @param wepid WeaponId To get name of.
* @param nameBuffer String buffer to write the weapon name to.
* @param length Max length which can be written to the buffer.
* @return Number of bytes written to buffer, or 0 for invalid weaponId.
*/
stock GetWeaponName({WeaponId, MeleeWeaponId}:wepid, String:nameBuffer[], length, tagType = tagof(wepid))
{
if (tagType == tagof(MeleeWeaponId))
{
strcopy(nameBuffer, length, GETMELEEWEAPONNAME(wepid));
}
else
{
strcopy(nameBuffer, length, GETWEAPONNAME(wepid));
}
}
/**
* Tries to look up L4D2's internal weapon name for a given WeaponId.
*
* @param wepid WeaponId To get name of.
* @param nameBuffer String buffer to write the weapon name to.
* @param length Max length which can be written to the buffer.
* @return Number of bytes written to buffer, or 0 for invalid weaponId.
*/
stock GetLongWeaponName({WeaponId, MeleeWeaponId}:wepid, String:nameBuffer[], length, tagType = tagof(wepid))
{
if (tagType == tagof(MeleeWeaponId))
{
strcopy(nameBuffer, length, GETLONGMELEEWEAPONNAME(wepid));
}
else
{
strcopy(nameBuffer, length, GETLONGWEAPONNAME(wepid));
}
}
/**
* Tries to look up the weapon model for a given WeaponId.
* @remarks You should use HasValidWeaponModel to make sure the WeaponId you're looking up has a valid model associated with it.
*
* @param wepid WeaponId To get name of.
* @param nameBuffer String buffer to write the weapon name to.
* @param length Max length which can be written to the buffer.
* @return Number of bytes written to buffer, or 0 for invalid weaponid or no weapon model available.
*/
stock GetWeaponModel({WeaponId, MeleeWeaponId}:wepid, String:modelBuffer[], length, tagType = tagof(wepid))
{
if (tagType == tagof(MeleeWeaponId))
{
strcopy(modelBuffer, length, GETMELEEWEAPONMODEL(wepid));
}
else
{
strcopy(modelBuffer, length, GETWEAPONMODEL(wepid));
}
}
/**
* Identifies a weapon spawn or weapon entity as a WeaponID
* @remark Should work on most weapon ents--even spawns, singles, held, etc.
*
* @param entity Index of entity to identify
* @return WeaponID for the entity if it is a weapon, WEPID_NONE otherwise
*/
stock WeaponId:IdentifyWeapon(entity)
{
if(!entity || !IsValidEntity(entity) || !IsValidEdict(entity))
{
return WEPID_NONE;
}
decl String:class[64];
if(!GetEdictClassname(entity, class, sizeof(class)))
{
return WEPID_NONE;
}
if(StrEqual(class, "weapon_spawn"))
{
return WeaponId:GetEntProp(entity,Prop_Send,"m_weaponID");
}
new len = strlen(class);
if(len-6 > 0 && StrEqual(class[len-6], "_spawn"))
{
class[len-6]='\0';
return WeaponNameToId(class);
}
return WeaponNameToId(class);
}
// Helper function used for getting an entity's internal melee name
stock bool:GetMeleeWeaponNameFromEntity(entity, String:buffer[], length) {
decl String:classname[64];
if (! GetEdictClassname(entity, classname, sizeof(classname)))
{
return false;
}
if (StrEqual(classname, "weapon_melee_spawn"))
{
if (hMeleeWeaponModelsTrie == INVALID_HANDLE)
{
InitWeaponNamesTrie();
}
decl String:sModelName[128];
GetEntPropString(entity, Prop_Data, "m_ModelName", sModelName, sizeof(sModelName));
// Strip models directory
if (strncmp(sModelName, "models/", 7, false) == 0)
{
strcopy(sModelName, sizeof(sModelName), sModelName[6]);
}
if (GetTrieString(hMeleeWeaponModelsTrie, sModelName, buffer, length))
{
return true;
}
return false;
}
else if (StrEqual(classname, "weapon_melee"))
{
GetEntPropString(entity, Prop_Data, "m_strMapSetScriptName", buffer, length);
return true;
}
return false;
}
/**
* Identifies a melee weapon spawn or weapon entity as a MeleeWeaponId
* @remark Should work on most weapon ents--even spawns, singles, held, etc.
*
* @param entity Index of entity to identify
* @return MeleeWeaponId for the entity if it is a weapon, WEPID_MELEE_NONE otherwise
*/
stock MeleeWeaponId:IdentifyMeleeWeapon(entity)
{
if (IdentifyWeapon(entity) != WEPID_MELEE)
{
return WEPID_MELEE_NONE;
}
decl String:sName[128];
if (! GetMeleeWeaponNameFromEntity(entity, sName, sizeof(sName)))
{
return WEPID_MELEE_NONE;
}
if (hMeleeWeaponNamesTrie == INVALID_HANDLE)
{
InitWeaponNamesTrie();
}
new id;
if(GetTrieValue(hMeleeWeaponNamesTrie, sName, id))
{
return MeleeWeaponId:id;
}
return WEPID_MELEE_NONE;
}
/**
* Attempts to convert a weapon spawn entity to a given weapon spawn
* @remark Truthfully, this will work on any entity with origin/rotation.
* Also, requires the weapon to either have a Valid weapon model or have one provided
*
* @param entity Index of entity to convert to weapon spawn
* @param wepid WeaponId of the weapon to have the spawner hold
* @param count Weapon count for the spawner (default 5)
* @param model World model to use for the weapon spawn
* @return entity of the new weapon spawn, or -1 on errors.
*/
stock ConvertWeaponSpawn(entity, WeaponId:wepid, count=5, const String:model[] = "")
{
if(!IsValidEntity(entity)) return -1;
if(!IsValidWeaponId(wepid)) return -1;
if(model[0] == '\0' && !HasValidWeaponModel(wepid)) return -1;
new Float:origins[3], Float:angles[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", origins);
GetEntPropVector(entity, Prop_Send, "m_angRotation", angles);
AcceptEntityInput(entity, "kill");
entity = CreateEntityByName("weapon_spawn");
if(!IsValidEntity(entity)) return -1;
SetEntProp(entity, Prop_Send, "m_weaponID", wepid);
decl String:buf[64];
if(model[0] == '\0')
{
SetEntityModel(entity, model);
}
else
{
GetWeaponModel(wepid, buf, sizeof(buf));
SetEntityModel(entity, buf);
}
IntToString(count, buf, sizeof(buf));
DispatchKeyValue(entity, "count", buf);
TeleportEntity(entity, origins, angles, NULL_VECTOR);
DispatchSpawn(entity);
SetEntityMoveType(entity,MOVETYPE_NONE);
return entity;
}

View file

@ -0,0 +1,71 @@
const char WEAPON_GUN_GROUPS = [][] {
"rifle",
"sniper",
"smg",
"shotgun"
}
enum WEAPON_TYPES {
Weapon_Rifle,
Weapon_Sniper,
Weapon_SMG,
Weapon_Shotgun
}
const char WEAPONS_RIFLE = []
stock bool IsPrimaryWeapon(const char[] wpnName) {
return StrContains(wpnName, "rifle") > -1
|| StrContains(wpnName, "smg") > -1
|| StrContains(wpnName, "weapon_grenade_launcher") > -1
|| StrContains(wpnName, "sniper") > -1
|| StrContains(wpnName, "shotgun") > -1;
}
stock int GetClientWeaponEntIndex(int client, int slot) {
if(slot >= 0 && slot <= 4) {
int wpnRef = GetPlayerWeaponSlot(client, slot);
if(wpnRef != -1) {
int wpn = EntRefToEntIndex(wpnRef);
if(wpn != INVALID_ENT_REFERENCE) {
return wpn;
}else{
return -1;
}
}else{
return -1;
}
}else{
return -1;
}
}
stock int GetClientSecondaryWeapon(int client) {
return GetClientWeaponEntIndex(client, 1);
}
stock bool GetClientWeaponName(int client, int slot, char[] name, int nameSize) {
int wpn = GetClientWeaponEntIndex(client, slot);
if(wpn > -1) {
GetEntityClassname(wpn, name, nameSize);
return true;
}else{
return false;
}
}
stock bool DoesClientHaveWeapon(int client, int slot, const char[] name) {
char wpn[32];
if(GetClientWeaponName(client, slot, wpn, sizeof(wpn))) {
return StrEqual(wpn, name, false);
}else{
return false;
}
}
stock bool DoesClientHaveMelee(int client) {
int wpnEnt = GetClientSecondaryWeapon(client);
if(wpnEnt > -1) {
char wpn[16];
GetEdictClassname(wpnEnt, wpn, sizeof(wpn));
return StrEqual(wpn, "weapon_melee");
}else{
return false;
}
}

View file

@ -0,0 +1,27 @@
enum Character {
Character_Nick,
Character_Ellis,
Character_Rochelle,
Character_Coach,
Character_Bill,
Character_Francis,
Character_Zoey,
Character_Louis
}
native int IdentityFix_SetPlayerModel(int client, int args);
static bool nativeAvailable, nativeTested;
bool UpdatePlayerIdentity(int client, Character character) {
if(!nativeTested) {
nativeTested = true;
nativeAvailable = GetFeatureStatus(FeatureType_Native, "IdentityFix_SetPlayerModel") == FeatureStatus_Available;
}
if(nativeAvailable) {
int result = IdentityFix_SetPlayerModel(client, view_as<int>(character));
return result == 0;
}else{
return false;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,460 @@
#if defined _multicolors_included
#endinput
#endif
#define _multicolors_included
#define MuCo_VERSION "2.1.2"
#include <multicolors/morecolors>
#include <multicolors/colors>
/*
*
* Credits:
* - Popoklopsi
* - Powerlord
* - exvel
* - Dr. McKay
*
* Based on stamm-colors
* - https://github.com/popoklopsi/Stamm/blob/master/include/stamm/stamm-colors.inc
*
*/
#define PREFIX_MAX_LENGTH 64
#define PREFIX_SEPARATOR "{default} "
/* Global var to check whether colors are fixed or not */
static bool g_bCFixColors;
static char g_sCPrefix[PREFIX_MAX_LENGTH];
/**
* Add a chat prefix before all chat msg
*
* @param sPrefix Prefix
*/
stock void CSetPrefix(const char[] sPrefix, any ...) {
if (!sPrefix[0]) {
return;
}
SetGlobalTransTarget(LANG_SERVER);
VFormat(g_sCPrefix, sizeof(g_sCPrefix) - strlen(PREFIX_SEPARATOR), sPrefix, 2);
// Add ending space
Format(g_sCPrefix, sizeof(g_sCPrefix), "%s%s", g_sCPrefix, PREFIX_SEPARATOR);
}
/**
* Add a chat prefix before all chat msg
*
* @param sPrefix Prefix
*/
stock void CClearPrefix() {
g_sCPrefix[0] = '\0';
}
/**
* Writes a message to a client with the correct stock for the game.
*
* @param client Client index.
* @param message Message (formatting rules).
*
* @error If the client is not connected an error will be thrown.
*/
stock void CPrintToChat(int client, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_PrintToChat(client, "%s%s", g_sCPrefix, buffer);
}
else {
MC_PrintToChat(client, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param message Message (formatting rules)
*/
stock void CPrintToChatAll(const char[] message, any ...) {
if (!g_bCFixColors) {
CFixColors();
}
char buffer[MAX_BUFFER_LENGTH];
if (!IsSource2009()) {
for (int i = 1; i <= MaxClients; ++i) {
if (IsClientInGame(i) && !IsFakeClient(i) && !C_SkipList[i]) {
SetGlobalTransTarget(i);
VFormat(buffer, sizeof(buffer), message, 2);
C_PrintToChat(i, "%s", buffer);
}
C_SkipList[i] = false;
}
}
else {
MC_CheckTrie();
char buffer2[MAX_BUFFER_LENGTH];
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || MC_SkipList[i]) {
MC_SkipList[i] = false;
continue;
}
SetGlobalTransTarget(i);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 2);
MC_ReplaceColorCodes(buffer2);
MC_SendMessage(i, buffer2);
}
}
}
/**
* Writes a message to all of a client's observers.
*
* @param target Client index.
* @param message Message (formatting rules).
*/
stock void CPrintToChatObservers(int target, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
for (int client = 1; client <= MaxClients; client++) {
if (IsClientInGame(client) && !IsPlayerAlive(client) && !IsFakeClient(client)) {
int observee = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
int ObserverMode = GetEntProp(client, Prop_Send, "m_iObserverMode");
if (observee == target && (ObserverMode == 4 || ObserverMode == 5)) {
CPrintToChat(client, buffer);
}
}
}
}
/**
* Writes a message to a client with the correct stock for the game.
*
* @param client Client index.
* @param author Author index.
* @param message Message (formatting rules).
*
* @error If the client is not connected an error will be thrown.
*/
stock void CPrintToChatEx(int client, int author, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 4);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_PrintToChatEx(client, author, "%s%s", g_sCPrefix, buffer);
}
else {
MC_PrintToChatEx(client, author, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Writes a message to all clients with the correct stock for the game.
*
* @param author Author index.
* @param message Message (formatting rules).
*/
stock void CPrintToChatAllEx(int author, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_PrintToChatAllEx(author, "%s%s", g_sCPrefix, buffer);
}
else {
MC_PrintToChatAllEx(author, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Writes a message to all of a client's observers with the correct
* game stock.
*
* @param target Client index.
* @param message Message (formatting rules).
*/
stock void CPrintToChatObserversEx(int target, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
for (int client = 1; client <= MaxClients; client++) {
if (IsClientInGame(client) && !IsPlayerAlive(client) && !IsFakeClient(client)) {
int observee = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
int ObserverMode = GetEntProp(client, Prop_Send, "m_iObserverMode");
if (observee == target && (ObserverMode == 4 || ObserverMode == 5)) {
CPrintToChatEx(client, target, buffer);
}
}
}
}
/**
* Replies to a command with colors
*
* @param client Client to reply to
* @param message Message (formatting rules)
*/
stock void CReplyToCommand(int client, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ReplyToCommand(client, "%s%s", g_sCPrefix, buffer);
}
else {
MC_ReplyToCommand(client, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Replies to a command with colors
*
* @param client Client to reply to
* @param author Client to use for {teamcolor}
* @param message Message (formatting rules)
*/
stock void CReplyToCommandEx(int client, int author, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 4);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ReplyToCommandEx(client, author, "%s%s", g_sCPrefix, buffer);
}
else {
MC_ReplyToCommandEx(client, author, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Remove all tags and print to server
*
* @param message Message (formatting rules)
*/
stock void CPrintToServer(const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
char prefixBuffer[PREFIX_MAX_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 2);
strcopy(prefixBuffer, sizeof(prefixBuffer), g_sCPrefix);
if (!g_bCFixColors) {
CFixColors();
}
CRemoveTags(buffer, sizeof(buffer));
CRemoveTags(prefixBuffer, sizeof(prefixBuffer));
PrintToServer("%s%s", prefixBuffer, buffer);
}
/**
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
*
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* CShowActivity2() is slightly more useful.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*
* @error
*/
stock void CShowActivity(int author, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ShowActivity(author, "%s", buffer);
}
else {
MC_ShowActivity(author, "%s", buffer);
}
}
/**
* Same as C_ShowActivity(), except the tag parameter is used instead of "[SM] " (note that you must supply any spacing).
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to display with.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*
* @error
*/
stock void CShowActivityEx(int author, const char[] tag, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 4);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ShowActivityEx(author, tag, "%s", buffer);
}
else {
MC_ShowActivityEx(author, tag, "%s", buffer);
}
}
/**
* Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar.
* All users receive a message in their chat text, except for the originating client,
* who receives the message based on the current ReplySource.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to prepend to the message.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*
* @error
*/
stock void CShowActivity2(int author, const char[] tag, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 4);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ShowActivity2(author, tag, "%s", buffer);
}
else {
MC_ShowActivity2(author, tag, "%s", buffer);
}
}
/**
* Replaces color tags in a string with color codes
*
* @param message String.
* @param maxlength Maximum length of the string buffer.
*/
stock void CFormatColor(char[] message, int maxlength, int author = -1) {
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
if (author == 0) {
author = -1;
}
C_Format(message, maxlength, author);
}
else {
if (author == -1) {
author = 0;
}
MC_ReplaceColorCodes(message, author, false, maxlength);
}
}
/**
* Removes color tags from a message
*
* @param message Message to remove tags from
* @param maxlen Maximum buffer length
*/
stock void CRemoveTags(char[] message, int maxlen) {
if (!IsSource2009()) {
C_RemoveTags(message, maxlen);
}
else {
MC_RemoveTags(message, maxlen);
}
}
/**
* Fixes missing Lightgreen color.
*/
stock void CFixColors() {
g_bCFixColors = true;
// Replace lightgreen if not exists
if (!C_ColorAllowed(Color_Lightgreen)) {
if (C_ColorAllowed(Color_Lime)) {
C_ReplaceColor(Color_Lightgreen, Color_Lime);
}
else if (C_ColorAllowed(Color_Olive)) {
C_ReplaceColor(Color_Lightgreen, Color_Olive);
}
}
}
stock bool IsSource2009() {
return (GetEngineVersion() == Engine_CSS
|| GetEngineVersion() == Engine_HL2DM
|| GetEngineVersion() == Engine_DODS
|| GetEngineVersion() == Engine_TF2
|| GetEngineVersion() == Engine_SDK2013);
}