Jump to content
  • 0

Spectators gamemode changing to survival when rejoining the server.


maxybuild

Question

I am making a server to play with my friends. It has a skript code that makes it so once you die three times your gamemode changes to spectator. The code has been working as it should, but there is an issue where when spectators rejoin the server, their gamemode is changed to survival. The death count isn't changed, just their gamemode. I know I can just ban them, but I would like to give them the option to spectate the world. I have tried changing many server settings like force gamemode, but none of them made a difference. Can this be fixed?

Here is the code I am using:

  1. on death of player:
  2. add 1 to {deaths::%victim's uuid%}
  3.  
  4. on respawn:
  5. if {deaths::%player's uuid%} >= 3:
  6. set player's gamemode to spectator
  7.  
  8. command /resetdeaths <player>:
  9. permission: deaths.reset
  10. trigger:
  11. set {deaths::%arg-1's uuid%} to 0
  12. set arg-1's gamemode to survival
  • Like 1
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hello there @maxybuild,

You can use a "on join" event so when the player joins and they have died 3 or more times, their gamemode will be forced to be set to spectator.

on join:
  if {deaths::%player's uuid%} >= 3:
  	set player's gamemode to spectator

 

  • Thanks 1

I'm just a known player who been playing since the 24 July 2019.

Please don't DM me for support, go here (if you don't mind waiting) or join Minehut's Discord (which is more active) if you need assistance.


 

Link to comment
Share on other sites

  • 0

That code looks like it should work, but somehow it doesn't. When I kill myself 3 times and my gamemode is turned to spectator, I leave and rejoin, and my gamemode is switched to survival again. I typed /sk reload lives to check whether there was an error in the code and it was completely fine. This is the code again if that helps. Thanks.

on death of player:
    add 1 to {deaths::%victim's uuid%}
 
on respawn:
    if {deaths::%player's uuid%} >= 3:
        set player's gamemode to spectator

on join:
    if {deaths::%player's uuid%} >= 3:
        set player's gamemode to spectator

command /resetdeaths <player>:
    permission: deaths.reset
    trigger:
        set {deaths::%arg-1's uuid%} to 0
        set arg-1's gamemode to survival

Edited by maxybuild
  • Thanks 1
Link to comment
Share on other sites

  • 0

Hmm @maxybuild,

Can you verify that this option is off (like the image, go to your panel > edit server > settings)?

force-gamemode.png.9524fa8a065eb0572d7b219f5fcba573.png

Also, can you verify that the option is "false" in your server.properties file (go to panel > edit server > file manager > server.properties)?

force-gamemode-2.png.c484644a21f92b1a45f75ba2c7f516fa.png

If they are not, then set them to how they are in the images above.

Please note: after changing any server settings, you need to restart the server.

If this didn't help, please contact support here and click on "Contact Support" on the page linked.

  • Thanks 1

I'm just a known player who been playing since the 24 July 2019.

Please don't DM me for support, go here (if you don't mind waiting) or join Minehut's Discord (which is more active) if you need assistance.


 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...