1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Possible to set a damage cause?

Discussion in 'Skript' started by pepper82, Mar 2, 2017.

Thread Status:
Not open for further replies.
  1. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    272
    Likes Received:
    1
    I use "damage player by X" in several scripts. The damage cause is always "UNKNOWN" of course. SO I wonder if there is a way to set the damage cause?

    Example:
    damage player by 5
    set damage cause to "MyCustomDamageCause"

    on damage:
    if damage cause is "MyCustomDamageCause" ....

     
  2. Best Answer:
    Post #5 by ShaneBee, Mar 2, 2017
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Maybe damage cause is unchangeable.... ;(
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    I don't think you can change it. What you could do though is set a variable beforehand. Just remember to not use any waits or you could have problems.

    Code (Skript):
    1.         ...
    2.         set metadata value "damagesource" of player to "A Trap"
    3.         damage player by 5
    4.        
    5. on damage:
    6.     set {_source} to metadata value "damagesource" of attacked
    7.     delete metadata value "damagesource" of attacked
    8.     if {_source} is "A Trap":
    9.         apply wither 1 to the attacked for 5 seconds
     
    • Like Like x 1
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Good idea! Metadata is reset on server restart, right?
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Yes. I use it instead of variables when in cases like these.
     
    • Agree Agree x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...