Added cvar to control suicide blocking for zombies and humans seperately
This commit is contained in:
parent
2a24a8a204
commit
7817981473
@ -51,7 +51,8 @@ enum ZRSettings
|
|||||||
Handle:CVAR_RESPAWN,
|
Handle:CVAR_RESPAWN,
|
||||||
Handle:CVAR_RESPAWN_TEAM,
|
Handle:CVAR_RESPAWN_TEAM,
|
||||||
Handle:CVAR_RESPAWN_DELAY,
|
Handle:CVAR_RESPAWN_DELAY,
|
||||||
Handle:CVAR_SUICIDE,
|
Handle:CVAR_SUICIDE_ZOMBIE,
|
||||||
|
Handle:CVAR_SUICIDE_HUMAN,
|
||||||
Handle:CVAR_SUICIDE_ECHO,
|
Handle:CVAR_SUICIDE_ECHO,
|
||||||
Handle:CVAR_SUICIDE_WORLD_DAMAGE,
|
Handle:CVAR_SUICIDE_WORLD_DAMAGE,
|
||||||
Handle:CVAR_SPAWN_MIN,
|
Handle:CVAR_SPAWN_MIN,
|
||||||
@ -137,7 +138,8 @@ CreateCvars()
|
|||||||
gCvars[CVAR_RESPAWN] = CreateConVar("zr_respawn", "0", "When player is killed, player will respawn");
|
gCvars[CVAR_RESPAWN] = CreateConVar("zr_respawn", "0", "When player is killed, player will respawn");
|
||||||
gCvars[CVAR_RESPAWN_TEAM] = CreateConVar("zr_respawn_team", "zombie", "Which team to respawn player as (Choices: zombie, human)");
|
gCvars[CVAR_RESPAWN_TEAM] = CreateConVar("zr_respawn_team", "zombie", "Which team to respawn player as (Choices: zombie, human)");
|
||||||
gCvars[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "How long to wait after death to respawn, in seconds");
|
gCvars[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "How long to wait after death to respawn, in seconds");
|
||||||
gCvars[CVAR_SUICIDE] = CreateConVar("zr_suicide", "1", "Stops players from suiciding");
|
gCvars[CVAR_SUICIDE_ZOMBIE] = CreateConVar("zr_suicide_zombie", "1", "Stops zombies from suiciding");
|
||||||
|
gCvars[CVAR_SUICIDE_HUMAN] = CreateConVar("zr_suicide_human", "1", "Stops humans from suiciding");
|
||||||
gCvars[CVAR_SUICIDE_ECHO] = CreateConVar("zr_suicide_echo", "0", "Log suicide attempts to admin chat.");
|
gCvars[CVAR_SUICIDE_ECHO] = CreateConVar("zr_suicide_echo", "0", "Log suicide attempts to admin chat.");
|
||||||
gCvars[CVAR_SUICIDE_WORLD_DAMAGE] = CreateConVar("zr_suicide_world_damage", "1", "Respawn zombies as zombies if they were killed by the world, like elevators, doors and lasers. (0: Disable)");
|
gCvars[CVAR_SUICIDE_WORLD_DAMAGE] = CreateConVar("zr_suicide_world_damage", "1", "Respawn zombies as zombies if they were killed by the world, like elevators, doors and lasers. (0: Disable)");
|
||||||
gCvars[CVAR_SPAWN_MIN] = CreateConVar("zr_spawn_min", "30", "Minimum time a player is picked to be zombie after the round starts, in seconds");
|
gCvars[CVAR_SPAWN_MIN] = CreateConVar("zr_spawn_min", "30", "Minimum time a player is picked to be zombie after the round starts, in seconds");
|
||||||
|
@ -1,196 +1,188 @@
|
|||||||
/**
|
/**
|
||||||
* ====================
|
* ====================
|
||||||
* Zombie:Reloaded
|
* Zombie:Reloaded
|
||||||
* File: damagecontrol.inc
|
* File: damagecontrol.inc
|
||||||
* Author: Greyscale
|
* Author: Greyscale
|
||||||
* ====================
|
* ====================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DMG_GENERIC 0 // generic damage was done
|
#define DMG_GENERIC 0 // generic damage was done
|
||||||
#define DMG_BULLET (1 << 1) // shot
|
#define DMG_BULLET (1 << 1) // shot
|
||||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
||||||
#define DMG_BURN (1 << 3) // heat burned
|
#define DMG_BURN (1 << 3) // heat burned
|
||||||
#define DMG_FALL (1 << 5) // fell too far
|
#define DMG_FALL (1 << 5) // fell too far
|
||||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
#define DMG_BLAST (1 << 6) // explosive blast damage
|
||||||
#define DMG_DROWN (1 << 14) // Drowning
|
#define DMG_DROWN (1 << 14) // Drowning
|
||||||
|
|
||||||
enum ZRHooks
|
enum ZRHooks
|
||||||
{
|
{
|
||||||
Hook_TraceAttack,
|
Hook_TraceAttack,
|
||||||
Hook_OnTakeDamage
|
Hook_OnTakeDamage
|
||||||
}
|
}
|
||||||
|
|
||||||
new gHooks[MAXPLAYERS+1][ZRHooks];
|
new gHooks[MAXPLAYERS+1][ZRHooks];
|
||||||
|
|
||||||
InitDmgControl()
|
InitDmgControl()
|
||||||
{
|
{
|
||||||
/* It's case sensitive! */
|
/* It's case sensitive! */
|
||||||
RegConsoleCmd("kill", Attempt_Suicide);
|
RegConsoleCmd("kill", Attempt_Suicide);
|
||||||
RegConsoleCmd("KILL", Attempt_Suicide);
|
RegConsoleCmd("KILL", Attempt_Suicide);
|
||||||
RegConsoleCmd("jointeam", Attempt_Suicide);
|
RegConsoleCmd("jointeam", Attempt_Suicide);
|
||||||
RegConsoleCmd("JOINTEAM", Attempt_Suicide);
|
RegConsoleCmd("JOINTEAM", Attempt_Suicide);
|
||||||
RegConsoleCmd("spectate", Attempt_Suicide);
|
RegConsoleCmd("spectate", Attempt_Suicide);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientHookAttack(client)
|
ClientHookAttack(client)
|
||||||
{
|
{
|
||||||
gHooks[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, TraceAttack, false);
|
gHooks[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, TraceAttack, false);
|
||||||
gHooks[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, OnTakeDamage, false);
|
gHooks[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, OnTakeDamage, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientUnHookAttack(client)
|
ClientUnHookAttack(client)
|
||||||
{
|
{
|
||||||
Hacks_Unhook(gHooks[client][Hook_TraceAttack]);
|
Hacks_Unhook(gHooks[client][Hook_TraceAttack]);
|
||||||
Hacks_Unhook(gHooks[client][Hook_OnTakeDamage]);
|
Hacks_Unhook(gHooks[client][Hook_OnTakeDamage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
|
public TraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
|
||||||
{
|
{
|
||||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||||
|
|
||||||
if (!attacker || !IsClientPlayer(attacker) || !IsClientInGame(attacker) || !enabled)
|
if (!attacker || !IsClientPlayer(attacker) || !IsClientInGame(attacker) || !enabled)
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsPlayerZombie(client) && IsPlayerZombie(attacker))
|
if (IsPlayerZombie(client) && IsPlayerZombie(attacker))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsPlayerHuman(client) && IsPlayerHuman(attacker))
|
if (IsPlayerHuman(client) && IsPlayerHuman(attacker))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnTakeDamage(client, inflictor, attacker, damage, damagetype, ammotype)
|
public OnTakeDamage(client, inflictor, attacker, damage, damagetype, ammotype)
|
||||||
{
|
{
|
||||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
decl String:classname[64];
|
decl String:classname[64];
|
||||||
GetEdictClassname(inflictor, classname, sizeof(classname));
|
GetEdictClassname(inflictor, classname, sizeof(classname));
|
||||||
if (StrContains(classname, "trigger") > -1)
|
if (StrContains(classname, "trigger") > -1)
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damagetype & DMG_FALL)
|
if (damagetype & DMG_FALL)
|
||||||
{
|
{
|
||||||
if (!IsPlayerZombie(client))
|
if (!IsPlayerZombie(client))
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
new bool:blockfalldamage = GetClassNoFallDamage(pClass[client]);
|
new bool:blockfalldamage = GetClassNoFallDamage(pClass[client]);
|
||||||
if (!blockfalldamage)
|
if (!blockfalldamage)
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damagetype & DMG_BLAST)
|
if (damagetype & DMG_BLAST)
|
||||||
{
|
{
|
||||||
if (!IsPlayerHuman(client) || !IsClientPlayer(attacker) || !IsClientInGame(attacker))
|
if (!IsPlayerHuman(client) || !IsClientPlayer(attacker) || !IsClientInGame(attacker))
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damagetype & DMG_BULLET)
|
if (damagetype & DMG_BULLET)
|
||||||
{
|
{
|
||||||
if (!client || !IsClientPlayer(client) || !IsClientInGame(client))
|
if (!client || !IsClientPlayer(client) || !IsClientInGame(client))
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!attacker || !IsClientPlayer(attacker) || !IsClientInGame(attacker))
|
if (!attacker || !IsClientPlayer(attacker) || !IsClientInGame(attacker))
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsPlayerZombie(client) && IsPlayerHuman(attacker))
|
if (IsPlayerZombie(client) && IsPlayerHuman(attacker))
|
||||||
{
|
{
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsPlayerHuman(client) && IsPlayerZombie(attacker))
|
if (IsPlayerHuman(client) && IsPlayerZombie(attacker))
|
||||||
{
|
{
|
||||||
new health = GetClientHealth(client);
|
new health = GetClientHealth(client);
|
||||||
SetEntityHealth(client, health + damage);
|
SetEntityHealth(client, health + damage);
|
||||||
|
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Hacks_Continue;
|
return Hacks_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action:Attempt_Suicide(client, argc)
|
public Action:Attempt_Suicide(client, argc)
|
||||||
{
|
{
|
||||||
if (!client)
|
if (!client)
|
||||||
{
|
{
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
new bool:suicide = GetConVarBool(gCvars[CVAR_SUICIDE]);
|
|
||||||
if (!suicide)
|
|
||||||
{
|
new bool:suicide = IsPlayerZombie(client) ? GetConVarBool(gCvars[CVAR_SUICIDE_ZOMBIE]) : GetConVarBool(gCvars[CVAR_SUICIDE_HUMAN]);
|
||||||
return Plugin_Continue;
|
if (!suicide)
|
||||||
}
|
{
|
||||||
|
return Plugin_Continue;
|
||||||
decl String:cmd[16];
|
}
|
||||||
GetCmdArg(0, cmd, sizeof(cmd));
|
|
||||||
|
decl String:cmd[16];
|
||||||
if (!IsPlayerZombie(client) && StrEqual(cmd, "spectate", false))
|
GetCmdArg(0, cmd, sizeof(cmd));
|
||||||
{
|
|
||||||
return Plugin_Continue;
|
if (!IsPlayerAlive(client))
|
||||||
}
|
{
|
||||||
|
return Plugin_Continue;
|
||||||
if (!IsPlayerZombie(client) && !GetConVarBool(gCvars[CVAR_RESPAWN]))
|
}
|
||||||
{
|
|
||||||
return Plugin_Continue;
|
ZR_ReplyToCommand(client, "Suicide text");
|
||||||
}
|
ZR_PrintToChat(client, "Suicide text");
|
||||||
|
|
||||||
if (!IsPlayerAlive(client))
|
decl String:clientname[64];
|
||||||
{
|
decl String:buffer[192];
|
||||||
return Plugin_Continue;
|
|
||||||
}
|
GetClientName(client, clientname, sizeof(clientname));
|
||||||
|
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_DAMAGECONTROL))
|
||||||
ZR_ReplyToCommand(client, "Suicide text");
|
{
|
||||||
ZR_PrintToChat(client, "Suicide text");
|
ZR_LogMessageFormatted(client, "damage control", "suicide", "Player \"%s\" attempted suicide.", true, clientname);
|
||||||
|
}
|
||||||
decl String:clientname[64];
|
if (GetConVarBool(gCvars[CVAR_SUICIDE_ECHO]))
|
||||||
decl String:buffer[192];
|
{
|
||||||
|
Format(buffer, sizeof(buffer), "Player '%s' attempted suicide.", clientname);
|
||||||
GetClientName(client, clientname, sizeof(clientname));
|
ZR_PrintToAdminChat(buffer);
|
||||||
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_DAMAGECONTROL))
|
}
|
||||||
{
|
|
||||||
ZR_LogMessageFormatted(client, "damage control", "suicide", "Player \"%s\" attempted suicide.", true, clientname);
|
return Plugin_Handled;
|
||||||
}
|
|
||||||
if (GetConVarBool(gCvars[CVAR_SUICIDE_ECHO]))
|
|
||||||
{
|
|
||||||
Format(buffer, sizeof(buffer), "Player '%s' attempted suicide.", clientname);
|
|
||||||
ZR_PrintToAdminChat(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user