Jump to content

Health "api"


PixelTrainerYT

Recommended Posts

so i decided to make this:

command sethealth <text> <num> <text>:
	trigger:
		set {%arg 3% %arg 1%} to arg 2
		loop {healthlist::*}:
			if loop-value is arg 1:
				remove loop-value from {healthlist::*}
		add arg 1 to {healthlist::*}




every tick:
	Loop all players:
		set loop-player's max health to 10
		loop {healthlist::*}:
			add {%uuid of loop-player% %loop-value-2%} to loop-player's max health
		
		

This allows me to have multiple skripts that will change the players health without any of them conflicting eachother

theres probably a better way to achieve this and this might have a few issues but this is all I have for now

if you can see this, you have vision

Link to comment
Share on other sites

3 minutes ago, PixelTrainerYT said:

so i decided to make this:

command sethealth <text> <num> <text>:
	trigger:
		set {%arg 3% %arg 1%} to arg 2
		loop {healthlist::*}:
			if loop-value is arg 1:
				remove loop-value from {healthlist::*}
		add arg 1 to {healthlist::*}




every tick:
	Loop all players:
		set loop-player's max health to 10
		loop {healthlist::*}:
			add {%uuid of loop-player% %loop-value-2%} to loop-player's max health
		
		

This allows me to have multiple skripts that will change the players health without any of them conflicting eachother

theres probably a better way to achieve this and this might have a few issues but this is all I have for now

Personally I'd be careful with "every tick:" because it can lag the server a lot.

1 Tick is 1/20th of a second which means you're looping every player on your server about 20 times a second if you have 10 players on that would already be 200 per one second just fyi.

tumblr_lqahoaPLkC1ql1l0v.gif

Feel free to add me on discord if you:

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need help with plugins

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need help with skripts

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need to vent about something

tumblr_lqahoaPLkC1ql1l0v.gif

>[ ‧₊˚꒰ʚ Starshine ɞ ‧✦ *#2683 ]<

Link to comment
Share on other sites

14 hours ago, StarBunnie said:

Personally I'd be careful with "every tick:" because it can lag the server a lot.

1 Tick is 1/20th of a second which means you're looping every player on your server about 20 times a second if you have 10 players on that would already be 200 per one second just fyi.

so would it be better every second?

if you can see this, you have vision

Link to comment
Share on other sites

6 minutes ago, PixelTrainerYT said:

so would it be better every second?

It would definitely take less performance you could also use something called a while loop

on join:
 while player is online:
  set player's max health to 10
  add {health::%player's uuid%} to player's max health
  wait 1 second
  
command /health [<offlineplayer>] [<integer>]:
 trigger:
  player has permission "health.set":
   if arg 1 is set:
    if arg 2 is set:
     set {health::%arg 1's uuid%} to arg 2

With a while loop it's very important to add a wait otherwise it will crash your server.

Edited by StarBunnie

tumblr_lqahoaPLkC1ql1l0v.gif

Feel free to add me on discord if you:

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need help with plugins

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need help with skripts

dc3456c-e0ec58e8-c807-43e3-b986-5224b91a need to vent about something

tumblr_lqahoaPLkC1ql1l0v.gif

>[ ‧₊˚꒰ʚ Starshine ɞ ‧✦ *#2683 ]<

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...