1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Execute command when one player is left

Discussion in 'Skript' started by Zyxed, May 24, 2021.

Thread Status:
Not open for further replies.
  1. Zyxed

    Supporter

    Joined:
    May 17, 2021
    Messages:
    23
    Likes Received:
    1
    I'm having a trouble with my skript. I want to execute command when there is one player left in survival gamemode.
    Example: 2 players in survival mode remaining, and the other player kills the other one -> execute command.

    I have no clue how to get this to work.

    Code (Text):
    1. command /resetointi:
    2.     trigger:
    3.         set block at location -148, 68, -172 to redstone block
    4.  
    5. on join:
    6.     set {players.online} to number of all players
    7.  
    8. on death of player:
    9.     if {players.online} is less than 2:
    10.         make player execute command "/resetointi"
    --- Double Post Merged, May 24, 2021, Original Post Date: May 24, 2021 ---
    nvm got it working!
    Code (Text):
    1. on join:
    2.     set {players.online} to number of all players
    3.  
    4. on quit:
    5.     remove 1 from {players.online}
    6.  
    7. command /resetointi:
    8.     trigger:
    9.         set block at location -148, 68, -172 to redstone block
    10.  
    11. on death of player:
    12.     remove 1 from {players.online}
    13.     if {players.online} = 1:
    14.         make player execute command "/resetointi"
     
  2. Minecoll_YT

    Supporter Forums Helper

    Joined:
    Dec 2, 2018
    Messages:
    650
    Likes Received:
    39
    This is very inefficient just remove everything and use:
    Code (Text):
    1. on death of player:
    2.     if number of all players [where input players gamemode is survial] is less than 2:
    3.         #do stuff
     
Thread Status:
Not open for further replies.

Share This Page

Loading...