5
5
using MaxMind . GeoIP2 . Exceptions ;
6
6
using System . Text ;
7
7
using System . Drawing ;
8
- using CounterStrikeSharp . API . Core . Attributes ;
9
- using CounterStrikeSharp . API . Modules . Entities ;
10
8
11
9
12
10
namespace CnD_Sound ;
@@ -49,7 +47,7 @@ public class CnDSoundConfig : BasePluginConfig
49
47
public class CnDSound : BasePlugin , IPluginConfig < CnDSoundConfig >
50
48
{
51
49
public override string ModuleName => "Connect Disconnect Sound" ;
52
- public override string ModuleVersion => "1.0.5 " ;
50
+ public override string ModuleVersion => "1.0.6 " ;
53
51
public override string ModuleAuthor => "Gold KingZ" ;
54
52
public override string ModuleDescription => "Connect , Disconnect , Country , City , Message , Sound , Logs , Discord" ;
55
53
private static readonly HttpClient _httpClient = new HttpClient ( ) ;
@@ -111,15 +109,15 @@ private void OnClientPutInServer(int playerSlot)
111
109
112
110
var player = Utilities . GetPlayerFromSlot ( playerSlot ) ;
113
111
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 ;
115
113
116
114
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" ;
121
119
var GetIpAddress = NativeAPI . GetPlayerIpAddress ( playerSlot ) ;
122
- var ipAddress = GetIpAddress . Split ( ':' ) [ 0 ] ;
120
+ var ipAddress = GetIpAddress ? . Split ( ':' ) [ 0 ] ?? "InValidIpAddress" ;
123
121
var Country = GetCountry ( ipAddress ) ;
124
122
var SCountry = GetCountryS ( ipAddress ) ;
125
123
var City = GetCity ( ipAddress ) ;
@@ -182,8 +180,10 @@ private void OnClientPutInServer(int playerSlot)
182
180
{
183
181
foreach ( var players in GetPlayerControllers ( ) . FindAll ( x => x . Connected == PlayerConnectedState . PlayerConnected && ! x . IsBot ) )
184
182
{
185
- if ( ! player . IsValid ) continue ;
186
- players . ExecuteClientCommand ( "play " + Config . InGameSoundConnect ) ;
183
+ if ( players . IsValid )
184
+ {
185
+ players . ExecuteClientCommand ( "play " + Config . InGameSoundConnect ) ;
186
+ }
187
187
}
188
188
}
189
189
}
@@ -207,15 +207,15 @@ private void OnClientDisconnect(int playerSlot)
207
207
208
208
var player = Utilities . GetPlayerFromSlot ( playerSlot ) ;
209
209
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 ;
211
211
212
212
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" ;
217
217
var GetIpAddress = NativeAPI . GetPlayerIpAddress ( playerSlot ) ;
218
- var ipAddress = GetIpAddress . Split ( ':' ) [ 0 ] ;
218
+ var ipAddress = GetIpAddress ? . Split ( ':' ) [ 0 ] ?? "InValidIpAddress" ;
219
219
var Country = GetCountry ( ipAddress ) ;
220
220
var SCountry = GetCountryS ( ipAddress ) ;
221
221
var City = GetCity ( ipAddress ) ;
@@ -278,8 +278,11 @@ private void OnClientDisconnect(int playerSlot)
278
278
{
279
279
foreach ( var players in GetPlayerControllers ( ) . FindAll ( x => x . Connected == PlayerConnectedState . PlayerConnected && ! x . IsBot ) )
280
280
{
281
- if ( ! player . IsValid ) continue ;
282
- players . ExecuteClientCommand ( "play " + Config . InGameSoundDisconnect ) ;
281
+ if ( players . IsValid )
282
+ {
283
+ players . ExecuteClientCommand ( "play " + Config . InGameSoundDisconnect ) ;
284
+ }
285
+
283
286
}
284
287
}
285
288
}
0 commit comments