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 Knocked into the void by player?

Discussion in 'Skript' started by Adrihun, May 27, 2017.

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

    Adrihun Member

    Joined:
    Feb 1, 2017
    Messages:
    368
    Likes Received:
    6
    I'm trying to make a script that will make it so if i knock a player into the void, they'll die, and it will say in chat knocked the player into the void. But it doesn't work.

    What am I doing wrong?

    Code (Skript):
    1. on damage:
    2.     if attacker is a player:
    3.         set {deadFall.%victim%} to true
    4.         wait 3 seconds
    5.         delete {deadFall.%victim%}
    6.  
    7. on death of player:
    8.     if damage was caused by void:
    9.         if {deadFall.%victim%} is true:
    10.             set the death message to "%victim% was knocked into the void by %attacker%"
    11.         else:
    12.             set the death message to "%victim% died in the void"
     
    #1 Adrihun, May 27, 2017
    Last edited: May 27, 2017
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    You can use TuSKe's expression :
    Code (Skript):
    1. last attacker of %entity%
    2. %entity%'[s] last attacker
    (Don't count on me to spoonfeed you)
     
    • Agree Agree x 1
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    maybe you need raise the wait seconds... or just check if player getting damage by voids then kill him and check if varaibles is true, then say is knocked, else void
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Your code will never work as it is.
    You are setting "on damage" a variable to "true".

    How the skript will know in the "on death" event who was the attacker?
    you need to set the {deadFall.%victim%} to "%attacker%." to use it later in the death of player by void:

    Somethink like this:

    Code (Skript):
    1.     on damage:
    2.         if attacker is a player:
    3.             if {deadFall.%victim%} = %attacker%:
    4.                 stop
    5.             set {deadFall.%victim%} to "%attacker%"
    6.             wait 30 seconds
    7.             clear {deadFall.%victim%}
    8.             stop
    9.         if {deadFall.%victim%} is set: #if anyone else than a player hits you
    10.             clear {deadFall.%victim%} #delete the variable
    11.  
    12.     on death of player:
    13.         if damage was caused by void:
    14.             if {deadFall.%victim%} is set:
    15.                 set the death message to "%victim% was knocked into the void by %{deadFall.%victim%}%"
    16.             else:
    17.                 set the death message to "%victim% died in the void"
    18.  
    I don't know if "on death of player" there's a victim. If this wont work, change my code on the "on death of player" part from %victim% to %event-player%.

    i think you should already know how to do something as simple as this, just saying.
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Using waits is unreliable as all living hell
    --- Double Post Merged, May 27, 2017, Original Post Date: May 27, 2017 ---
    The player could fall into the void again (not being knocked this time) when the variable isn't deleted yet
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Just add "clear {deadFall.%victim%}" on death event.
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Code (Skript):
    1. on death of player:
    2.     if last damage cause of victim is void:
    3.         set death message to (last attacker of victim's type != player ? "%victim% was knocked into the void by %last attacker of victim%" : "%victim% died in the void")
     
    • Winner Winner x 1
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Talking about efficiency...
     
    • Agree Agree x 1
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    its {deadFall.%victim%} = "%attacker%" not %attacker%"
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    In case anyone is interested how this line:
    Code (Skript):
    1. set death message to (last attacker of victim's type != player ? "%victim% was knocked into the void by %last attacker of victim%" : "%victim% died in the void")
    works, it is called called an IIF (in SkQuery) or a ternary/conditional operator (pretty much everywhere else) and the syntax is:
    Code (Skript):
    1. %boolean%[ ]?[ ]%object%[ ]:[ ]%object%
    which basically looks like:
    Code (Skript):
    1. condition ? true : false
    where condition is the condition, true is the object(s) returned if the condition is true and false if the object(s) returned if the condition if false.
    Here's a simple example:
    Code (Skript):
    1. set {_number} to a random integer from 1 to 2
    2. broadcast ({_number} == 1 ? "{_number} is 1" : "{_number} is 2")
    To use it with standard skript conditions without skquery equality checkers (==, !=, ===, etc) you'll probably need to use skquery's check syntax:
    Code (Skript):
    1. check[ed] %predicate%
    like so
    Code (Skript):
    1. on join:
    2.   broadcast (check [player's helmet is air] ? "%player% doesn't have a helmet on!" : "%player% has a helmet on")
     
    • Like Like x 3
Thread Status:
Not open for further replies.

Share This Page

Loading...