Skip to content

Commit

Permalink
Automatically Add Game Admins
Browse files Browse the repository at this point in the history
- Automatically generate a mod admin entry if the player is recognized as a game admin
-- Root game admins will have Root (z) mod powers and a 100 immunity level
-- Standard game admins will have Kick, Slay, Map, Commander, Endround, Eject, Mute, Generic, and Teams powers and a 10 immunity level
  • Loading branch information
data-bomb committed May 5, 2024
1 parent 061cc2c commit 153a1c1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
34 changes: 31 additions & 3 deletions Si_AdminMod/AdminMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License

#if !NET6_0
using DebugTools;
#else
using Il2Cpp;
#endif

using MelonLoader;
Expand Down Expand Up @@ -77,14 +79,40 @@ public static bool UnregisterAdminCommand(String adminCommand)

public static Admin? FindAdminFromSteamId(long steamId)
{
foreach (Admin admin in SiAdminMod.AdminList)
// check the mod admin list first
foreach (Admin modAdmin in SiAdminMod.AdminList)
{
if (admin.SteamId == steamId)
if (modAdmin.SteamId == steamId)
{
return admin;
return modAdmin;
}
}

// grant some default powers if they are on the game's admin list but missing from the mod admin list
NetworkAdminPlayer gameAdmin = NetworkServerSettings.GetPlayerAdmin((ulong)steamId);
if (gameAdmin != null)
{
Admin gameModAdminConversion = new Admin
{
SteamId = steamId,
Level = (gameAdmin.m_Root ? (byte)100 : (byte)10),
Name = gameAdmin.m_Name,
CreatedOn = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
LastModifiedOn = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
Powers = (gameAdmin.m_Root ? Power.Root : (Power.Kick
| Power.Slay
| Power.Map
| Power.Commander
| Power.End
| Power.Eject
| Power.Mute
| Power.Generic
| Power.Teams))
};

return gameModAdminConversion;
}

return null;
}

Expand Down
4 changes: 2 additions & 2 deletions Si_AdminMod/ModAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Silica Admin Mod
Copyright (C) 2024 by databomb
Copyright (C) 2023-2024 by databomb
* License *
This program is free software: you can redistribute it and/or modify
Expand All @@ -21,7 +21,7 @@ You should have received a copy of the GNU General Public License
using SilicaAdminMod;
using System.Drawing;

[assembly: MelonInfo(typeof(SiAdminMod), "Admin Mod", "2.0.768", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonInfo(typeof(SiAdminMod), "Admin Mod", "2.0.769", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]

// Color.Cyan
Expand Down

0 comments on commit 153a1c1

Please sign in to comment.