Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
partiusfabaa committed Dec 3, 2023
1 parent 8cb93e8 commit bb2db7f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
Binary file modified LiteVip/CounterStrikeSharp.API.dll
Binary file not shown.
41 changes: 25 additions & 16 deletions LiteVip/LiteVip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@

namespace LiteVip;

[MinimumApiVersion(87)]
[MinimumApiVersion(95)]
public class LiteVip : BasePlugin
{
public override string ModuleAuthor => "thesamefabius";
public override string ModuleName => "Lite VIP";
public override string ModuleVersion => "v1.0.7";

private static string _dbConnectionString = string.Empty;
private static readonly User?[] Users = new User[65];
private static readonly User?[] Users = new User[Server.MaxPlayers];
private static Config _config = null!;
private static readonly int?[] Jumps = new int?[65];
private static readonly int?[] Respawn = new int?[65];
private static readonly int?[] Jumps = new int?[Server.MaxPlayers];
private static readonly int?[] Respawn = new int?[Server.MaxPlayers];
private Timer?[] _timerGive = new Timer[Server.MaxPlayers];

//private short _offsetRender;
private static readonly UserSettings?[] UsersSettings = new UserSettings?[Server.MaxPlayers];
Expand Down Expand Up @@ -64,6 +65,7 @@ public override void Load(bool hotReload)
Jumps[slot + 1] = 0;
Respawn[slot + 1] = 0;
_timerGive[slot + 1] = null;
});

RegisterListener<Listeners.OnClientAuthorized>((slot, _) =>
Expand Down Expand Up @@ -91,6 +93,12 @@ public override void Load(bool hotReload)
UsersSettings[slot + 1] = null;
Jumps[slot + 1] = null;
Respawn[slot + 1] = null;
if(_timerGive[slot + 1] != null)
{
_timerGive[slot + 1]!.Kill();
_timerGive[slot + 1] = null;
}
});

CreateMenu();
Expand Down Expand Up @@ -465,14 +473,14 @@ private HookResult EventPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)

var controller = @event.Userid;

AddTimer(_config.Delay, () => Timer_Give(controller));
_timerGive[controller.Index] = AddTimer(_config.Delay, () => Timer_Give(controller));

return HookResult.Continue;
}

private void Timer_Give(CCSPlayerController controller)
{
if (controller.SteamID == 0 || !controller.IsValid) return;
if (!controller.IsValid || controller.SteamID == 0 || !controller.PlayerPawn.IsValid) return;

var group = GetUserVipGroup(controller);

Expand All @@ -483,22 +491,21 @@ private void Timer_Give(CCSPlayerController controller)
var playerPawnValue = controller.PlayerPawn.Value;
var moneyServices = controller.InGameMoneyServices;

if (playerPawnValue == null) return;

if (group.Health != null)
if (userSettings.IsHealth)
if (playerPawnValue != null)
playerPawnValue.Health = group.Health.Value;
playerPawnValue.Health = group.Health.Value;

if (group.Armor != null)
if (userSettings.IsArmor)
if (playerPawnValue != null)
playerPawnValue.ArmorValue = group.Armor.Value;
playerPawnValue.ArmorValue = group.Armor.Value;

if (group.Gravity != null)
if (userSettings.IsGravity)
if (playerPawnValue != null)
playerPawnValue.GravityScale = group.Gravity.Value;
playerPawnValue.GravityScale = group.Gravity.Value;

if (playerPawnValue != null && playerPawnValue.ItemServices != null)
if (playerPawnValue.ItemServices != null)
{
if (group.DecoySettings is { DecoyTeleport: true } && userSettings.IsDecoy &&
group.DecoySettings.DecoyCountToBeIssued > 0)
Expand Down Expand Up @@ -531,6 +538,9 @@ private void Timer_Give(CCSPlayerController controller)
}
}

if (controller is { TeamNum: (int)CsTeam.CounterTerrorist, PawnHasDefuser: false })
GiveItem(controller, "item_defuser");

if (group.Money != null)
if (group.Money.Value != -1)
if (moneyServices != null)
Expand All @@ -546,8 +556,7 @@ private void Timer_Give(CCSPlayerController controller)
userSettings.RainbowTimer = AddTimer(1.4f,
() =>
{
if (playerPawnValue != null)
Timer_SetRainbowModel(playerPawnValue, Random.Shared.Next(0, 255),
Timer_SetRainbowModel(playerPawnValue, Random.Shared.Next(0, 255),
Random.Shared.Next(0, 255), Random.Shared.Next(0, 255));
},
TimerFlags.REPEAT);
Expand All @@ -572,7 +581,7 @@ private bool HasItem(CCSPlayerController player, string item)
return false;
}

public VipGroup? GetUserVipGroup(CCSPlayerController player)
private VipGroup? GetUserVipGroup(CCSPlayerController player)
{
var user = Users[player.Index];

Expand Down

0 comments on commit bb2db7f

Please sign in to comment.