i dont even know

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

completeidiot

Member
May 5, 2024
40
1
8
19
so im trying to make a damage reduction script, heres the code:

Code:
on join:
  if {res::%player's uuid%} is not set:
    set {res::%player's uuid%} to 0

on damage:
  if {res::%victim's uuid%} is greater than 0:
    reduce damage by {res::%victim's uuid%}

command setres [<player>] <integer>:
  permission: op
  trigger:
    if arg-1 is set:
      set {res::%arg-1's uuid%} to arg-2
    if arg-1 is not set:
      set {res::%player's uuid%} to arg-2

on join:
  while player is online:
    set title of player's scoreboard to "&aBurvival But &dBetter"
    set line 1 of player's scoreboard to "&fPlayer: &6%player%"
    set line 2 of player's scoreboard to "&7Server Ip: &8burvivalbutbetter.feathermc.gg"
    set line 3 of player's scoreboard to "&cDamage Resistance: &9%{res::%player's uuid%}%"
    wait 1 second

the scoreboard works fine, same with the command, its the damage reduction part, i have tried like 50 different iterations, i set it back to this one to make it easier to understand and post here, it reduces damage by a flat number, not a percentage, how do i like add a percentage after the variable or smth to fix it idk how to explain
 
so im trying to make a damage reduction script, heres the code:

Code:
on join:
  if {res::%player's uuid%} is not set:
    set {res::%player's uuid%} to 0

on damage:
  if {res::%victim's uuid%} is greater than 0:
    reduce damage by {res::%victim's uuid%}

command setres [<player>] <integer>:
  permission: op
  trigger:
    if arg-1 is set:
      set {res::%arg-1's uuid%} to arg-2
    if arg-1 is not set:
      set {res::%player's uuid%} to arg-2

on join:
  while player is online:
    set title of player's scoreboard to "&aBurvival But &dBetter"
    set line 1 of player's scoreboard to "&fPlayer: &6%player%"
    set line 2 of player's scoreboard to "&7Server Ip: &8burvivalbutbetter.feathermc.gg"
    set line 3 of player's scoreboard to "&cDamage Resistance: &9%{res::%player's uuid%}%"
    wait 1 second

the scoreboard works fine, same with the command, its the damage reduction part, i have tried like 50 different iterations, i set it back to this one to make it easier to understand and post here, it reduces damage by a flat number, not a percentage, how do i like add a percentage after the variable or smth to fix it idk how to explain
You'll need to do a bit of math in order to reduce damage to a percent. Because it would be a tad tricky to do a specific percent removal of the damage (With only percents), I'll go over a different solution. Let's say you want to reduce the damage for the player by 40%. Since we can't use 40%, we'll move the decimal over a couple places to make it something you can use (In this case, 0.40). Now that you have that number, simply multiply 0.40 by the total damage and it'll be reduced by the desired 40%.