near npc

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

yzlm

Member
Feb 25, 2021
16
0
1
23
on join:
while player online:
loop player in radius 20 of the npc: #does not work
push loop-player up at speed 1
push loop-player backwards at speed 2
play sound "entity.wither.shoot" with volume 0.7 to the player

is this true can anyone help me? i wanna when player go into npc i wanna push player
 
on join:
while player online:
loop player in radius 20 of the npc: #does not work
push loop-player up at speed 1
push loop-player backwards at speed 2
play sound "entity.wither.shoot" with volume 0.7 to the player

is this true can anyone help me? i wanna when player go into npc i wanna push player
You need put a "Loop all players" before. Also, i dont think that its needed loop all players.

code_language.skript:
on join:
   while player is online:
       set {_npc} to a npc with name "Name of Npc" and entity type "PLAYER"
       set {_p::*} to all players in radius 20 of {_npc}
       loop {_p::*}
          push loop-player upwards with force 1
          push loop-player backwards with force 2
          play sound "entity.wither.shoot" with volume 3 and pitch 1 at {_npc}
       wait a second

You need skellet to do this.
 
You need put a "Loop all players" before. Also, i dont think that its needed loop all players.

code_language.skript:
on join:
   while player is online:
       set {_npc} to a npc with name "Name of Npc" and entity type "PLAYER"
       set {_p::*} to all players in radius 20 of {_npc}
       loop {_p::*}
          push loop-player upwards with force 1
          push loop-player backwards with force 2
          play sound "entity.wither.shoot" with volume 3 and pitch 1 at {_npc}
       wait a second

You need skellet to do this.

the server crashing down why i don't know but when server start and completed loading its freezing 5-10 sec and crashing because skript
 
the server crashing down why i don't know but when server start and completed loading its freezing 5-10 sec and crashing because skript
Mmh... another alternative for your script is to save the position of the npc and use that instead of Skellett. Like this:

Do you wrote "wait a second"? It's important to put a timeout when creating a "while".
 
  • Like
Reactions: yzlm
Code:
on join:
    while player is online:
        set {_npc} to a npc with name "Skyblock" and entity type "PLAYER"
        set {_p::*} to all players in radius 20 of {_npc}
        loop {_p::*}
            push loop-player upwards with force 1
            push loop-player backwards with force 2
            play sound "entity.wither.shoot" with volume 3 and pitch 1 at {_npc}
        wait a second

i have skellet
upload_2021-2-26_8-53-36.png


upload_2021-2-26_8-54-7.png
 

Attachments

  • upload_2021-2-26_8-49-58.png
    upload_2021-2-26_8-49-58.png
    56.9 KB · Views: 86
  • upload_2021-2-26_8-50-33.png
    upload_2021-2-26_8-50-33.png
    17.5 KB · Views: 93
Code:
on join:
    while player is online:
        set {_npc} to a npc with name "Skyblock" and entity type "PLAYER"
        set {_p::*} to all players in radius 20 of {_npc}
        loop {_p::*}
            push loop-player upwards with force 1
            push loop-player backwards with force 2
            play sound "entity.wither.shoot" with volume 3 and pitch 1 at {_npc}
        wait a second

i have skellet
View attachment 5806

View attachment 5807
The first error is because forgotten put the ':' after loop {_p::*}
code_language.skript:
loop {_p::*}:
And im testing the code i wrote and it sent me the same error as you.
[doublepost=1614319235,1614319111][/doublepost]And yeah... i made a mistake again. Remove all "Loop-players" from the code i sent you and replace them for "loop-value"
 
i did now i don't see any error but still doesn't work i guess i making mistake when write npc name can we make this for all npcs or how can i find npc name
 
i did now i don't see any error but still doesn't work i guess i making mistake when write npc name can we make this for all npcs or how can i find npc name
I think that its a Skellett error, but anyways, try setting the npc loc like this:

code_language.skript:
command /npcloc:
    trigger:
        set {npc.loc} to player's location
#Wrote the command of up in Npc location.

every second:
    loop all players in radius 5 of {npc.loc}:
        push loop-player upwards with force 1
        push loop-player backwards with force 2
I try it, and i must used every a second.
 
yes its workeeddd but how can i add multiple location for npcs
I didnt tested, but try this:
code_language.skript:
command /npcloc [<string>]:
   trigger:
       arg 1 is set:
           add player's location to {npc.loc::*}
           send "&aLoc established"
       
every second:
   loop all players in radius 5 of {npc.loc::*}:
        push loop-player upwards with force 1
        push loop-player backwards with force 2
 
Yep, this work for me:

code_language.skript:
command /npcloc [<string>]:
    trigger:
        arg 1 is set: #Npc name
            set {npc.loc::%arg 1%} to player's location


every second:
    loop {npc.loc::*}:
        loop all players in radius 5 of loop-value:
            push loop-player upwards with force 1
            push loop-player backwards with force 2
 
this part still does not work :emoji_frowning:
Code:
every second:
    loop {npc.loc::*}:
        loop all players in radius 5 of loop-value:
            push loop-player upwards with force 1
            push loop-player backwards with force 2
 
this part still does not work :emoji_frowning:
Code:
every second:
    loop {npc.loc::*}:
        loop all players in radius 5 of loop-value:
            push loop-player upwards with force 1
            push loop-player backwards with force 2
How weird... that works to me.

Did you use /npcloc to set the positions of NPCs?
[doublepost=1614322608,1614322171][/doublepost]If you had doubt, i tested it : https://gyazo.com/5da493d359377c3f2d50965400a52879
 
loop {npc.loc::*}:
i guess this part does not work im using skript 2.2-dev36
 
Status
Not open for further replies.