Fix rebuy exploit by keeping current clip.

Add zr_infect_knife_cooldown
Convert includes to new syntax.
This commit is contained in:
2017-07-05 23:00:50 +02:00
parent b09747346f
commit 6478d995b9
8 changed files with 48 additions and 25 deletions

View File

@ -103,13 +103,14 @@ enum CvarsList
Handle:CVAR_INFECT_SPAWNTIME_MAX,
Handle:CVAR_INFECT_CONSECUTIVE_BLOCK,
Handle:CVAR_INFECT_WEAPONS_DROP,
Handle:CVAR_INFECT_KNIFE_COOLDOWN,
Handle:CVAR_INFECT_MAX_DISTANCE,
Handle:CVAR_INFECT_MZOMBIE_MODE,
Handle:CVAR_INFECT_MZOMBIE_RATIO,
Handle:CVAR_INFECT_MZOMBIE_MIN,
Handle:CVAR_INFECT_MZOMBIE_MAX,
Handle:CVAR_INFECT_MZOMBIE_COUNTDOWN,
Handle:CVAR_INFECT_MZOMBIE_RESPAWN,
Handle:CVAR_INFECT_MAX_DISTANCE,
Handle:CVAR_INFECT_EXPLOSION,
Handle:CVAR_INFECT_FIREBALL,
Handle:CVAR_INFECT_SMOKE,
@ -328,6 +329,7 @@ CvarsCreate()
g_hCvarsList[CVAR_INFECT_SPAWNTIME_MAX] = CreateConVar("zr_infect_spawntime_max", "50.0", "Maximum time from the start of the round until picking the mother zombie(s).");
g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK] = CreateConVar("zr_infect_consecutive_block", "1", "Prevent a player from being chosen as mother zombie two rounds in a row.");
g_hCvarsList[CVAR_INFECT_WEAPONS_DROP] = CreateConVar("zr_infect_weapons_drop", "1", "Force player to drop all weapons on infect, disabling this will strip weapons instead.");
g_hCvarsList[CVAR_INFECT_KNIFE_COOLDOWN] = CreateConVar("zr_infect_knife_cooldown", "1.0", "Time in seconds during which knife can not be used after becoming a zombie.");
g_hCvarsList[CVAR_INFECT_MAX_DISTANCE] = CreateConVar("zr_infect_max_distance", "80.0", "The maximum allowed distance between a client and an attacker for a successful infection. [0.0 = Disabled]");
// Effects

View File

@ -769,6 +769,10 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
// Remove all weapons but knife.
WeaponsRemoveAllClientWeapons(client, weaponsdrop);
// Zombie won't be able to use their knife for this amount of time
new Float:knifecooldown = GetConVarFloat(g_hCvarsList[CVAR_INFECT_KNIFE_COOLDOWN]);
SetEntPropFloat(client, Prop_Send, "m_flNextAttack", GetGameTime() + knifecooldown);
// Switch the player to terrorists.
// TODO: A solution to stop confusing bots? Respawn and teleport?
CS_SwitchTeam(client, CS_TEAM_T);

View File

@ -286,7 +286,8 @@ bool:ClassApplyNightVision(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER
}
ToolsSetClientNightVision(client, nvgs);
ToolsSetClientNightVision(client, nvgs, false);
if (!nvgs)
ToolsSetClientNightVision(client, nvgs, false);
return true;
}

View File

@ -1018,12 +1018,14 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
// Check if client is buying the weapon or ammo for it.
if (!hasweapon || slot == Slot_Projectile || slot == Slot_NVGs)
{
int oldclip = -1;
// If the item is a projectile or NVGs, then skip.
if (slot != Slot_Projectile && slot != Slot_NVGs)
{
// If there is already a weapon in the slot, then force client to drop it.
if (weapons[slot] > -1)
{
oldclip = GetEntProp(weapons[slot], Prop_Send, "m_iClip1");
if(rebuy)
{
// Kill weapon right away to decrease amount of entities on roundstart.
@ -1037,6 +1039,7 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
}
}
int entity = INVALID_ENT_REFERENCE;
if (StrEqual(weaponentity, "item_kevlar"))
{
SetEntProp(client, Prop_Send, "m_ArmorValue", 100);
@ -1045,7 +1048,7 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
else
{
// Give client the weapon.
GivePlayerItem(client, weaponentity);
entity = GivePlayerItem(client, weaponentity);
}
if (!rebuy)
@ -1055,6 +1058,19 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false)
// If client isn't rebuying the weapon, then tell them the weapon has been purchased.
TranslationPrintToChat(client, "Weapons zmarket purchase", weapondisplay);
if (IsValidEntity(entity) && !WeaponsIsClientInBuyZone(client))
{
int newclip = 0;
if (oldclip != -1)
{
newclip = GetEntProp(entity, Prop_Send, "m_iClip1");
if(newclip > oldclip)
newclip = oldclip;
}
SetEntProp(entity, Prop_Send, "m_iClip1", newclip);
}
}
}
else if (!rebuy)