Solved can you set a variable to a zombie and how?

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

    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.
It's possible to set a variable to a server entity (i.e. not a player); however, the variable will cease to point to that specific entity if/when the server restarts- even if that exact entity is still present on the server.
 
It's possible to set a variable to a server entity (i.e. not a player); however, the variable will cease to point to that specific entity if/when the server restarts- even if that exact entity is still present on the server.
code_language.skript:
spawn a zombie
add 1 to {number}
set {variable.%spawned zombie%.%{number}%} to 10
 
code_language.skript:
spawn a zombie
add 1 to {number}
set {variable.%spawned zombie%.%{number}%} to 10

For short term variables, sure- using them as a variable / setting a variable to them is fine.

However, if you stop your server, the variable will no longer be able to point to the entity. If you set a variable to an entity like:

code_language.skript:
spawn zombie at player
set {entitySpawn} to last spawned entity

You should get a message saying exactly what I'm saying upon script reload.
 
For short term variables, sure- using them as a variable / setting a variable to them is fine.

However, if you stop your server, the variable will no longer be able to point to the entity. If you set a variable to an entity like:

code_language.skript:
spawn zombie at player
set {entitySpawn} to last spawned entity

You should get a message saying exactly what I'm saying upon script reload.
the variable I set is for like aximum 10 second that variable represent the life of the zombie is just a minigame whend the level complete i set {number} to 0 again and the zombie variable is goin to set temporary to another zombie can I do that with this code or I need to use that u say ?

code_language.skript:
spawn a zombie
add 1 to {number}
set {variable.%spawned zombie%.%{number}%} to 10
 
the variable I set is for like aximum 10 second that variable represent the life of the zombie is just a minigame whend the level complete i set {number} to 0 again and the zombie variable is goin to set temporary to another zombie can I do that with this code or I need to use that u say ?

code_language.skript:
spawn a zombie
add 1 to {number}
set {variable.%spawned zombie%.%{number}%} to 10

Your current code will definitely be okay; don't worry. I'm just stressing the importance of saving entities over long periods of time, but you shouldn't run into that issue for what you're trying to achieve.
 
Your current code will definitely be okay; don't worry. I'm just stressing the importance of saving entities over long periods of time, but you shouldn't run into that issue for what you're trying to achieve.
thanks men you are the best this is like my 5 skript you silved me
 
  • Like
Reactions: Orendigo
Status
Not open for further replies.