Hey everyone, pretty new to uMod and also Unity programming in general.
So I've chosen an easy project to begin with, ive got an outdated plugin which shows all player positions on the game map, works quite well but when activated player positions show for everyone not just the admin who activated it / has permission.
So ive been studying the code and found that the map icons are added using MapMarkerGenericRadius / VendingMachineMapMarker and in a loop they are destroyed and re-added to keep a live update.
All cool, understand that pretty well.
so ive tried and tried to tie into this function the ability so it only drawns these markers for users who have permission, doesnt matter what I do, everyone connected can see them.
Is there a way to do this? is it even possible? here is the main looped function that draws the markers:
So I've chosen an easy project to begin with, ive got an outdated plugin which shows all player positions on the game map, works quite well but when activated player positions show for everyone not just the admin who activated it / has permission.
So ive been studying the code and found that the map icons are added using MapMarkerGenericRadius / VendingMachineMapMarker and in a loop they are destroyed and re-added to keep a live update.
All cool, understand that pretty well.
so ive tried and tried to tie into this function the ability so it only drawns these markers for users who have permission, doesnt matter what I do, everyone connected can see them.
Is there a way to do this? is it even possible? here is the main looped function that draws the markers:
#region marker generator
void GenerateMarkers()
{
ListPlayers();
MarkerDisplayingDelete(null, null, null);
MapMarkerGenericRadius MapMarker;
VendingMachineMapMarker MapMarkerVending;
Vector3 pos;
string activname;
string sleepername;
foreach (var playeringame in activplayers)
{
playerspos.TryGetValue(playeringame.Key, out pos);
activplayers.TryGetValue(playeringame.Key, out activname);
if (debug){Puts($"-> LOADED MARKER ACTIV LOCATION");}
MapMarkerVending = GameManager.server.CreateEntity("assets/prefabs/deployable/vendingmachine/vending_mapmarker.prefab", pos) as VendingMachineMapMarker;
if (MapMarkerVending == null) return;
if (ShowSteamID) MapMarkerVending.markerShopName = $"ACTIVE PLAYER\n{activname}\nSTEAM : {playeringame.Key}";
else MapMarkerVending.markerShopName = $"ACTIVE PLAYER\n{activname}";
PublicVendMarker.Add(MapMarkerVending);
if (debug) Puts($"-> VENDING MARKER STORED DICT");
MapMarker = GameManager.server.CreateEntity("assets/prefabs/tools/map/genericradiusmarker.prefab", pos) as MapMarkerGenericRadius;
MapMarker.alpha = 1.0f;
MapMarker.color1 = Color.green;
MapMarker.color2 = Color.black;
MapMarker.radius = MarkerRadius;
PublicRadMarker.Add(MapMarker);
if (debug) {Puts($"-> SPAWN MARKER FOR ACTIV PLAYER {activname}");}
}
foreach (var playersleepin in sleepplayers)
{
playerspos.TryGetValue(playersleepin.Key, out pos);
sleepplayers.TryGetValue(playersleepin.Key, out sleepername);
if (debug){Puts($"-> LOADED MARKER ACTIV LOCATION");}
MapMarkerVending = GameManager.server.CreateEntity("assets/prefabs/deployable/vendingmachine/vending_mapmarker.prefab", pos) as VendingMachineMapMarker;
if (MapMarkerVending == null) return;
if (ShowSteamID) MapMarkerVending.markerShopName = $"SLEEPER PLAYER\n{sleepername}\nSTEAM : {playersleepin.Key}";
else MapMarkerVending.markerShopName = $"SLEEPER PLAYER\n{sleepername}";
PublicVendMarker.Add(MapMarkerVending);
if (debug) Puts($"-> VENDING MARKER STORED DICT");
MapMarker = GameManager.server.CreateEntity("assets/prefabs/tools/map/genericradiusmarker.prefab", pos) as MapMarkerGenericRadius;
MapMarker.alpha = 1.0f;
MapMarker.color1 = Color.red;
MapMarker.color2 = Color.black;
MapMarker.radius = MarkerRadius;
PublicRadMarker.Add(MapMarker);
if (debug) Puts($"-> SPAWN MARKER FOR SLEEPING PLAYER {sleepername}");
}
foreach (var Vend in PublicVendMarker)
{
Vend.Spawn();
if (debug){Puts($"-> SPAWN ALL VEND MARKER");}
}
foreach (var Rad in PublicRadMarker)
{
Rad.Spawn();
Rad.SendUpdate();
if (debug){Puts($"-> SPAWN ALL RAD MARKER");}
}
}
#endregion