jekart021 Posted January 7, 2022 Share Posted January 7, 2022 I need to check the number of live players, that is, I need to run the code, provided that only 1 player is alive, for example, let's take "print (He is alive)". I tried to find the code to regenerate the world with dead players, but I could not find it, I will be glad to help. Thank you ^_^ Link to comment https://forums.kleientertainment.com/forums/topic/136778-is-he-alive/ Share on other sites More sharing options...
Monti18 Posted January 10, 2022 Share Posted January 10, 2022 You can check the living players by looping through the table AllPlayers and checking if they have the tag "playerghost" to see if they are dead. You can regenerate the world by using the functions shown in console_commands.lua -- Permanently delete all game worlds in a server cluster, regenerates new worlds afterwards -- NOTE: This will not work properly for any shard that is offline or in a loading state function c_regenerateworld() if TheWorld ~= nil and TheWorld.ismastersim then TheNet:SendWorldResetRequestToServer() end end Link to comment https://forums.kleientertainment.com/forums/topic/136778-is-he-alive/#findComment-1531633 Share on other sites More sharing options...
jekart021 Posted January 11, 2022 Author Share Posted January 11, 2022 Can you tell me how to execute the code with just one live player? Link to comment https://forums.kleientertainment.com/forums/topic/136778-is-he-alive/#findComment-1531789 Share on other sites More sharing options...
Monti18 Posted January 11, 2022 Share Posted January 11, 2022 I think something like this should work: local function ResetWorld() if #GLOBAL.AllPlayers <= 1 then if GLOBAL.TheWorld ~= nil and GLOBAL.TheWorld.ismastersim then GLOBAL.TheNet:SendWorldResetRequestToServer() end end end This needs to be executed on the server, otherwise it won't work. Link to comment https://forums.kleientertainment.com/forums/topic/136778-is-he-alive/#findComment-1531797 Share on other sites More sharing options...
jekart021 Posted January 11, 2022 Author Share Posted January 11, 2022 Link to comment https://forums.kleientertainment.com/forums/topic/136778-is-he-alive/#findComment-1531813 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