Skip to content

Commit

Permalink
refactor: rename internal convar
Browse files Browse the repository at this point in the history
  • Loading branch information
rick-yao committed Dec 26, 2024
1 parent 5ef85ff commit 562e627
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions l4d2_tank_draw/scripting/lib/lib.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
ConVar
g_hInfiniteAmmo,
g_hInfinitePrimaryAmmo,
g_MeleeRange,
g_WorldGravity;
g_hMeleeRange,
g_hWorldGravity;

// Custom ConVars for the plugin
ConVar
Expand Down Expand Up @@ -100,11 +100,11 @@ stock void ResetAllValue()
g_hInfinitePrimaryAmmo = FindConVar("sv_infinite_primary_ammo");
g_hInfinitePrimaryAmmo.RestoreDefault();

g_MeleeRange = FindConVar("melee_range");
g_MeleeRange.RestoreDefault();
g_hMeleeRange = FindConVar("melee_range");
g_hMeleeRange.RestoreDefault();

g_WorldGravity = FindConVar("sv_gravity");
g_WorldGravity.RestoreDefault();
g_hWorldGravity = FindConVar("sv_gravity");
g_hWorldGravity.RestoreDefault();

g_GlowDisabled = 0;
}
Expand All @@ -127,9 +127,9 @@ stock Action ResetSingleGravity(Handle timer, int client)

stock Action ResetWorldGravity(Handle timer, int initValue)
{
g_WorldGravity = FindConVar("sv_gravity");
g_hWorldGravity = FindConVar("sv_gravity");

g_WorldGravity.RestoreDefault();
g_hWorldGravity.RestoreDefault();

CPrintToChatAll("%t", "TankDraw_WorldGravityReset");
PrintHintTextToAll("%t", "TankDraw_WorldGravityReset_NoColor");
Expand Down
28 changes: 14 additions & 14 deletions l4d2_tank_draw/scripting/lib/lucky_draw.sp
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ stock Action LuckyDraw(int victim, int attacker)
currentChance += chanceLimitedTimeWorldMoonGravity;
if (random <= currentChance)
{
g_WorldGravity = FindConVar("sv_gravity");
g_hWorldGravity = FindConVar("sv_gravity");
char default_gravity[16];
g_WorldGravity.GetDefault(default_gravity, sizeof(default_gravity));
int default_gravity_int = StringToInt(default_gravity);
g_hWorldGravity.GetDefault(default_gravity, sizeof(default_gravity));
int default_gravity_int = StringToInt(default_gravity);

g_WorldGravity.IntValue = WorldMoonGravity.IntValue;
g_hWorldGravity.IntValue = WorldMoonGravity.IntValue;

if (g_WorldGravityTimer != null)
{
Expand Down Expand Up @@ -305,19 +305,19 @@ stock Action LuckyDraw(int victim, int attacker)
currentChance += chanceWorldMoonGravityToggle;
if (random <= currentChance)
{
g_WorldGravity = FindConVar("sv_gravity");
g_hWorldGravity = FindConVar("sv_gravity");
char default_gravity[16];
g_WorldGravity.GetDefault(default_gravity, sizeof(default_gravity));
g_hWorldGravity.GetDefault(default_gravity, sizeof(default_gravity));
int default_gravity_int = StringToInt(default_gravity);

if (g_WorldGravity.IntValue == default_gravity_int)
if (g_hWorldGravity.IntValue == default_gravity_int)
{
g_WorldGravity.IntValue = WorldMoonGravity.IntValue;
g_hWorldGravity.IntValue = WorldMoonGravity.IntValue;
CPrintToChatAll("%t", "TankDrawResult_EnableMoonGravity", attackerName);
PrintHintTextToAll("%t", "TankDrawResult_EnableMoonGravity_NoColor", attackerName);
}
else {
g_WorldGravity.RestoreDefault();
g_hWorldGravity.RestoreDefault();
// before timer ends, if draw this prize, should clear timer
if (g_WorldGravityTimer != null)
{
Expand Down Expand Up @@ -409,19 +409,19 @@ stock Action LuckyDraw(int victim, int attacker)
if (random <= currentChance)
{
// Infinite melee range
g_MeleeRange = FindConVar("melee_range");
g_hMeleeRange = FindConVar("melee_range");
char default_range[16];
g_MeleeRange.GetDefault(default_range, sizeof(default_range));
g_hMeleeRange.GetDefault(default_range, sizeof(default_range));
int default_range_int = StringToInt(default_range);

if (g_MeleeRange.IntValue == default_range_int)
if (g_hMeleeRange.IntValue == default_range_int)
{
g_MeleeRange.IntValue = GetConVarInt(InfiniteMeeleRange);
g_hMeleeRange.IntValue = GetConVarInt(InfiniteMeeleRange);
CPrintToChatAll("%t", "TankDrawResult_EnableInfiniteMelee", attackerName);
PrintHintTextToAll("%t", "TankDrawResult_EnableInfiniteMelee_NoColor", attackerName);
}
else {
g_MeleeRange.RestoreDefault();
g_hMeleeRange.RestoreDefault();
CPrintToChatAll("%t", "TankDrawResult_DisableInfiniteMelee", attackerName);
PrintHintTextToAll("%t", "TankDrawResult_DisableInfiniteMelee_NoColor", attackerName);
}
Expand Down

0 comments on commit 562e627

Please sign in to comment.