Show map marker only for players with permission?
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:

#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​
You need to destroy marker for all players that can't see it + use CanNetworkTo

P.S. Some examples in vanish

Merged post

Also i can recommend using https://umod.org/plugins/rust-marker-manager
Thanks for working to update that mod! 
Sorry thats over my head to be honest, very new to the scripting language, what do you mean by examples in vanish? Can you link me to some documentation I'm struggling to find anything.
He means open the Vanish.cs file for pre-made code examples in the code file.
5ba216a6d7f65.png Orange
You need to destroy marker for all players that can't see it + use CanNetworkTo

P.S. Some examples in vanish

Merged post

Also i can recommend using https://umod.org/plugins/rust-marker-manager

this is a plugin with many BUGS, it shows ONLY vending machine markers, not costum markers, so not usable !
if i tell wrong, tell user, what is the exactly command for a custom marker with no vendingmachine icon ...