Integrated zrtools and removed hacks extension dependency (don't forget zrtools.inc), and I'll make a repos for the source code and binary. No linux binary yet. Gunna be a pain in the ass.
This commit is contained in:
@ -10,14 +10,6 @@
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @section Damage type flags.
|
||||
*/
|
||||
#define DMG_FALL (1 << 5) /** Client was damaged by falling. */
|
||||
#define DMG_BLAST (1 << 6) /** Client was damaged by explosion. */
|
||||
#define DMG_BULLET (1 << 12) /** Client was shot or knifed. */
|
||||
#define DMG_HEADSHOT (1 << 30) /** Client was shot in the head. */
|
||||
|
||||
/**
|
||||
* @endsection
|
||||
*/
|
||||
@ -74,8 +66,8 @@ DamageInit()
|
||||
DamageClientInit(client)
|
||||
{
|
||||
// Hook damage callbacks.
|
||||
g_iDamageHookID[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, DamageTraceAttack);
|
||||
g_iDamageHookID[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, DamageOnTakeDamage);
|
||||
g_iDamageHookID[client][Hook_TraceAttack] = ZRTools_HookTraceAttack(client, DamageTraceAttack);
|
||||
g_iDamageHookID[client][Hook_OnTakeDamage] = ZRTools_HookOnTakeDamage(client, DamageOnTakeDamage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,8 +78,8 @@ DamageClientInit(client)
|
||||
DamageOnClientDisconnect(client)
|
||||
{
|
||||
// Unhook damage callbacks.
|
||||
Hacks_Unhook(g_iDamageHookID[client][Hook_TraceAttack]);
|
||||
Hacks_Unhook(g_iDamageHookID[client][Hook_OnTakeDamage]);
|
||||
ZRTools_UnhookTraceAttack(g_iDamageHookID[client][Hook_TraceAttack]);
|
||||
ZRTools_UnhookOnTakeDamage(g_iDamageHookID[client][Hook_OnTakeDamage]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,29 +87,26 @@ DamageOnClientDisconnect(client)
|
||||
* Called right before the bullet enters a client.
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param inflictor Entity index of damage-causing entity.
|
||||
* @param attacker The client doing the damage.
|
||||
* @param damage The amount of damage that will be inflicted.
|
||||
* @param inflictor The entity index of the inflictor.
|
||||
* @param attacker The client index of the attacker.
|
||||
* @param damage The amount of damage inflicted.
|
||||
* @param hitbox The hitbox index.
|
||||
* @param hitgroup The hitgroup index.
|
||||
* @return Hacks_Continue allows shot to be made.
|
||||
* 0 stops the bullet from impacting.
|
||||
* @param hitgroup The hitgroup index.
|
||||
* @return Return ZRTools_Handled to stop bullet from hitting client.
|
||||
* ZRTools_Continue to allow bullet to hit client.
|
||||
*/
|
||||
public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
|
||||
public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damage, hitbox, hitgroup)
|
||||
{
|
||||
// Disabled
|
||||
// new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]);
|
||||
|
||||
// If attacker isn't valid, then stop.
|
||||
if (!ZRIsClientValid(attacker))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// If client is attacking himself, then stop.
|
||||
if(attacker == client)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// Get zombie flag for each client.
|
||||
@ -131,11 +120,11 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
|
||||
new bool:damageblockff = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_FF]);
|
||||
if (!damageblockff)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// Stop bullet from hurting client.
|
||||
return 0;
|
||||
return ZRTools_Handled;
|
||||
}
|
||||
|
||||
// Here we know that attacker and client are different teams.
|
||||
@ -145,7 +134,7 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
|
||||
if (!damagehitgroups)
|
||||
{
|
||||
// Allow damage.
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// If damage is disabled for this hitgroup, then stop.
|
||||
@ -153,36 +142,28 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
|
||||
if (!candamage)
|
||||
{
|
||||
// Stop bullet from hurting client.
|
||||
return 0;
|
||||
return ZRTools_Handled;
|
||||
}
|
||||
|
||||
// Allow damage.
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook: OnTakeDamage
|
||||
* Called right before damage is done.
|
||||
*
|
||||
*
|
||||
* @param client The client index.
|
||||
* @param inflictor Entity index of damage-causing entity.
|
||||
* @param attacker The client doing the damage.
|
||||
* @param damage The amount of damage that will be inflicted.
|
||||
* @param damagetype The type of damage done (see damage flag defines)
|
||||
* @param ammotype Type of ammo attacker shot at client.
|
||||
* @return Hacks_Continue allows shot to be made.
|
||||
* 0 stops the bullet from doing damage.
|
||||
* @param inflictor The entity index of the inflictor.
|
||||
* @param attacker The client index of the attacker.
|
||||
* @param damage The amount of damage inflicted.
|
||||
* @param damagetype The type of damage inflicted.
|
||||
* @param ammotype The ammo type of the attacker's weapon.
|
||||
* @return Return ZRTools_Handled to stop the damage to client.
|
||||
* ZRTools_Continue to allow damage to client.
|
||||
*/
|
||||
public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammotype)
|
||||
public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:damage, damagetype, ammotype)
|
||||
{
|
||||
// Disabled.
|
||||
/**
|
||||
new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]);
|
||||
if (!enabled)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
}*/
|
||||
|
||||
// Get classname of the inflictor.
|
||||
decl String:classname[64];
|
||||
GetEdictClassname(inflictor, classname, sizeof(classname));
|
||||
@ -190,16 +171,16 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
|
||||
// If entity is a trigger, then allow damage. (Map is damaging client)
|
||||
if (StrContains(classname, "trigger") > -1)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// Client was shot or knifed.
|
||||
if (damagetype & DMG_BULLET)
|
||||
if (damagetype & DMG_CSS_BULLET)
|
||||
{
|
||||
// If attacker isn't valid, then allow damage.
|
||||
if (!ZRIsClientValid(attacker))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// Get zombie flag for each client.
|
||||
@ -209,7 +190,7 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
|
||||
// If client and attacker are on the same team, then let CS:S handle the rest.
|
||||
if (clientzombie == attackerzombie)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// We know that clientzombie is the opposite of attacker zombie.
|
||||
@ -217,63 +198,63 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
|
||||
// If the client is a zombie, then allow damage.
|
||||
if (clientzombie)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// Client is about to be infected, re-add HP so they aren't killed by knife.
|
||||
new health = GetClientHealth(client);
|
||||
SetEntityHealth(client, health + damage);
|
||||
SetEntityHealth(client, health + RoundToNearest(damage));
|
||||
|
||||
// Allow damage.
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
// Client was damaged by explosion.
|
||||
else if (damagetype & DMG_BLAST)
|
||||
else if (damagetype & DMG_CSS_BLAST)
|
||||
{
|
||||
// If blast damage is blocked, then stop.
|
||||
new bool:damageblockblast = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST]);
|
||||
if (!damageblockblast)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// If attacker isn't valid, then allow damage.
|
||||
if (!ZRIsClientValid(attacker))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// If client is a zombie, then allow damage.
|
||||
if (InfectIsClientInfected(client))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// Stop damage.
|
||||
return 0;
|
||||
return ZRTools_Handled;
|
||||
}
|
||||
// Client was damaged by falling.
|
||||
else if (damagetype & DMG_FALL)
|
||||
else if (damagetype & DMG_CSS_FALL)
|
||||
{
|
||||
// If client isn't a zombie, then allow damage.
|
||||
if (!InfectIsClientInfected(client))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// If class has "nofalldamage" disabled, then allow damage.
|
||||
new bool:blockfalldamage = ClassGetNoFallDamage(client);
|
||||
if (!blockfalldamage)
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// Stop damage.
|
||||
return 0;
|
||||
return ZRTools_Handled;
|
||||
}
|
||||
|
||||
// Allow damage.
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,7 +209,7 @@ RestrictWeaponUnrestrictAll()
|
||||
RestrictClientInit(client)
|
||||
{
|
||||
// Hook "canuse" on client.
|
||||
gCanUseHookID[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, RestrictCanUse, false);
|
||||
gCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,7 +220,7 @@ RestrictClientInit(client)
|
||||
RestrictOnClientDisconnect(client)
|
||||
{
|
||||
// Unhook "canuse" on client.
|
||||
Hacks_Unhook(gCanUseHookID[client]);
|
||||
ZRTools_UnhookWeapon_CanUse(gCanUseHookID[client]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,8 +231,8 @@ RestrictOnClientDisconnect(client)
|
||||
RestrictOnClientSpawn(client)
|
||||
{
|
||||
// Re-hook "canuse" on client.
|
||||
Hacks_Unhook(gCanUseHookID[client]);
|
||||
gCanUseHookID[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, RestrictCanUse, false);
|
||||
ZRTools_UnhookWeapon_CanUse(gCanUseHookID[client]);
|
||||
gCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -868,9 +868,10 @@ RestrictGetGroupWeapons(const String:groupname[], String:weaponlist[], maxlen, c
|
||||
* Hook callback, called when a player is trying to pick up a weapon.
|
||||
* @param client The client index.
|
||||
* @param weapon The weapon index.
|
||||
* @return 0 to block weapon pickup, Hacks_Continue to allow.
|
||||
* @return Return ZRTools_Handled to stop weapon pickup.
|
||||
* ZRTools_Continue to allow weapon pickup.
|
||||
*/
|
||||
public RestrictCanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
|
||||
public ZRTools_Action:RestrictCanUse(client, weapon)
|
||||
{
|
||||
new String:weaponname[WEAPONS_MAX_LENGTH];
|
||||
GetEdictClassname(weapon, weaponname, sizeof(weaponname));
|
||||
@ -881,21 +882,21 @@ public RestrictCanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
|
||||
// If weapon is a knife, then allow pickup.
|
||||
if (StrEqual(weaponname, "knife"))
|
||||
{
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
||||
// If the weapon is restricted, then prevent pickup.
|
||||
if (RestrictIsWeaponRestricted(weaponname))
|
||||
{
|
||||
return 0;
|
||||
return ZRTools_Handled;
|
||||
}
|
||||
|
||||
// If the player is a zombie, then prevent pickup.
|
||||
if (InfectIsClientInfected(client))
|
||||
{
|
||||
return 0;
|
||||
return ZRTools_Handled;
|
||||
}
|
||||
|
||||
// Allow pickup.
|
||||
return Hacks_Continue;
|
||||
return ZRTools_Continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user