Fixed typo in playerclasses.inc with logging defines, add updated weaponalpha module to track weapon alphas.
This commit is contained in:
parent
67ec1f8433
commit
14c5acf0bf
@ -20,7 +20,7 @@
|
|||||||
// name text The class name used in class menu.
|
// name text The class name used in class menu.
|
||||||
// description text The class description used in class menu.
|
// description text The class description used in class menu.
|
||||||
// model_path text Path to model to use. Relative to cstrike folder.
|
// model_path text Path to model to use. Relative to cstrike folder.
|
||||||
// alpha_spawn number Initial transparency setting.
|
// alpha_initial number Initial transparency setting.
|
||||||
// alpha_damaged number Transparency when damaged.
|
// alpha_damaged number Transparency when damaged.
|
||||||
// alpha_damage number How much damage to do before switching alpha.
|
// alpha_damage number How much damage to do before switching alpha.
|
||||||
// overlay_path text Overlay displayed at the player.
|
// overlay_path text Overlay displayed at the player.
|
||||||
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
// Model
|
// Model
|
||||||
"model_path" "models/player/zh/zh_charple001.mdl"
|
"model_path" "models/player/zh/zh_charple001.mdl"
|
||||||
"alpha_spawn" "255"
|
"alpha_initial" "100"
|
||||||
"alpha_damaged" "255"
|
"alpha_damaged" "255"
|
||||||
"alpha_damage" "0"
|
"alpha_damage" "0"
|
||||||
|
|
||||||
@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
// Model
|
// Model
|
||||||
"model_path" "models/player/zh/zh_corpse002.mdl"
|
"model_path" "models/player/zh/zh_corpse002.mdl"
|
||||||
"alpha_spawn" "255"
|
"alpha_initial" "50"
|
||||||
"alpha_damaged" "255"
|
"alpha_damaged" "255"
|
||||||
"alpha_damage" "0"
|
"alpha_damage" "0"
|
||||||
|
|
||||||
@ -140,7 +140,7 @@
|
|||||||
|
|
||||||
// Model
|
// Model
|
||||||
"model_path" "models/player/zh/zh_zombie003.mdl"
|
"model_path" "models/player/zh/zh_zombie003.mdl"
|
||||||
"alpha_spawn" "255"
|
"alpha_initial" "150"
|
||||||
"alpha_damaged" "255"
|
"alpha_damaged" "255"
|
||||||
"alpha_damage" "0"
|
"alpha_damage" "0"
|
||||||
|
|
||||||
@ -181,7 +181,7 @@
|
|||||||
|
|
||||||
// Model
|
// Model
|
||||||
"model_path" "models/player/ics/hellknight_red/t_guerilla.mdl"
|
"model_path" "models/player/ics/hellknight_red/t_guerilla.mdl"
|
||||||
"alpha_spawn" "255"
|
"alpha_initial" "10"
|
||||||
"alpha_damaged" "255"
|
"alpha_damaged" "255"
|
||||||
"alpha_damage" "0"
|
"alpha_damage" "0"
|
||||||
|
|
||||||
@ -228,7 +228,7 @@
|
|||||||
|
|
||||||
// Model
|
// Model
|
||||||
"model_path" "default"
|
"model_path" "default"
|
||||||
"alpha_spawn" "255"
|
"alpha_initial" "200"
|
||||||
"alpha_damaged" "255"
|
"alpha_damaged" "255"
|
||||||
"alpha_damage" "0"
|
"alpha_damage" "0"
|
||||||
|
|
||||||
@ -269,7 +269,7 @@
|
|||||||
|
|
||||||
// Model
|
// Model
|
||||||
"model_path" "default"
|
"model_path" "default"
|
||||||
"alpha_spawn" "255"
|
"alpha_initial" "240"
|
||||||
"alpha_damaged" "255"
|
"alpha_damaged" "255"
|
||||||
"alpha_damage" "0"
|
"alpha_damage" "0"
|
||||||
|
|
||||||
@ -310,7 +310,7 @@
|
|||||||
|
|
||||||
// Model
|
// Model
|
||||||
"model_path" "default"
|
"model_path" "default"
|
||||||
"alpha_spawn" "255"
|
"alpha_initial" "100"
|
||||||
"alpha_damaged" "255"
|
"alpha_damaged" "255"
|
||||||
"alpha_damage" "0"
|
"alpha_damage" "0"
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ InfectClient(client, attacker = -1, bool:motherinfect = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Force client to drop weapon.
|
// Force client to drop weapon.
|
||||||
WeaponForceClientDrop(client, weapons[x]);
|
WeaponsForceClientDrop(client, weapons[x]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -323,7 +323,7 @@ new ClassPlayerNextAdminClass[MAXPLAYERS + 1];
|
|||||||
ClassLoad()
|
ClassLoad()
|
||||||
{
|
{
|
||||||
// Initialize log boolean.
|
// Initialize log boolean.
|
||||||
new bool:enablelog = LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS);
|
new bool:enablelog = LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_CLASSES);
|
||||||
|
|
||||||
// Make sure kvClassData is ready to use.
|
// Make sure kvClassData is ready to use.
|
||||||
if (kvClassData != INVALID_HANDLE)
|
if (kvClassData != INVALID_HANDLE)
|
||||||
|
@ -141,7 +141,7 @@ ToolsClientScore(client, bool:score = true, bool:apply = true, value = 0)
|
|||||||
* @param alpha The alpha value to set client's alpha to. (0-255)
|
* @param alpha The alpha value to set client's alpha to. (0-255)
|
||||||
* @param weapons Apply alpha to all client's weapons.
|
* @param weapons Apply alpha to all client's weapons.
|
||||||
*/
|
*/
|
||||||
ToolsSetClientAlpha(client, alpha, bool:bWeapons = true)
|
ToolsSetClientAlpha(client, alpha)
|
||||||
{
|
{
|
||||||
// Turn rendermode on, on the client.
|
// Turn rendermode on, on the client.
|
||||||
SetEntityRenderMode(client, RENDER_TRANSALPHA);
|
SetEntityRenderMode(client, RENDER_TRANSALPHA);
|
||||||
@ -149,12 +149,36 @@ ToolsSetClientAlpha(client, alpha, bool:bWeapons = true)
|
|||||||
// Set alpha value on the client.
|
// Set alpha value on the client.
|
||||||
SetEntityRenderColor(client, _, _, _, alpha);
|
SetEntityRenderColor(client, _, _, _, alpha);
|
||||||
|
|
||||||
// If bWeapons is false, then stop.
|
// Forward event to modules.
|
||||||
if (!bWeapons)
|
WeaponAlphaOnClientAlphaChanged(client, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an entity's color. (This is the "get" version of SetEntityRenderColor)
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @return The alpha value of the client. (0-255)
|
||||||
|
*/
|
||||||
|
ToolsGetEntityAlpha(entity)
|
||||||
|
{
|
||||||
|
static bool:gotconfig = false;
|
||||||
|
static String:prop[32];
|
||||||
|
|
||||||
|
if (!gotconfig)
|
||||||
{
|
{
|
||||||
return;
|
new Handle:gc = LoadGameConfigFile("core.games");
|
||||||
|
new bool:exists = GameConfGetKeyValue(gc, "m_clrRender", prop, sizeof(prop));
|
||||||
|
CloseHandle(gc);
|
||||||
|
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
strcopy(prop, sizeof(prop), "m_clrRender");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set client's weapons' alpha.
|
gotconfig = true;
|
||||||
WeaponSetWeaponAlpha(client, alpha);
|
}
|
||||||
|
|
||||||
|
new offset = GetEntSendPropOffs(entity, prop);
|
||||||
|
|
||||||
|
return GetEntData(entity, offset + 3, 1);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ RestrictWeaponUnrestrictAll()
|
|||||||
*/
|
*/
|
||||||
RestrictClientInit(client)
|
RestrictClientInit(client)
|
||||||
{
|
{
|
||||||
// Hook "canuse" on client.
|
// Hook "Weapon_CanUse" on client.
|
||||||
gCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
|
gCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ RestrictClientInit(client)
|
|||||||
*/
|
*/
|
||||||
RestrictOnClientDisconnect(client)
|
RestrictOnClientDisconnect(client)
|
||||||
{
|
{
|
||||||
// Unhook "canuse" on client.
|
// Unhook "Weapon_CanUse" on client.
|
||||||
ZRTools_UnhookWeapon_CanUse(gCanUseHookID[client]);
|
ZRTools_UnhookWeapon_CanUse(gCanUseHookID[client]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ WpnRestrictQuery:RestrictRestrict(const String:weapon[], String:display[] = "")
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get display name of the weapon.
|
// Get display name of the weapon.
|
||||||
WeaponGetDisplayName(weapon, display);
|
WeaponsGetDisplayName(weapon, display);
|
||||||
|
|
||||||
// Return restrict failed if weapon is already restricted.
|
// Return restrict failed if weapon is already restricted.
|
||||||
if (RestrictIsWeaponRestricted(weapon))
|
if (RestrictIsWeaponRestricted(weapon))
|
||||||
@ -432,7 +432,7 @@ WpnRestrictQuery:RestrictUnrestrict(const String:weapon[], String:display[] = ""
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get display name of the weapon.
|
// Get display name of the weapon.
|
||||||
WeaponGetDisplayName(weapon, display);
|
WeaponsGetDisplayName(weapon, display);
|
||||||
|
|
||||||
// Return unrestrict failed if weapon isn't restricted.
|
// Return unrestrict failed if weapon isn't restricted.
|
||||||
if (!RestrictIsWeaponRestricted(weapon))
|
if (!RestrictIsWeaponRestricted(weapon))
|
||||||
@ -897,6 +897,9 @@ public ZRTools_Action:RestrictCanUse(client, weapon)
|
|||||||
return ZRTools_Handled;
|
return ZRTools_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward event to modules. (item pickup)
|
||||||
|
WeaponAlphaOnItemPickup(client, weapon);
|
||||||
|
|
||||||
// Allow pickup.
|
// Allow pickup.
|
||||||
return ZRTools_Continue;
|
return ZRTools_Continue;
|
||||||
}
|
}
|
131
src/zr/weapons/weaponalpha.inc
Normal file
131
src/zr/weapons/weaponalpha.inc
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* ============================================================================
|
||||||
|
*
|
||||||
|
* Zombie:Reloaded
|
||||||
|
*
|
||||||
|
* File: weaponalpha.inc
|
||||||
|
* Type: Core
|
||||||
|
* Description: Weapon alpha functions, and alpha updating on drop/pickup.
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default alpha on any CS:S weapon.
|
||||||
|
*/
|
||||||
|
#define WEAPONALPHA_DEFAULT_VALUE 255
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array that stores the "HookID" to be later unhooked on player disconnect.
|
||||||
|
*/
|
||||||
|
new g_iWeaponDropHookID[MAXPLAYERS + 1];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client is joining the server.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
*/
|
||||||
|
WeaponAlphaClientInit(client)
|
||||||
|
{
|
||||||
|
// Hook "Weapon_Drop" on client.
|
||||||
|
g_iWeaponDropHookID[client] = ZRTools_HookWeapon_Drop(client, WeaponAlphaDrop);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unhook Weapon_CanUse function on a client.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
*/
|
||||||
|
WeaponAlphaOnClientDisconnect(client)
|
||||||
|
{
|
||||||
|
// Unhook "Weapon_Drop" on client.
|
||||||
|
ZRTools_UnhookWeapon_Drop(g_iWeaponDropHookID[client]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client has just picked up a weapon.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param weapon The weapon index.
|
||||||
|
*/
|
||||||
|
WeaponAlphaOnItemPickup(client, weapon)
|
||||||
|
{
|
||||||
|
// Get client's current alpha.
|
||||||
|
new alpha = ToolsGetEntityAlpha(client);
|
||||||
|
|
||||||
|
// Set new alpha on weapons.
|
||||||
|
WeaponAlphaApplyWeaponAlpha(weapon, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback function for Weapon_Drop.
|
||||||
|
* Called when a client drops their weapon.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
* @param weapon The weapon index.
|
||||||
|
*/
|
||||||
|
public ZRTools_Action:WeaponAlphaDrop(client, weapon)
|
||||||
|
{
|
||||||
|
// If weapon isn't a valid entity, then stop.
|
||||||
|
if (weapon < MaxClients)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set new alpha on weapons.
|
||||||
|
WeaponAlphaApplyWeaponAlpha(weapon, WEAPONALPHA_DEFAULT_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A client's alpha has been changed by the plugin.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
*/
|
||||||
|
WeaponAlphaOnClientAlphaChanged(client, alpha)
|
||||||
|
{
|
||||||
|
// Set new alpha on weapons.
|
||||||
|
WeaponAlphaApplyWeaponAlpha(client, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set's the alpha on a client's weapons.
|
||||||
|
*
|
||||||
|
* @param entity If client index is given, alpha will be set on all their weapons.
|
||||||
|
* If a non-client index is given, alpha will be set on given entity.
|
||||||
|
* @param alpha The alpha to set the weapons to.
|
||||||
|
*/
|
||||||
|
WeaponAlphaApplyWeaponAlpha(entity, alpha)
|
||||||
|
{
|
||||||
|
if (entity > MaxClients)
|
||||||
|
{
|
||||||
|
// Turn rendermode on, on the weapon.
|
||||||
|
SetEntityRenderMode(entity, RENDER_TRANSALPHA);
|
||||||
|
|
||||||
|
// Set alpha value on the weapon.
|
||||||
|
SetEntityRenderColor(entity, _, _, _, alpha);
|
||||||
|
|
||||||
|
// Entity alpha has been set, so stop.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get client's list of weapons.
|
||||||
|
new weapons[WeaponsType];
|
||||||
|
WeaponsGetClientWeapons(entity, weapons);
|
||||||
|
|
||||||
|
// Loop through array slots and set alpha.
|
||||||
|
// x = weapon slot.
|
||||||
|
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
||||||
|
{
|
||||||
|
// If weapon is invalid, then stop.
|
||||||
|
if (weapons[x] == -1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Turn rendermode on, on the weapon.
|
||||||
|
SetEntityRenderMode(weapons[x], RENDER_TRANSALPHA);
|
||||||
|
|
||||||
|
// Set alpha value on the weapon.
|
||||||
|
SetEntityRenderColor(weapons[x], _, _, _, alpha);
|
||||||
|
}
|
||||||
|
}
|
@ -43,6 +43,7 @@ enum WeaponsType
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "zr/weapons/restrict"
|
#include "zr/weapons/restrict"
|
||||||
|
#include "zr/weapons/weaponalpha"
|
||||||
#include "zr/weapons/markethandler"
|
#include "zr/weapons/markethandler"
|
||||||
#include "zr/weapons/menu_weapons"
|
#include "zr/weapons/menu_weapons"
|
||||||
|
|
||||||
@ -137,6 +138,7 @@ WeaponsClientInit(client)
|
|||||||
{
|
{
|
||||||
// Forward event to sub-module.
|
// Forward event to sub-module.
|
||||||
RestrictClientInit(client);
|
RestrictClientInit(client);
|
||||||
|
WeaponAlphaClientInit(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,6 +150,7 @@ WeaponsOnClientDisconnect(client)
|
|||||||
{
|
{
|
||||||
// Forward event to sub-module.
|
// Forward event to sub-module.
|
||||||
RestrictOnClientDisconnect(client);
|
RestrictOnClientDisconnect(client);
|
||||||
|
WeaponAlphaOnClientDisconnect(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,7 +222,7 @@ bool:WeaponsIsValidWeapon(const String:weapon[])
|
|||||||
* @param weapon The weapon name.
|
* @param weapon The weapon name.
|
||||||
* @param display Returns with the display name, is not changed if weapon is invalid.
|
* @param display Returns with the display name, is not changed if weapon is invalid.
|
||||||
*/
|
*/
|
||||||
WeaponGetDisplayName(const String:weapon[], String:display[])
|
WeaponsGetDisplayName(const String:weapon[], String:display[])
|
||||||
{
|
{
|
||||||
// Reset keyvalue's traversal stack.
|
// Reset keyvalue's traversal stack.
|
||||||
KvRewind(kvWeapons);
|
KvRewind(kvWeapons);
|
||||||
@ -373,38 +376,8 @@ WeaponsType:WeaponsGetDeployedWeaponSlot(client)
|
|||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @param weapon The weapon index to force client to drop.
|
* @param weapon The weapon index to force client to drop.
|
||||||
*/
|
*/
|
||||||
WeaponForceClientDrop(client, weapon)
|
WeaponsForceClientDrop(client, weapon)
|
||||||
{
|
{
|
||||||
// Force client to drop weapon.
|
// Force client to drop weapon.
|
||||||
SDKCall(g_hToolsCSWeaponDrop, client, weapon, true, false);
|
SDKCall(g_hToolsCSWeaponDrop, client, weapon, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set's the alpha on a client's weapons.
|
|
||||||
*
|
|
||||||
* @param client The client index.
|
|
||||||
* @param alpha The alpha to set the weapons to.
|
|
||||||
*/
|
|
||||||
WeaponSetWeaponAlpha(client, alpha)
|
|
||||||
{
|
|
||||||
// Get client's list of weapons.
|
|
||||||
new weapons[WeaponsType];
|
|
||||||
WeaponsGetClientWeapons(client, weapons);
|
|
||||||
|
|
||||||
// Loop through array slots and set alpha.
|
|
||||||
// x = weapon slot.
|
|
||||||
for (new x = 0; x < WEAPONS_SLOTS_MAX; x++)
|
|
||||||
{
|
|
||||||
// If weapon is invalid, then stop.
|
|
||||||
if (weapons[x] == -1)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turn rendermode on, on the weapon.
|
|
||||||
SetEntityRenderMode(weapons[x], RENDER_TRANSALPHA);
|
|
||||||
|
|
||||||
// Set alpha value on the weapon.
|
|
||||||
SetEntityRenderColor(weapons[x], _, _, _, alpha);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user