Grimshackles Posted August 5, 2024 Share Posted August 5, 2024 hi i need a mod that reveals the map for the player when he spawn in for dedicated server i have one but it's only for non dedicated Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/ Share on other sites More sharing options...
Haruhi Kawaii Posted August 7, 2024 Share Posted August 7, 2024 On 8/5/2024 at 3:32 PM, Dezcoo said: hi i need a mod that reveals the map for the player when he spawn in for dedicated server i have one but it's only for non dedicated Do you want to reveal the map based on one entity or the entire map? local function MapExplorer(inst) local find = TheSim:FindFirstEntityWithTag("king") if find then local x, y, z = find.Transform:GetWorldPosition() inst.player_classified.MapExplorer:RevealArea(x, y, z) end end AddPrefabPostInit("world", function(inst) if not TheWorld.ismastersim then return inst end inst:ListenForEvent("ms_newplayerspawned", function(world, player) local mapexplorer = player:DoTaskInTime(3, MapExplorer) end) end) 1 Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739556 Share on other sites More sharing options...
Grimshackles Posted August 7, 2024 Author Share Posted August 7, 2024 i want it to reveal the entire map for everyone that's comes online Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739667 Share on other sites More sharing options...
Grimshackles Posted August 7, 2024 Author Share Posted August 7, 2024 also my server just freezes when i run the script lol does it take time even before i log in? Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739683 Share on other sites More sharing options...
. . . Posted August 7, 2024 Share Posted August 7, 2024 I think this code will reveal map for all players I remember seeing it on dst wiki also based on how big your map is and how many players and how many prefabs exist in world it will freeze up the game for k, v in pairs(AllPlayers) do for x = -1600, 1600, 35 do for y = -1600, 1600, 35 do v.player_classified.MapExplorer:RevealArea(x, 0, y) end end end Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739686 Share on other sites More sharing options...
Grimshackles Posted August 8, 2024 Author Share Posted August 8, 2024 Isen't there like a better way,can't you give someone cartographer's desk map scroll with full map and make them read it so it doesn't make the whole game lag? Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739742 Share on other sites More sharing options...
Grimshackles Posted August 8, 2024 Author Share Posted August 8, 2024 On 8/7/2024 at 6:01 AM, Haruhi Kawaii said: Do you want to reveal the map based on one entity or the entire map? local function MapExplorer(inst) local find = TheSim:FindFirstEntityWithTag("king") if find then local x, y, z = find.Transform:GetWorldPosition() inst.player_classified.MapExplorer:RevealArea(x, y, z) end end AddPrefabPostInit("world", function(inst) if not TheWorld.ismastersim then return inst end inst:ListenForEvent("ms_newplayerspawned", function(world, player) local mapexplorer = player:DoTaskInTime(3, MapExplorer) end) end) it just makes the server lag and not work i tried leaving it on for more than 50 minutes but it doesn't work Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739812 Share on other sites More sharing options...
. . . Posted August 8, 2024 Share Posted August 8, 2024 20 hours ago, Dezcoo said: Isen't there like a better way,can't you give someone cartographer's desk map scroll with full map and make them read it so it doesn't make the whole game lag? Sharing map with cartographer's desk map scroll depending on how much map the player has revealed and if the player using it has very little map revealed will cause lag spike too for the entire game. There's no avoiding lag spike when revealing the entire map unfortunately it's a demanding process on the server I assume which is why it causes lag for everybody Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739903 Share on other sites More sharing options...
_zwb Posted August 9, 2024 Share Posted August 9, 2024 2 hours ago, . . . said: There's no avoiding lag spike when revealing the entire map unfortunately it's a demanding process on the server I assume which is why it causes lag for everybody you can avoid it by starting a new thread Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739918 Share on other sites More sharing options...
Grimshackles Posted August 9, 2024 Author Share Posted August 9, 2024 14 hours ago, _zwb said: you can avoid it by starting a new thread how you do that though Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1739982 Share on other sites More sharing options...
_zwb Posted August 9, 2024 Share Posted August 9, 2024 5 hours ago, Dezcoo said: how you do that though function EntityScript:StartThread(fn) return StartThread(fn, self.GUID) end AddPrefabPostInit("world", function(inst) if not TheWorld.ismastersim then return inst end inst:ListenForEvent("ms_newplayerspawned", function(world, player) player:StartThread(function() for x = -1600, 1600, 35 do for y = -1600, 1600, 35 do player.player_classified.MapExplorer:RevealArea(x, 0, y) end end) end) end) 1 Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1740026 Share on other sites More sharing options...
Grimshackles Posted August 10, 2024 Author Share Posted August 10, 2024 13 hours ago, _zwb said: function EntityScript:StartThread(fn) return StartThread(fn, self.GUID) end AddPrefabPostInit("world", function(inst) if not TheWorld.ismastersim then return inst end inst:ListenForEvent("ms_newplayerspawned", function(world, player) player:StartThread(function() for x = -1600, 1600, 35 do for y = -1600, 1600, 35 do player.player_classified.MapExplorer:RevealArea(x, 0, y) end end) end) end) i just get brackets error when i run it Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1740113 Share on other sites More sharing options...
Grimshackles Posted August 11, 2024 Author Share Posted August 11, 2024 -- AddPrefabPostInit is used to modify the "world" prefab after its initialization AddPrefabPostInit("world", function(inst) -- Ensure this code only runs on the master simulation if not TheWorld.ismastersim then return inst end -- Function to progressively reveal the map using a coroutine local function RevealMapCoroutine(player) local min_x, max_x = -1600, 1600 local min_y, max_y = -1600, 1600 local step = 100 -- Size of each chunk local delay = 0.1 -- Delay in seconds between reveals for x = min_x, max_x, step do for y = min_y, max_y, step do if player.player_classified and player.player_classified.MapExplorer then player.player_classified.MapExplorer:RevealArea(x, 0, y) else print("Error: MapExplorer not found for player " .. tostring(player.GUID)) return end end -- Yield to avoid locking up the server; this simulates running on a separate thread Sleep(delay) end end -- Listen for the event when a new player spawns inst:ListenForEvent("ms_newplayerspawned", function(world, player) -- Start a coroutine (simulated thread) to progressively reveal the map player:StartThread(function() -- Run the map reveal coroutine local reveal_thread = coroutine.create(function() RevealMapCoroutine(player) end) while coroutine.status(reveal_thread) ~= "dead" do local success, err = coroutine.resume(reveal_thread) if not success then print("Coroutine error: " .. tostring(err)) break end -- Yield control to avoid blocking Sleep(0.1) end end) end) end) this is what chat gpt came up with but no matter what i do the server is frozen still if someone wants to help please Link to comment https://forums.kleientertainment.com/forums/topic/158863-mod-requestreveal-map-for-dedicated-server-when-the-player-spawn-in/#findComment-1740213 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now