#Mob spawning

1 messages · Page 1 of 1 (latest)

wide trellis
#

Is there a way to create a script that spawn a cow that when you kill it and 5 seconds pass another will spawn? (i dont want the cow to be moving too)

sick glen
#

There is a way

#

Make a function for spawning it

#

And just make a code where if that specific cow is killed, it runs the function

wide trellis
#

ok thanks

wide trellis
sick glen
#

No

#

Make the spawning a function

wide trellis
#
  wait 5 seconds
  spawn cow with noAi NBT ```
#

like that?

sick glen
#

That’s not how functions work

#

Do some googling on how functions work for entity types :)

wide trellis
#

idk bro i am trying

#
  wait 5 seconds
  set {_n} to nbt compound from "{NoAI:1b}"
  spawn cow at location(69, -60 -15 world "skripts") with nbt {_n}```
#

this?

#

idk how functions work 100%

sick glen
#

Entity type instead of player

wide trellis
#

also this error

tame geyser
#

Remove the part that errored

#

Remove the n:nbt part

wide trellis
#

ok

sick glen
#

Spawn it at a variable

#

Way easier

wide trellis
#

how do i do that lol

#

first time

#

nvm

#

i just put some commas'

tame geyser
#

👍 now?

wide trellis
#

i have multiple cow spawns tho

#

how would that work?

#

this doesnt work too

  wait 5 seconds
  set {_n} to nbt compound from "{NoAI:1b}"
  spawn cow at location(69, -60, -15, world "skripts") with nbt {_n}```
i get no errors but it doesnt work
it spawns like 300 cows
and then they all die from entity cramming
and then 24 remain
they have the noAi nbt
but why does it spawn that many?
sick glen
#

you might've looped all players or something

wide trellis
#

i dont think so

sick glen
#

show full code

wide trellis
#

sure

sick glen
#

why loop all players every second

#

just make a function with boolean

#

and check upon killing mobs

wide trellis
#

that is not the point

sick glen
#

so it can return value

#

it most likely is

#

Im trynna help you get your code as efficienct as possible

wide trellis
#

ok

wide trellis
sick glen
#

they are easy to learn

wide trellis
#
  loop all players:
    if {combat::%loop-player's uuid%} is 1:
      if {combatxp::%loop-player's uuid%} >= 50:
        set {combat::%loop-player's uuid%} to 2
        set {combatxp::%loop-player's uuid%} to 0
        send "&7-----------&8-----------" to loop-player
        send "&e&lCOMBAT 1 → COMBAT 2" to loop-player
        send "&7-----------&8-----------" to loop-player
    if {combat::%loop-player's uuid%} is 2:
      if {combatxp::%loop-player's uuid%} >= 150:
        set {combat::%loop-player's uuid%} to 3
        set {combatxp::%loop-player's uuid%} to 0
        send "&7-----------&8-----------" to loop-player
        send "&e&lCOMBAT 2 → COMBAT 3" to loop-player
        send "&7-----------&8-----------" to loop-player
    if {combat::%loop-player's uuid%} is 3:
      if {combatxp::%loop-player's uuid%} >= 500:
        set {combat::%loop-player's uuid%} to 4
        set {combatxp::%loop-player's uuid%} to 0
        send "&7-----------&8-----------" to loop-player
        send "&e&lCOMBAT 3 → COMBAT 4" to loop-player
        send "&7-----------&8-----------" to loop-player
    if {combat::%loop-player's uuid%} is 2:
      if {combatxp::%loop-player's uuid%} >= 1000:
        set {combat::%loop-player's uuid%} to 3
        set {combatxp::%loop-player's uuid%} to 0
        send "&7-----------&8-----------" to loop-player
        send "&e&lCOMBAT 4 → COMBAT 5" to loop-player
        send "&7-----------&8-----------" to loop-player
        stop```
#

this ?

sick glen
#

thats a very bad code yeah

wide trellis
#

how do i do it?

sick glen
#

lemme show you

#
function check(stuff here) :: boolean:
  if {var} is x:
    return true
  else:
    return false

on death of x:
  if check(stuff here) = true
    #do stuff
#

gotta fill out the x and whatever I didnt do since I can't spoonfeed

wide trellis
#

spoonfeed?

sick glen
#

Spoonfeeding is when you spoil the whole code

#

If I were to give you the whole code

#

Its not allowed

