Solved Execute command when one player is left

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Zyxed

Supporter
May 17, 2021
23
1
3
27
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:
command /resetointi:
    trigger:
        set block at location -148, 68, -172 to redstone block

on join:
    set {players.online} to number of all players

on death of player:
    if {players.online} is less than 2:
        make player execute command "/resetointi"
[doublepost=1621870760,1621869852][/doublepost]nvm got it working!
Code:
on join:
    set {players.online} to number of all players

on quit:
    remove 1 from {players.online}

command /resetointi:
    trigger:
        set block at location -148, 68, -172 to redstone block

on death of player:
    remove 1 from {players.online}
    if {players.online} = 1:
        make player execute command "/resetointi"
 
This is very inefficient just remove everything and use:
Code:
on death of player:
    if number of all players [where input players gamemode is survial] is less than 2:
        #do stuff
 
Status
Not open for further replies.