-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
164 additions
and
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Modules.Admin; | ||
using CounterStrikeSharp.API.Modules.Commands; | ||
using CounterStrikeSharp.API; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ImperfectModels | ||
{ | ||
public partial class ImperfectModels | ||
{ | ||
// Command for changing the player model alpha (transparency) | ||
[ConsoleCommand("css_selfmodelalpha", "Changes the alpha of your player model")] | ||
[CommandHelper(minArgs: 1, usage: "<number for alpha ex. 50>", whoCanExecute: CommandUsage.CLIENT_ONLY)] | ||
[RequiresPermissions("@css/root")] | ||
public void ChangeSelfModelAlphaCommand(CCSPlayerController? player, CommandInfo commandInfo) | ||
{ | ||
/// This argument is the number for the alpha | ||
var alphaPercentage = commandInfo.GetArg(1); | ||
int alphaPercentageInt = 0; | ||
|
||
var intParseSuccess = int.TryParse(alphaPercentage, out alphaPercentageInt); | ||
|
||
if (intParseSuccess) | ||
{ | ||
try | ||
{ | ||
player.PlayerPawn.Value.Render = Color.FromArgb(alphaPercentageInt, 255, 255, 255); | ||
Utilities.SetStateChanged(player.PlayerPawn.Value, "CBaseModelEntity", "m_clrRender"); | ||
|
||
commandInfo.ReplyToCommand($"Player model alpha set to {alphaPercentage}"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.LogWarning("Something went wrong when setting the player model alpha {message}", ex.Message); | ||
|
||
commandInfo.ReplyToCommand("Something went wrong when setting the player model alpha. Check error logs for more info."); | ||
} | ||
} | ||
else | ||
{ | ||
Logger.LogWarning("The number that was input was not correct."); | ||
commandInfo.ReplyToCommand("The number that you input was not correct. Try a number between 1 and 255."); | ||
} | ||
} | ||
|
||
// Command for changing all players model alpha (transparency) | ||
[ConsoleCommand("css_modelalpha", "Changes the alpha of all player models")] | ||
[CommandHelper(minArgs: 1, usage: "<number for alpha ex. 50>", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] | ||
[RequiresPermissions("@css/root")] | ||
public void ChangeModelAlphaCommand(CCSPlayerController? player, CommandInfo commandInfo) | ||
{ | ||
/// This argument is the number for the alpha | ||
var alphaPercentage = commandInfo.GetArg(1); | ||
int alphaPercentageInt = 0; | ||
|
||
var connectedPlayers = Utilities.GetPlayers(); | ||
|
||
var intParseSuccess = int.TryParse(alphaPercentage, out alphaPercentageInt); | ||
|
||
if (intParseSuccess) | ||
{ | ||
try | ||
{ | ||
foreach (var connectedPlayer in connectedPlayers) | ||
{ | ||
connectedPlayer.PlayerPawn.Value.Render = Color.FromArgb(alphaPercentageInt, 255, 255, 255); | ||
Utilities.SetStateChanged(connectedPlayer.PlayerPawn.Value, "CBaseModelEntity", "m_clrRender"); | ||
} | ||
|
||
commandInfo.ReplyToCommand($"All player models alpha set to {alphaPercentage}"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.LogWarning("Something went wrong when setting the player model alpha {message}", ex.Message); | ||
|
||
commandInfo.ReplyToCommand("Something went wrong when setting the player model alpha. Check error logs for more info."); | ||
} | ||
} | ||
else | ||
{ | ||
Logger.LogWarning("The number that was input was not correct."); | ||
commandInfo.ReplyToCommand("The number that you input was not correct. Try a number between 1 and 255."); | ||
} | ||
} | ||
} | ||
} |
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,68 @@ | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ImperfectModels | ||
{ | ||
public partial class ImperfectModels | ||
{ | ||
public void RegisterPlayerEvents() | ||
{ | ||
RegisterEventHandler<EventPlayerConnectFull>((@event, info) => | ||
{ | ||
if (@event.Userid.IsValid) | ||
{ | ||
var player = @event.Userid; | ||
|
||
if (!player.IsValid || player.IsBot) | ||
{ | ||
return HookResult.Continue; | ||
} | ||
else | ||
{ | ||
OnPlayerConnect(player); | ||
return HookResult.Continue; | ||
} | ||
} | ||
else | ||
{ | ||
return HookResult.Continue; | ||
} | ||
}); | ||
} | ||
private void OnPlayerConnect(CCSPlayerController? player, bool isForBot = false) | ||
{ | ||
try | ||
{ | ||
if (player == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (player.PlayerPawn == null) | ||
{ | ||
return; | ||
} | ||
|
||
try | ||
{ | ||
player.PlayerPawn.Value.Render = Color.FromArgb(Config.DefaultAlpha, 255, 255, 255); | ||
Utilities.SetStateChanged(player.PlayerPawn.Value, "CBaseModelEntity", "m_clrRender"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine($"Something bad happened: {ex.Message}"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine($"Something bad happened: {ex.Message}"); | ||
} | ||
} | ||
} | ||
} |
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