Compare commits

...

5 Commits
v1.0.13 ... v17

Author SHA1 Message Date
Roflmuffin
cb6d86a54d feat: implement IEquatable<T> for SteamID 2023-11-10 17:29:45 +10:00
Roflmuffin
d4a2ae68e1 Merge branch 'main' of github.com:roflmuffin/CounterStrikeSharp into main 2023-11-09 23:25:40 +10:00
Roflmuffin
82c92f555b chore: simplify auto-copy configs folder 2023-11-09 23:22:35 +10:00
Daniel Saewitz
19a0923559 feat: Add Current API Version to css console command (#47) 2023-11-09 13:24:54 +10:00
Roflmuffin
cef9758c12 fix: ignore -1 in get players, fixes, #46 2023-11-09 11:02:15 +10:00
11 changed files with 50 additions and 12 deletions

View File

@@ -56,7 +56,6 @@ jobs:
- name: Add API to Artifacts
run: |
mkdir -p build/output/addons/counterstrikesharp/api
mkdir -p build/output/addons/counterstrikesharp/plugins
cp -r managed/CounterStrikeSharp.API/bin/Release/net7.0/publish/* build/output/addons/counterstrikesharp/api
- uses: actions/upload-artifact@v3

View File

@@ -114,7 +114,8 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/addons/counterstrikesharp/bin/linuxsteamrt64"
)
add_custom_target(build-time-make-directory ALL
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/addons/metamod")
configure_file(configs/counterstrikesharp.vdf "${CMAKE_BINARY_DIR}/addons/metamod/counterstrikesharp.vdf" COPYONLY)
configure_file(configs/gamedata.json "${CMAKE_BINARY_DIR}/addons/counterstrikesharp/gamedata/gamedata.json" COPYONLY)
add_custom_command(
TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/configs ${CMAKE_BINARY_DIR}
)

View File

@@ -0,0 +1,4 @@
Place plugins in this folder. Each plugin should be in its own subfolder, e.g.
TestPlugin/TestPlugin.dll
AnotherPlugin/AnotherPlugin.dll

View File

@@ -165,7 +165,7 @@ namespace CounterStrikeSharp.API.Core
private PluginContext? FindPluginByIdOrName(string query)
{
PluginContext? plugin = null;
if (Int32.TryParse(query, out var pluginNumber))
{
@@ -180,9 +180,12 @@ namespace CounterStrikeSharp.API.Core
private void OnCSSCommand(CCSPlayerController? caller, CommandInfo info)
{
var currentVersion = Api.GetVersion();
Utilities.ReplyToCommand(caller, " CounterStrikeSharp was created and is maintained by Michael \"roflmuffin\" Wilson.\n" +
" Counter-Strike Sharp uses code borrowed from SourceMod, Source.Python, FiveM, Saul Rennison and CS2Fixes.\n" +
" See ACKNOWLEDGEMENTS.md for more information.", true);
" See ACKNOWLEDGEMENTS.md for more information.\n" +
" Current API Version: " + currentVersion, true);
return;
}
@@ -206,7 +209,7 @@ namespace CounterStrikeSharp.API.Core
sb.Append(plugin.Description);
}
Utilities.ReplyToCommand(caller, sb.ToString(), true);
}
break;
@@ -231,7 +234,7 @@ namespace CounterStrikeSharp.API.Core
{
path = Path.Combine(rootDir.FullName, path);
}
try
{
LoadPlugin(path);
@@ -240,7 +243,7 @@ namespace CounterStrikeSharp.API.Core
{
Console.WriteLine($"Failed to load plugin {path} with error {e}");
}
break;
}

View File

@@ -2,7 +2,7 @@ using System;
namespace CounterStrikeSharp.API.Modules.Entities
{
public class SteamID
public class SteamID : IEquatable<SteamID>
{
const long Base = 76561197960265728;
public ulong SteamId64 { get; set; }
@@ -46,5 +46,35 @@ namespace CounterStrikeSharp.API.Modules.Entities
}
public override string ToString() => $"[SteamID {SteamId64}, {SteamId2}, {SteamId3}]";
public bool Equals(SteamID? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return SteamId64 == other.SteamId64;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((SteamID)obj);
}
public override int GetHashCode()
{
return SteamId64.GetHashCode();
}
public static bool operator ==(SteamID? left, SteamID? right)
{
return Equals(left, right);
}
public static bool operator !=(SteamID? left, SteamID? right)
{
return !Equals(left, right);
}
}
}

View File

@@ -79,7 +79,7 @@ namespace CounterStrikeSharp.API
{
var controller = GetPlayerFromIndex(i);
if (!controller.IsValid || controller.UserId < 0)
if (!controller.IsValid || controller.UserId == -1)
continue;
players.Add(controller);

View File

@@ -15,6 +15,7 @@
*/
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using CounterStrikeSharp.API;