Solved Last player standing.

  • 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.
May 5, 2018
2
0
0
23
Okay, so, I'm making a minigame for my server and I need help finding the last player standing in the arena. I already have it where they will teleport to the spawn when they die, I just need it to find if there is only one player in the arena world, it can execute some things. Thank you!

Code:
code_language.skript:
                    set {game.active} to true
                    loop all players:
                        teleport loop-player to spawn of "./maps/%arg-2%/default"
                        set {%loop-player%.ingame} to true
                        send "&6&l&m=============================================" to loop-player
                        send "&6Game - &7Fighter Mania" to loop-player
                        send "&6Map - &7Default Map" to loop-player
                        send "&6 " to loop-player
                        send "&6Game Information" to loop-player
                        send "&eFree for all!"
                        send "&eFight your enemies to their death."
                        send "&eLast player standing wins!"
                        send "&c&lWARNING: &cThe arcade is in beta! Expect some bugs." to loop-player
                        send "&6&l&m=============================================" to loop-player
                        give loop-player 1 iron helmet named "&6&lHelmet &8(Equip)"
                        give loop-player 1 iron chestplate named "&6&lChestplate &8(Equip)"
                        give loop-player 1 iron leggings named "&6&lLeggings &8(Equip)"
                        give loop-player 1 iron boots named "&6&lBoots &8(Equip)"
                        give loop-player 1 stone sword named "&6&lSword"
                        wait 2 seconds
                        send "&6Game> &7A 10 second grace period has started!" to loop-player
                        wait 10 seconds
                        send "&6Game> &7The grace period has ended. Start fighting!"
                        set {pvp.enabled} to true
                        #Find last player standing...
                        #Whenever I add a last player standing thing, game will end (code below)
                        wait 2 seconds
                        set {pvp.enabled} to false
                        set {%loop-player%.ingame} to false
                        send "&6&l&m=============================================" to loop-player
                        send "&6&lGame Ended!" to loop-player
                        send "&aReturning to the waiting area..." to loop-player
                        send "&6&l&m=============================================" to loop-player
                        teleport loop-player to spawn of "./arcadelobby"
 
Actually I would add all the player's to a list at the beginning. And with a "on death of player" event just remove them. If the size of the list is 1 you will have your last player standing

code_language.skript:
on join:
    add player to {alive::*}
   
on death of player:
    remove player from {alive::*}
    if size of {alive::*} is less than 2:
        loop {alive::*}:
            broadcast "The winner is %loop-value%"
   
on quit:
    remove player from {alive::*}
    if size of {alive::*} is less than 2:
        loop {alive::*}:
            broadcast "The winner is %loop-value%"
 
Actually I would add all the player's to a list at the beginning. And with a "on death of player" event just remove them. If the size of the list is 1 you will have your last player standing

code_language.skript:
on join:
    add player to {alive::*}
  
on death of player:
    remove player from {alive::*}
    if size of {alive::*} is less than 2:
        loop {alive::*}:
            broadcast "The winner is %loop-value%"
  
on quit:
    remove player from {alive::*}
    if size of {alive::*} is less than 2:
        loop {alive::*}:
            broadcast "The winner is %loop-value%"
Thank you!
 
Status
Not open for further replies.