This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
generated from K4ryuu/Project_Template
-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
218 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using static K4System.ModuleRank; | ||
|
||
namespace K4System; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
namespace K4System | ||
{ | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
using K4System.Models; | ||
|
||
public partial class ModuleUtils : IModuleUtils | ||
{ | ||
public void Initialize_Events() | ||
{ | ||
if (Config.UtilSettings.ConnectMessageEnable) | ||
{ | ||
plugin.RegisterEventHandler((EventPlayerActivate @event, GameEventInfo info) => | ||
{ | ||
K4Player? k4player = plugin.GetK4Player(@event.Userid); | ||
if (k4player is null || !k4player.IsValid || !k4player.IsPlayer) | ||
return HookResult.Continue; | ||
Server.PrintToChatAll(ReplacePlaceholders(k4player, plugin.ApplyPrefixColors(Config.UtilSettings.ConnectMessage))); | ||
return HookResult.Continue; | ||
}); | ||
} | ||
|
||
if (Config.UtilSettings.DisconnectMessageEnable) | ||
{ | ||
plugin.RegisterEventHandler((EventPlayerDisconnect @event, GameEventInfo info) => | ||
{ | ||
K4Player? k4player = plugin.GetK4Player(@event.Userid); | ||
if (k4player is null || !k4player.IsValid || !k4player.IsPlayer) | ||
return HookResult.Continue; | ||
Server.PrintToChatAll(ReplacePlaceholders(k4player, plugin.ApplyPrefixColors(Config.UtilSettings.DisconnectMessage))); | ||
return HookResult.Continue; | ||
}); | ||
} | ||
} | ||
|
||
public string ReplacePlaceholders(K4Player k4player, string text) | ||
{ | ||
Dictionary<string, string> placeholders = new Dictionary<string, string> | ||
{ | ||
{ "{name}", k4player.PlayerName }, | ||
{ "{steamid}", k4player.SteamID.ToString() }, | ||
{ "{clantag}", k4player.ClanTag }, | ||
{ "{rank}", k4player.rankData?.Rank.Name ?? "Unranked" }, | ||
{ "{country}", plugin.GetPlayerCountryCode(k4player.Controller) }, | ||
{ "{points}", k4player.rankData?.Points.ToString() ?? "0" }, | ||
{ "{topplacement}", k4player.rankData?.TopPlacement.ToString() ?? "0" }, | ||
{ "{playtime}", k4player.timeData?.TimeFields["all"].ToString() ?? "0" }, | ||
}; | ||
|
||
foreach (var placeholder in placeholders) | ||
{ | ||
text = text.Replace(placeholder.Key, placeholder.Value); | ||
} | ||
|
||
return text; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.