Citizen range & loop-citizen

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

Francesco0608

New Member
Jan 14, 2018
6
0
0
20
Goodnight, SkUnity. I've got problems with this part of code, How can I fix it? (Minecraft 1.8)
code_language.skript:
every second in "world":
     loop all players in radius 5 around player: # don't work
          if loop-player is not a citizen: #don't work
          set {test} to "no"
on npc left click: # How can I set number of clicks?
     send "test" to player
     damage player by 0.5 heart
on damage of a player:
 if {test} is "yes":
     attacker is a player:
      send attacker title "&7..." with subtitle "&ctest" for 2 seconds
      set {_plus} to a citizen near 5 blocks of attacker # don't worrk
      make citizen {_plus} fight attacker # don't work
 
Last edited:
1 and 2. It doesn't work because you're looping the players around the player, but what player? That event doesn't not have any. Moreover, the whole trigger is redundant as NPCs aren't players, it's a different entity type so that variable will never be set.

3. You'd use a variable like {npc-clicks::%player%}, in the event, check if the variable is equal to the number of clicks and if so run your code, then add 1 to your variable.

4. Not sure if that's even a valid expression but anyways. You can't set a single variable to multiple objects, you have to use a list variable (i.e. {_plus::*}) or use the element of expression.
 
Last edited:
1 and 2. It doesn't work because you're looping the players around the player, but what player? That event doesn't not have any. Moreover, the whole trigger is redundant as NPCs aren't players, it's a different entity type so that variable will never be set.

3. You'd use a variable like {npc-clicks::%player%}, in the event, check if the variable is equal to the number of clicks and if so run your code, then add 1 to your variable.

4. Not sure if that's even a valid expression but anyways. You can't set a single variable to multiple objects, you have to use a list variable (i.e. {_plus::*}) or use the element of expression.
Excuse me could you give me an example to fix it? [For loop] I would to loop all citizens around the player, when there is a npc near the player the variable "{test}" will be set to "yes"
 
Last edited:
I corrected the beginning, I didn't understand what else you want to do?

code_language.skript:
every second in "world":
    loop all players:
        loop all players in radius 5 around loop-player:
            if metadata "NPC" of loop-player-2 is not set:
 
I corrected the beginning, I didn't understand what else you want to do?

code_language.skript:
every second in "world":
    loop all players:
        loop all players in radius 5 around loop-player:
            if metadata "NPC" of loop-player-2 is not set:
How can I set a citizen near 5 blocks of the player?
 
Je n'ai pas compris votre requête
Sorry lol.
code_language.skript:
on damage of a player:
 if {test} is "yes":
     attacker is a player:
      send attacker title "&7..." with subtitle "&ctest" for 2 seconds
      set {_plus} to a citizen near 5 blocks of attacker # don't worrk
      make citizen {_plus} fight attacker # don't work
When the player hit another player, if {test} is "yes". It sets a random citizen near 5 blocks of the player (radius) and it makes this citizen fight attacker
[doublepost=1516216000,1516112025][/doublepost]
Sorry lol.
code_language.skript:
on damage of a player:
 if {test} is "yes":
     attacker is a player:
      send attacker title "&7..." with subtitle "&ctest" for 2 seconds
      set {_plus} to a citizen near 5 blocks of attacker # don't worrk
      make citizen {_plus} fight attacker # don't work
When the player hit another player, if {test} is "yes". It sets a random citizen near 5 blocks of the player (radius) and it makes this citizen fight attacker
The citizen in radius were activated with this code. And select before running "make citizen {this citizen} fight attacker
 
Status
Not open for further replies.