Solved I need help in random spawns

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

christianmv84

Active Member
Jul 20, 2017
50
0
0
59
Well I will explain a little what I want to do:

I want to do a skript of uhcmetup, and I want that when entering, because each person appears in a different place, that is to say each person spawne in the map of 100x100 but in a different place, never that 2 players spawnen in a same place thanks!
 
code_language.skript:
function getUhcmetupLocation(locations:Locations,radius:Integer=27,best_players_count:Integer=100) :: Location:
    loop {_locations::*}:
        if amount of (all players in radius {_radius} around loop-value) = 0:
            return loop-value
        else if amount of (all players in radius {_radius} around loop-value) < {_best_players_count}:
            set {_return} to loop-value
            set {_best_players_count} to amount of (all players in radius {_radius} around loop-value)
    #if {_return} isn't set:
      #  return {_locations::1}
    return {_return}
 
Well I will explain a little what I want to do:

I want to do a skript of uhcmetup, and I want that when entering, because each person appears in a different place, that is to say each person spawne in the map of 100x100 but in a different place, never that 2 players spawnen in a same place thanks!
I found this code online from a Spigot skript post that's free to download, you could change some things and repurpose it to your wishes.

code_language.skript:
options:
    min.x: -250
    max.x: 250
    min.z: -250
    max.z: 250
    avoid: air or water block or lava block or stone block or sandstone block or mossy cobblestone block or dirt block
    perm: cmd.wild
    cooldown: 10 seconds #Change to whatever you like such as "1 minute" "2 hours" "1 day" "30 seconds"


Command /wild:
    permission: {@perm}
    trigger:
        set {_waited} to difference between {wild.%player%.lastused} and now
        if {_waited} is less than {@cooldown}:
            message "&c(!) &4You must wait %difference between {@cooldown} and {_waited}% before using this command again."
            stop
        
        send "&c(!) &eTeleporting to the wild. &e&l{Expect Some &4&lMinor &e&lLag}" to player
        wait 1 tick
        send "&c(!) &eTeleporting in 3 Seconds."
        wait 1 second
        send "&c(!) &eTeleporting in 2 Seconds."
        wait 1 second
        send "&c(!) &eTeleporting in 1 Second."
        wait 2 second
        apply resistance 100 to player for 6 seconds
        wait 1 tick
        set {_loc::old} to player's location
        while player's location is {_loc::old}:
            set {_loc::new} to location at random number between {@min.x} and {@max.x}, 0, random number between {@min.z} and {@max.z}
            loop blocks above {_loc::new}:
                if loop-block and block above loop-block are air:
                    if block under loop-block is not {@avoid}:
                        set {_loc::new} to location of loop-block
                        teleport player to {_loc::new}
                        stop loop
                        wait 10 ticks
        set {wild.%player%.lastused} to now
You could make the uhc core skript I assume you're using to automatically make all players execute the /wild command on the start of the game or build it into the 'on game start' code area, best of luck,
~Selvati