Skip to content

Commit

Permalink
admins only
Browse files Browse the repository at this point in the history
  • Loading branch information
InvalidArgument3 committed Jun 18, 2024
1 parent d1f2f99 commit 0f97148
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Dynamic Asteroids/Data/Scripts/DynamicAsteroids/MainSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using VRageMath;
using ProtoBuf;
using Sandbox.Game.Entities;
using VRage.Game.ModAPI;
using VRage.Game;

namespace DynamicAsteroids
{
Expand Down Expand Up @@ -80,6 +82,9 @@ protected override void UnloadData()

private void OnMessageEntered(string messageText, ref bool sendToOthers)
{
var player = MyAPIGateway.Session.Player;
if (player == null || !IsPlayerAdmin(player)) return;

if (messageText.StartsWith("/dynamicasteroids") || messageText.StartsWith("/dn"))
{
var args = messageText.Split(' ');
Expand Down Expand Up @@ -108,6 +113,11 @@ private void OnMessageEntered(string messageText, ref bool sendToOthers)
}
}

private bool IsPlayerAdmin(IMyPlayer player)
{
return MyAPIGateway.Session.OnlineMode == MyOnlineModeEnum.OFFLINE || MyAPIGateway.Session.IsUserAdmin(player.SteamUserId);
}

private void CreateSpawnArea(double radius)
{
var player = MyAPIGateway.Session.Player;
Expand Down

0 comments on commit 0f97148

Please sign in to comment.