Skip to content

Commit 03cbb1e

Browse files
authored
1.0.6
1 parent a3b7a62 commit 03cbb1e

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

CnD_Sound.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
using MaxMind.GeoIP2.Exceptions;
66
using System.Text;
77
using System.Drawing;
8-
using CounterStrikeSharp.API.Core.Attributes;
9-
using CounterStrikeSharp.API.Modules.Entities;
108

119

1210
namespace CnD_Sound;
@@ -49,7 +47,7 @@ public class CnDSoundConfig : BasePluginConfig
4947
public class CnDSound : BasePlugin, IPluginConfig<CnDSoundConfig>
5048
{
5149
public override string ModuleName => "Connect Disconnect Sound";
52-
public override string ModuleVersion => "1.0.5";
50+
public override string ModuleVersion => "1.0.6";
5351
public override string ModuleAuthor => "Gold KingZ";
5452
public override string ModuleDescription => "Connect , Disconnect , Country , City , Message , Sound , Logs , Discord";
5553
private static readonly HttpClient _httpClient = new HttpClient();
@@ -111,15 +109,15 @@ private void OnClientPutInServer(int playerSlot)
111109

112110
var player = Utilities.GetPlayerFromSlot(playerSlot);
113111

114-
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.AuthorizedSteamID == null|| player.IpAddress == null)return;
112+
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV)return;
115113

116114
var JoinPlayer = player.PlayerName;
117-
var steamId2 = player.AuthorizedSteamID.SteamId2;
118-
var steamId3 = player.AuthorizedSteamID.SteamId3;
119-
var steamId32 = player.AuthorizedSteamID.SteamId32;
120-
var steamId64 = player.AuthorizedSteamID.SteamId64;
115+
var steamId2 = (player.AuthorizedSteamID != null) ? player.AuthorizedSteamID.SteamId2 : "InvalidSteamID";
116+
var steamId3 = (player.AuthorizedSteamID != null) ? player.AuthorizedSteamID.SteamId3 : "InvalidSteamID";
117+
var steamId32 = (player.AuthorizedSteamID != null) ? player.AuthorizedSteamID.SteamId32.ToString() : "InvalidSteamID";
118+
var steamId64 = (player.AuthorizedSteamID != null) ? player.AuthorizedSteamID.SteamId64.ToString() : "InvalidSteamID";
121119
var GetIpAddress = NativeAPI.GetPlayerIpAddress(playerSlot);
122-
var ipAddress = GetIpAddress.Split(':')[0];
120+
var ipAddress = GetIpAddress?.Split(':')[0] ?? "InValidIpAddress";
123121
var Country = GetCountry(ipAddress);
124122
var SCountry = GetCountryS(ipAddress);
125123
var City = GetCity(ipAddress);
@@ -182,8 +180,10 @@ private void OnClientPutInServer(int playerSlot)
182180
{
183181
foreach(var players in GetPlayerControllers().FindAll(x => x.Connected == PlayerConnectedState.PlayerConnected && !x.IsBot))
184182
{
185-
if (!player.IsValid) continue;
186-
players.ExecuteClientCommand("play " + Config.InGameSoundConnect);
183+
if (players.IsValid)
184+
{
185+
players.ExecuteClientCommand("play " + Config.InGameSoundConnect);
186+
}
187187
}
188188
}
189189
}
@@ -207,15 +207,15 @@ private void OnClientDisconnect(int playerSlot)
207207

208208
var player = Utilities.GetPlayerFromSlot(playerSlot);
209209

210-
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV || player.AuthorizedSteamID == null|| player.IpAddress == null)return;
210+
if (player == null || !player.IsValid || player.IsBot || player.IsHLTV)return;
211211

212212
var JoinPlayer = player.PlayerName;
213-
var steamId2 = player.AuthorizedSteamID.SteamId2;
214-
var steamId3 = player.AuthorizedSteamID.SteamId3;
215-
var steamId32 = player.AuthorizedSteamID.SteamId32;
216-
var steamId64 = player.AuthorizedSteamID.SteamId64;
213+
var steamId2 = (player.AuthorizedSteamID != null) ? player.AuthorizedSteamID.SteamId2 : "InvalidSteamID";
214+
var steamId3 = (player.AuthorizedSteamID != null) ? player.AuthorizedSteamID.SteamId3 : "InvalidSteamID";
215+
var steamId32 = (player.AuthorizedSteamID != null) ? player.AuthorizedSteamID.SteamId32.ToString() : "InvalidSteamID";
216+
var steamId64 = (player.AuthorizedSteamID != null) ? player.AuthorizedSteamID.SteamId64.ToString() : "InvalidSteamID";
217217
var GetIpAddress = NativeAPI.GetPlayerIpAddress(playerSlot);
218-
var ipAddress = GetIpAddress.Split(':')[0];
218+
var ipAddress = GetIpAddress?.Split(':')[0] ?? "InValidIpAddress";
219219
var Country = GetCountry(ipAddress);
220220
var SCountry = GetCountryS(ipAddress);
221221
var City = GetCity(ipAddress);
@@ -278,8 +278,11 @@ private void OnClientDisconnect(int playerSlot)
278278
{
279279
foreach(var players in GetPlayerControllers().FindAll(x => x.Connected == PlayerConnectedState.PlayerConnected && !x.IsBot))
280280
{
281-
if (!player.IsValid) continue;
282-
players.ExecuteClientCommand("play " + Config.InGameSoundDisconnect);
281+
if (players.IsValid)
282+
{
283+
players.ExecuteClientCommand("play " + Config.InGameSoundDisconnect);
284+
}
285+
283286
}
284287
}
285288
}

0 commit comments

Comments
 (0)