Solved Spawn System Help

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

Stefqnutz

Active Member
Sep 23, 2019
67
1
8
19
Im trying to make a SG Skript and im having trouble for the player spawning system, what I mean by that is when the game will start the players need to spawn to a specified location, and I dont really know how to do that.

Code:
options:
    prefix: &8[&6SG&8]


on load:
    set {survivalgames.%%lobbyplayercounter%%} to "0"
    set {%%spawn1%%} to "0"
    set {%%spawn2%%} to "0"


on join:
    teleport player to {lobby}
    add 1 to {survivalgames.%%lobbyplayercounter%%}


on quit:
    remove 1 from {survivalgames.%%lobbyplayercounter%%}

every 2 seconds:
    if {survivalgames.%%lobbyplayercounter%%} is less than 0:
        add 1 to {survivalgames.%%lobbyplayercounter%%}


command sg [<text>]:
    permission: sg.admin
    trigger:
        if arg 1 is not set:
            send "&cADMIN COMMANDS"
            send " "
            send " "
            send " "
            send "&c/sg setlobby | Sets were the players will spawn when they join the lobby."
            send "&c/sg addspawn <id> | Self explanatory, keep in mind the max spawn number is 12."
            send "&c/sg adddeathmatchspawn <id> | Same as the previous command, tho this is for the deathmatch spawns."
        if arg 1 is "setlobby":
            set {lobby} to location of player
            send "{@prefix} &aLobby was set at your current location."
        if arg 1 is "addspawn":
            send "{@prefix} &cUsage: /sg addspawn 1/2/3/4/5/6/7/8/9/10/11/12"
        if arg 1 is "addspawn 1":
            set {spawn1} to location of player
            send "{@prefix} &aSpawn 1 was set to your current location."
        if arg 1 is "addspawn 2":
            set {spawn2} to location of player
            send "{@prefix} &aSpawn 2 was set to your current location."
        if arg 1 is "addspawn 3":
            set {spawn3} to location of player
            send "{@prefix} &aSpawn 3 was set to your current location."
        if arg 1 is "addspawn 4":
            set {spawn4} to location of player
            send "{@prefix} &aSpawn 4 was set to your current location."
        if arg 1 is "addspawn 5":
            set {spawn5} to location of player
            send "{@prefix} &aSpawn 5 was set to your current location."
        if arg 1 is "addspawn 6":
            set {spawn6} to location of player
            send "{@prefix} &aSpawn 6 was set to your current location."
        if arg 1 is "addspawn 7":
            set {spawn7} to location of player
            send "{@prefix} &aSpawn 7 was set to your current location."
        if arg 1 is "addspawn 8":
            set {spawn8} to location of player
            send "{@prefix} &aSpawn 8 was set to your current location."
        if arg 1 is "addspawn 9":
            set {spawn9} to location of player
            send "{@prefix} &aSpawn 9 was set to your current location."
        if arg 1 is "addspawn 10":
            set {spawn10} to location of player
            send "{@prefix} &aSpawn 10 was set to your current location."
        if arg 1 is "addspawn 11":
            set {spawn11} to location of player
            send "{@prefix} &aSpawn 11 was set to your current location."
        if arg 1 is "addspawn 12":
            set {spawn12} to location of player
            send "{@prefix} &aSpawn 12 was set to your current location."
        if arg 1 is "forcestart":
            broadcast "{@prefix} &aStarted the game. Good luck!"
            chance of 50%:
                add 1 to {%%spawn1%%}
                teleport player to {spawn1}
                stop
            chance of 50%:
                if {%%spawn1%%} is greater than 0:
                    add 1 to {%%spawn2%%}
                    teleport player to {spawn2}
                    stop
 
code_language.skript:
on load:
    set {survivalgames.%%lobbyplayercounter%%} to "0"
    set {%%spawn1%%} to "0"
    set {%%spawn2%%} to "0"
 
 
on join:
    teleport player to {lobby}
    add 1 to {survivalgames.%%lobbyplayercounter%%}
 
 
on quit:
    remove 1 from {survivalgames.%%lobbyplayercounter%%}
 
every 2 seconds:
    if {survivalgames.%%lobbyplayercounter%%} is less than 0:
        add 1 to {survivalgames.%%lobbyplayercounter%%}
 
 
command sg [<text>] [<integer>]:
    permission: sg.admin
    trigger:
        if arg 1 is not set:
            send "&cADMIN COMMANDS"
            send " "
            send " "
            send " "
            send "&c/sg setlobby | Sets were the players will spawn when they join the lobby."
            send "&c/sg addspawn <id> | Self explanatory, keep in mind the max spawn number is 12."
            send "&c/sg adddeathmatchspawn <id> | Same as the previous command, tho this is for the deathmatch spawns."
        if arg 1 is "setlobby":
            set {lobby} to location of player
            send "{@prefix} &aLobby was set at your current location."
        if arg 1 is "addspawn":
            if arg 2 is not set:
                send "{@prefix} &cUsage: /sg addspawn 1/2/3/4/5/6/7/8/9/10/11/12"
                stop
            if arg 2 > 12:
                stop
            if arg 2 < 1:
                stop
            set {spawn::%arg 2%} to location of player
            send "{@prefix} &aSpawn %arg 2% was set to your current location."
        if arg 1 is "forcestart":
            broadcast "{@prefix} &aStarted the game. Good luck!"
            #This var needs to contain all players to be teleported
            set {_i} to 1
            loop {_queuedplayers::*}:
                teleport loop-value to {spawn::%{_i}%}
                set {_i} to {_i} + 1
 
Status
Not open for further replies.