wide trellis
#
  if {combat::%loop-player's uuid%} is 1:
    if {combatxp::%loop-player's uuid%} >= 50:
      set {combat::%loop-player's uuid%} to 2
      set {combatxp::%loop-player's uuid%} to 0
      send "&7-----------&8-----------" to loop-player
      send "&e&lCOMBAT 1 → COMBAT 2" to loop-player
      send "&7-----------&8-----------" to loop-player
    if {combat::%loop-player's uuid%} is 2:
      if {combatxp::%loop-player's uuid%} >= 150:
        set {combat::%loop-player's uuid%} to 3
        set {combatxp::%loop-player's uuid%} to 0
        send "&7-----------&8-----------" to loop-player
        send "&e&lCOMBAT 2 → COMBAT 3" to loop-player
        send "&7-----------&8-----------" to loop-player
    if {combat::%loop-player's uuid%} is 3:
      if {combatxp::%loop-player's uuid%} >= 500:
        set {combat::%loop-player's uuid%} to 4
        set {combatxp::%loop-player's uuid%} to 0
        send "&7-----------&8-----------" to loop-player
        send "&e&lCOMBAT 3 → COMBAT 4" to loop-player
        send "&7-----------&8-----------" to loop-player
    if {combat::%loop-player's uuid%} is 2:
      if {combatxp::%loop-player's uuid%} >= 1000:
        set {combat::%loop-player's uuid%} to 3
        set {combatxp::%loop-player's uuid%} to 0
        send "&7-----------&8-----------" to loop-player
        send "&e&lCOMBAT 4 → COMBAT 5" to loop-player
        send "&7-----------&8-----------" to loop-player
        stop```
#

like that?

#

wait mb

sick glen
#

you cant do loop player in a function

#

its {_p}

wide trellis
#

yea

#

lmao

#

i forgot

#

i just copied it

sick glen
#

also return true/false

#

true is if its meeting the correct requirements

#

false is the opposite

#

I usually use it for checking if player has met correct requirements

#

now run the function on death event

#

(this makes it so if a player kills a mob it checks their variable and levels up their combat)

#

so you dont need to do it every second

wide trellis
# sick glen just make a function with boolean

like this?

  if {combat::%player's uuid%} is 1:
    if {combatxp::%player's uuid%} >= 50:
      set {combat::%player's uuid%} to 2
      set {combatxp::%player's uuid%} to 0
      send "&7-----------&8-----------" to {_p}
      send "&e&lCOMBAT 1 → COMBAT 2" to {_p}
      send "&7-----------&8-----------" to {_p}
    if {combat::%player's uuid%} is 2:
      if {combatxp::%player's uuid%} >= 150:
        set {combat::%player's uuid%} to 3
        set {combatxp::%player's uuid%} to 0
        send "&7-----------&8-----------" to {_p}
        send "&e&lCOMBAT 2 → COMBAT 3" to {_p}
        send "&7-----------&8-----------" to {_p}
    if {combat::%player's uuid%} is 3:
      if {combatxp::%player's uuid%} >= 500:
        set {combat::%player's uuid%} to 4
        set {combatxp::%player's uuid%} to 0
        send "&7-----------&8-----------" to {_p}
        send "&e&lCOMBAT 3 → COMBAT 4" to {_p}
        send "&7-----------&8-----------" to {_p}
    if {combat::%player's uuid%} is 4:
      if {combatxp::%player's uuid%} >= 1000:
        set {combat::%player's uuid%} to 5
        set {combatxp::%player's uuid%} to 0
        send "&7-----------&8-----------" to {_p}
        send "&e&lCOMBAT 4 → COMBAT 5" to {_p}
        send "&7-----------&8-----------" to {_p}
        stop```
#

it works tbh

#

i have this too

  loop all players:
    if {combat::%loop-player's uuid%} is 1:
      send action bar "&e%{combatxp::%loop-player's uuid%}%/50xp" to loop-player
    if {combat::%loop-player's uuid%} is 2:
      send action bar "&e%{combatxp::%loop-player's uuid%}%/150xp" to loop-player
    if {combat::%loop-player's uuid%} is 3:
      send action bar "&e%{combatxp::%loop-player's uuid%}%/500xp" to loop-player
    if {combat::%loop-player's uuid%} is 4:
      send action bar "&e%{combatxp::%loop-player's uuid%}%/1000xp" to loop-player
      stop```
#

should ii make it like this?

  if {combat::%player's uuid%} is 1:
    send action bar "&e%{combatxp::%loop-player's uuid%}%/50xp" to {_p}
  if {combat::%player's uuid%} is 2:
    send action bar "&e%{combatxp::%loop-player's uuid%}%/150xp" to {_p}
  if {combat::%player's uuid%} is 3:
    send action bar "&e%{combatxp::%loop-player's uuid%}%/500xp" to {_p}
  if {combat::%player's uuid%} is 4:
    send action bar "&e%{combatxp::%loop-player's uuid%}%/1000xp" to {_p}
    stop```
sick glen
#

{_p}

wide trellis
#

ok

#

if {combat::%{_p}'s uuid%} is 4:

#

like that?

#

ok fixed it

#

bruh the cow bug still remains

sick glen
#

Uhh

#

Debug

wide trellis
#

this?

  wait 5 seconds
  set {_n} to nbt compound from "{NoAI:1b}"
  spawn cow at location(69, -60, -15, world "skripts") with nbt {_n}```
sick glen
#

dont wait 5 seconds

#

try n remove it

#

show me ur full code

wide trellis
#

but i want it to spawn 5 seconds after the other one died

#

skript doesnt fit in discord

sick glen
#

yeah

#

send it as a .txt

wide trellis
#

how

sick glen
#

just send it

wide trellis
#

ok

sick glen
#

you still have every 1 seconds

wide trellis
#

yea

sick glen
#

remove it

wide trellis
#

how will the player see their xp ):

sick glen
#

remove the on spawn of cow

#

thats the issue

wide trellis
#

ok done

sick glen
#

now it should work

wide trellis
#

it doesnt lmao

sick glen
#

do skript effect commands to test function

#

whats the issue now?

wide trellis
#

i removed the death and it works

sick glen
#
  set {_n} to nbt compound from "{NoAI:1b}"
  spawn 1 cow with nbt {_n}```

U removed this right?
wide trellis
#

but it spawns with an Ai

sick glen
#

spawn 1 cow?

wide trellis
#

yes it spawns one cow but it spawns with a Ai

sick glen
#

do spawn 1 cow with nbt {_n}

#

Ohh I know why

#

you didnt set where it spawns

wide trellis
sick glen
#

theres no location

wide trellis
#

there is

#
  wait 5 seconds
  set {_n} to nbt compound from "{NoAI:1b}"
  spawn cow at location(69, -60, -15, world "skripts") with nbt {_n}```
sick glen
#

debug it

#

something is off in your skript

wide trellis
#

can i get skript-debug for that?

sick glen
#

no

#

debug it urself

wide trellis
#

what is debuging?

#

and dont clown on me ):

sick glen
#

its fixing the error

autumn willow
#

clowns on you

wide trellis
#

waaaa

wide trellis
sick glen
wide trellis
#

but it doesnt work

sick glen
#

That’s why u debug it

wide trellis
#

the cow doesnt get the noAi nbt

#

i have the function but it doesnt work

#

idk how to run the function when a cow spawns

wide trellis
#

why did you leave me on read? ):

sick glen
#

I didn’t

#

I just read it now, I’m at soccer can’t help rn

wide trellis
#

Oh mb

#

sorry

wide trellis
#

@sick glen sorry for pinging you but can i use this instead of the function?

    if event-entity is cow:
        if location of event-entity is 69, -60, -15, in world "skripts":
            wait 5 seconds
            spawn 1 cow with nbt "{NoAI:1b}" at location 69, -60, -15, in world "skripts"```
sick glen
#

Try

wide trellis
#

should i do

    if victim is cow:
        if location of victim is 69, -60, -15, in world "skripts":
            wait 5 seconds
            spawn 1 cow with nbt "{NoAI:1b}" at location 69, -60, -15, in world "skripts"```
tame geyser
#

hmmmm

#

Yes, that

wide trellis
#

ok

tame geyser
#

Use the location function

wide trellis
#

i used this in the end

    if victim is cow:
        if attacker is player:
            if location of victim is location(-69, -60, -24, world "skripts", 90, 0):
                wait 2.5 seconds
                set {_n} to nbt compound from "{NoAI:1b}"
                spawn cow at location(-69, -60, -24, world "skripts", 90, 0) with nbt {_n}```
tame geyser
#

I guess?

#

No need to ping me

wide trellis
#

i didnt i just replied

tame geyser
#

You pinged me.

#

By replying.

wide trellis
#

oh mb

pliant garden
#

if feel like that won't work because the player is unlikely not at a very specific block, he's gonna be in a region

#

you could check for worldguard regions or check between 2 locations

pliant garden
#

oh cus its the cow's location, makes sense

pliant garden
sick glen
#

no need to check between locations

pliant garden
#

why are you even telling this

#

this was solved at hours ago