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.

Function to Mob Spawn depending on Room teleport

Discussion in 'Skript' started by Jerooski, Jun 17, 2020.

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

    Jerooski Member

    Joined:
    Apr 19, 2020
    Messages:
    16
    Likes Received:
    0
    So I wanna make it so custom mobs spawn in set locations depending on the room the players enter.

    For example if player Steve gets teleported to room 1, mobs spawn at locations A & B of the room 1.
    then Steve moves to room 2, mobs spawn at locations A & B of room 2.

    The thing is room teleport is random and have over 30 rooms, how could I make it into a function so it detects what room player is teleporting to and just spawns the mobs in the set locations of that same room.

    (I have already set the rooms locations and have no problem with that)
    I'm quite lost and just have this, what would be the best way to store those mobs locations and spawn them on point A and B depending on the room.

    Code (Text):
    1. set {_roomtp} to a random integer between 1 and 30
    2. teleport player to {spawn.room%{_roomtp}%}
    3. run function mobSpawn("moblocation", "room%{_roomtp}%")
    4.  
    5.  
    6. function mobSpawn(m: text, r: text):
    7.     if {_r} is "room1":
    8.         spawn 1 adult zombie at location {_m1}
    9.         set name of last spawned entity to "&2Death Miner &7&o%player%"
    10.         set health of last spawned entity to 10
    11.         set {_chest} to leather chestplate
    12.         dye {_chest} (205, 89, 255)
    13.         equip last spawned entity with {_chest}
    14.         equip last spawned entity with chain leggings
    15.         equip last spawned entity with leather boots
    16.         set tool of last spawned entity to stone pickaxe
    17.         spawn 1 adult zombie at location {_m2}
    18.         set name of last spawned entity to "&2Death Miner &7&o%player%"
    19.         set health of last spawned entity to 10
    20.         set {_chest} to leather chestplate
    21.         dye {_chest} (205, 89, 255)
    22.         equip last spawned entity with {_chest}
    23.         equip last spawned entity with chain leggings
    24.         equip last spawned entity with leather boots
    25.         set tool of last spawned entity to stone pickaxe
     
  2. pokw

    pokw Member

    Joined:
    Jun 3, 2019
    Messages:
    48
    Likes Received:
    1
    Try setting a variable after the player has been teleported to the room to then have the zombies spawn at a location according to that variable.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...