pickleplayer Posted October 10, 2020 Share Posted October 10, 2020 So I'm trying to create a scenario where anyone who joins the server, even if they have played on the server previously, is forced to pick a new character and respawn as if it was their first time joining. I imagine the cleanest way to do this would be to run TheWorld:PushEvent("ms_playerdespawnanddelete", player) as the player disconnects, but haven't been able to get this to work because TheWorld:PushEvent("ms_playerdespawn", player) is already pushed as soon as the player disconnects, and so I'm pretty sure it's trying to delete the player twice. It doesn't crash, but the main menu becomes frozen in time and breaks the game until you restart. If I can't get the character to be removed on disconnecting, another lazy alternative would be to just despawnanddelete a player whenever they connect to the server with an existing character. Unfortunately, "ms_playerjoined" happens any time a player spawns, regardless of if it's their first time picking a character, reconnecting to an existing one, or respawning as a new character within the same session. So I'm kind of unsure where to go from here. Maybe there are some other events that I'm not familiar with, but I don't do a whole lot with server events so I'm hoping someone will know more than I do. 1 Link to comment Share on other sites More sharing options...
penguin0616 Posted October 10, 2020 Share Posted October 10, 2020 @pickleplayer Create a table. When "ms_playerjoined" is fired, check the table. If they are in the table, you already dealt with them. They're good to go. If they are not, Check if they have a character already. If they do, reroll them (despawnanddelete). If not, do nothing. Add them to the table. 1 1 Link to comment Share on other sites More sharing options...
pickleplayer Posted October 15, 2020 Author Share Posted October 15, 2020 Oh, yea that would be a pretty simple way to do it. Thanks! I'm sure your method would have worked, but I realized recently that despawning the player after joining would cause other issues with other parts of the mod, so I had to find an alternative. I did finally figure out how to despawn them as they leave though. Attaching "DeleteUserSession(inst)" to a the playercommon's OnDespawn function does the trick for everyone except a local host. Luckily, this doesn't need to apply to the host, so it works out well for me. 1 Link to comment 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