Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions VIPCore/modules/VIP_AntiFlash/VIP_AntiFlash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ public class VipAntiFlash : BasePlugin
{
public override string ModuleAuthor => "thesamefabius";
public override string ModuleName => "[VIP] Anti Flash";
public override string ModuleVersion => "v1.0.2";
public override string ModuleVersion => "v1.0.3";

private IVipCoreApi? _api;
private AntiFlash _antiFlash;

private AntiFlash? _antiFlash;
private PluginCapability<IVipCoreApi> PluginCapability { get; } = new("vipcore:core");

public override void OnAllPluginsLoaded(bool hotReload)
Expand All @@ -30,7 +29,10 @@ public override void OnAllPluginsLoaded(bool hotReload)

public override void Unload(bool hotReload)
{
_api?.UnRegisterFeature(_antiFlash);
if (_antiFlash != null)
{
_api?.UnRegisterFeature(_antiFlash);
}
}
}

Expand All @@ -43,17 +45,18 @@ public AntiFlash(VipAntiFlash vipAntiFlash, IVipCoreApi api) : base(api)
vipAntiFlash.RegisterEventHandler<EventPlayerBlind>((@event, info) =>
{
var player = @event.Userid;

if (player == null || !player.IsValid) return HookResult.Continue;

if (!IsClientVip(player) || !PlayerHasFeature(player) || GetPlayerFeatureState(player) is not FeatureState.Enabled) return HookResult.Continue;

var featureValue = GetFeatureValue<int>(player);
var attacker = @event.Attacker;

var playerPawn = player.PlayerPawn.Value;

if (playerPawn == null || playerPawn.LifeState is not (byte)LifeState_t.LIFE_ALIVE) return HookResult.Continue;

var sameTeam = attacker.Team == player.Team;
var sameTeam = attacker != null && attacker.Team == player.Team;

switch (featureValue)
{
case 1:
Expand Down
2 changes: 1 addition & 1 deletion VIPCore/modules/VIP_AntiFlash/VIP_AntiFlash.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.342" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.361" />
</ItemGroup>
<ItemGroup>
<Reference Include="VipCoreApi">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
".NETCoreApp,Version=v8.0": {
"VIP_AntiFlash/1.0.0": {
"dependencies": {
"CounterStrikeSharp.API": "1.0.342",
"CounterStrikeSharp.API": "1.0.361",
"VipCoreApi": "1.0.0.0"
},
"runtime": {
"VIP_AntiFlash.dll": {}
}
},
"CounterStrikeSharp.API/1.0.342": {
"CounterStrikeSharp.API/1.0.361": {
"dependencies": {
"McMaster.NETCore.Plugins": "1.4.0",
"Microsoft.CSharp": "4.7.0",
Expand All @@ -33,8 +33,8 @@
},
"runtime": {
"lib/net8.0/CounterStrikeSharp.API.dll": {
"assemblyVersion": "1.0.342.0",
"fileVersion": "1.0.342.0"
"assemblyVersion": "1.0.361.0",
"fileVersion": "1.0.361.0"
}
}
},
Expand Down Expand Up @@ -557,12 +557,12 @@
"serviceable": false,
"sha512": ""
},
"CounterStrikeSharp.API/1.0.342": {
"CounterStrikeSharp.API/1.0.361": {
"type": "package",
"serviceable": true,
"sha512": "sha512-HnkIxlKdohu+SU7hsH+wsvz/ihr5naaFzhG2myRitAmXCXcLHYG0l5nFfLwOWIBgFmQsGEY1ZNvhgvWeLhIteg==",
"path": "counterstrikesharp.api/1.0.342",
"hashPath": "counterstrikesharp.api.1.0.342.nupkg.sha512"
"sha512": "sha512-AhTF9MRd/FLJ/rO2+/FxzESvdpieRC8wY5X4HxrwS5MV7Qn5YWP5sk5XU0Cksa/50YbjmrJRg6mH8B9J2wdtTQ==",
"path": "counterstrikesharp.api/1.0.361",
"hashPath": "counterstrikesharp.api.1.0.361.nupkg.sha512"
},
"McMaster.NETCore.Plugins/1.4.0": {
"type": "package",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 5 additions & 19 deletions VIPCore/modules/VIP_Random/VIP_Random.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ public class VIP_Random : BasePlugin
public override string ModuleName => "[VIP] Random";
public override string ModuleAuthor => "T3Marius";
public override string ModuleDescription => "After x rounds from the map start, select random VIP.";
public override string ModuleVersion => "1.0.0";
public override string ModuleVersion => "1.0.1";

private static readonly string Feature = "random_vip";
private IVipCoreApi? _vipApi;
private Config _config = null!;
private PluginCapability<IVipCoreApi> PluginCapability { get; } = new("vipcore:core");

private CCSPlayerController? RandomVIP;
private int _currentRound;
private bool _vipAssigned; // Flag to track if VIP has been assigned
Expand All @@ -38,19 +36,16 @@ public override void OnAllPluginsLoaded(bool hotReload)
Server.PrintToChatAll("VIP API not found.");
return;
}

_config = LoadConfig();
}

private Config LoadConfig()
{
var configPath = Path.Combine(_vipApi.ModulesConfigDirectory, "vip_random.json");

var configPath = Path.Combine(_vipApi!.ModulesConfigDirectory, "vip_random.json");
if (!File.Exists(configPath))
{
return CreateConfig(configPath);
}

var configJson = File.ReadAllText(configPath);
return JsonSerializer.Deserialize<Config>(configJson) ?? CreateConfig(configPath);
}
Expand All @@ -63,24 +58,21 @@ private Config CreateConfig(string configPath)
RandomVIPRound = 4,
RandomVIPMinPlayers = 1
};

File.WriteAllText(configPath, JsonSerializer.Serialize(defaultConfig, new JsonSerializerOptions { WriteIndented = true }));
return defaultConfig;
}

private void SaveConfig()
{
var configPath = Path.Combine(_vipApi.ModulesConfigDirectory, "vip_random.json");
var configPath = Path.Combine(_vipApi!.ModulesConfigDirectory, "vip_random.json");
File.WriteAllText(configPath, JsonSerializer.Serialize(_config, new JsonSerializerOptions { WriteIndented = true }));
}

public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
{
int roundInterval = _config.RandomVIPRound;
int minPlayers = _config.RandomVIPMinPlayers;

_currentRound++;

if (_currentRound >= roundInterval)
{
if (Utilities.GetPlayers().Count >= minPlayers)
Expand All @@ -98,20 +90,17 @@ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
Server.PrintToChatAll(Localizer["prefix"] + Localizer["vip.not.enough"]);
}
}

return HookResult.Continue;
}

public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
{
var player = @event.Userid;

if (player == RandomVIP)
{
_vipApi?.RemoveClientVip(RandomVIP);
_vipApi?.RemoveClientVip(RandomVIP!);
_vipAssigned = false; // Reset the VIP assignment flag if the VIP disconnects
}

return HookResult.Continue;
}

Expand All @@ -133,7 +122,6 @@ public void GetRandomVIP()
string message = localizedMessage.Replace("{playerName}", player.PlayerName);
Server.PrintToChatAll(Localizer["prefix"] + message);
player.PrintToChat(Localizer["prefix"] + Localizer["vip.player.message"]);

_vipApi.GiveClientVip(player, _config.RandomVIPGroup, 1800); // Adding a duration parameter
RandomVIP = player;
_vipAssigned = true; // Set the flag to indicate a VIP has been assigned
Expand All @@ -150,9 +138,7 @@ public void GetRandomVIP()
var players = Utilities.GetPlayers()
.Where(p => p != null && p.IsValid && p.PlayerPawn != null && p.PlayerPawn.IsValid && !p.IsBot && !p.IsHLTV && p.Connected == PlayerConnectedState.PlayerConnected)
.ToList();

if (players.Count == 0) return null;

var rand = new Random();
var randomIndex = rand.Next(players.Count);
return players[randomIndex];
Expand All @@ -164,4 +150,4 @@ public class Config
public required string RandomVIPGroup { get; init; }
public int RandomVIPRound { get; init; }
public int RandomVIPMinPlayers { get; init; }
}
}
2 changes: 1 addition & 1 deletion VIPCore/modules/VIP_Random/VIP_Random.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.342" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.361" />
</ItemGroup>
<ItemGroup>
<Reference Include="VipCoreApi">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
".NETCoreApp,Version=v8.0": {
"VIP_Random/1.0.0": {
"dependencies": {
"CounterStrikeSharp.API": "1.0.342",
"CounterStrikeSharp.API": "1.0.361",
"VipCoreApi": "1.0.0.0"
},
"runtime": {
"VIP_Random.dll": {}
}
},
"CounterStrikeSharp.API/1.0.342": {
"CounterStrikeSharp.API/1.0.361": {
"dependencies": {
"McMaster.NETCore.Plugins": "1.4.0",
"Microsoft.CSharp": "4.7.0",
Expand All @@ -33,8 +33,8 @@
},
"runtime": {
"lib/net8.0/CounterStrikeSharp.API.dll": {
"assemblyVersion": "1.0.342.0",
"fileVersion": "1.0.342.0"
"assemblyVersion": "1.0.361.0",
"fileVersion": "1.0.361.0"
}
}
},
Expand Down Expand Up @@ -557,12 +557,12 @@
"serviceable": false,
"sha512": ""
},
"CounterStrikeSharp.API/1.0.342": {
"CounterStrikeSharp.API/1.0.361": {
"type": "package",
"serviceable": true,
"sha512": "sha512-HnkIxlKdohu+SU7hsH+wsvz/ihr5naaFzhG2myRitAmXCXcLHYG0l5nFfLwOWIBgFmQsGEY1ZNvhgvWeLhIteg==",
"path": "counterstrikesharp.api/1.0.342",
"hashPath": "counterstrikesharp.api.1.0.342.nupkg.sha512"
"sha512": "sha512-AhTF9MRd/FLJ/rO2+/FxzESvdpieRC8wY5X4HxrwS5MV7Qn5YWP5sk5XU0Cksa/50YbjmrJRg6mH8B9J2wdtTQ==",
"path": "counterstrikesharp.api/1.0.361",
"hashPath": "counterstrikesharp.api.1.0.361.nupkg.sha512"
},
"McMaster.NETCore.Plugins/1.4.0": {
"type": "package",
Expand Down
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions VIPCore/modules/VIP_ShowDamage/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using CounterStrikeSharp.API.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShowDamage
{
public class Config : IBasePluginConfig
{
public string AdminGroup { get; set; } = "";

public bool HideDamage { get; set; } = false;

public bool ShowArmorDmg { get; set; } = true;

public int Version { get; set; } = 1;
}
}
Loading