Solved Knocked into the void by player?

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

Status
Not open for further replies.

Adrihun

Member
Feb 1, 2017
368
6
0
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_language.skript:
on damage:
    if attacker is a player:
        set {deadFall.%victim%} to true
        wait 3 seconds
        delete {deadFall.%victim%}

on death of player:
    if damage was caused by void:
        if {deadFall.%victim%} is true:
            set the death message to "%victim% was knocked into the void by %attacker%"
        else:
            set the death message to "%victim% died in the void"
 
Last edited:
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
 
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_language.skript:
    on damage:
        if attacker is a player:
            if {deadFall.%victim%} = %attacker%:
                stop
            set {deadFall.%victim%} to "%attacker%"
            wait 30 seconds
            clear {deadFall.%victim%}
            stop
        if {deadFall.%victim%} is set: #if anyone else than a player hits you
            clear {deadFall.%victim%} #delete the variable
  
    on death of player:
        if damage was caused by void:
            if {deadFall.%victim%} is set:
                set the death message to "%victim% was knocked into the void by %{deadFall.%victim%}%"
            else:
                set the death message to "%victim% died in the void"

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.
 
Using waits is unreliable as all living hell
[doublepost=1495908964,1495908928][/doublepost]The player could fall into the void again (not being knocked this time) when the variable isn't deleted yet
 
Using waits is unreliable as all living hell
[doublepost=1495908964,1495908928][/doublepost]The player could fall into the void again (not being knocked this time) when the variable isn't deleted yet
Just add "clear {deadFall.%victim%}" on death event.
 
code_language.skript:
on death of player:
    if last damage cause of victim is void:
        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")
 
code_language.skript:
on death of player:
    if last damage cause of victim is void:
        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")
Talking about efficiency...
 
code_language.skript:
on death of player:
    if last damage cause of victim is void:
        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")
In case anyone is interested how this line:
code_language.skript:
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_language.skript:
%boolean%[ ]?[ ]%object%[ ]:[ ]%object%
which basically looks like:
code_language.skript:
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_language.skript:
set {_number} to a random integer from 1 to 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_language.skript:
check[ed] %predicate%
like so
code_language.skript:
on join:
  broadcast (check [player's helmet is air] ? "%player% doesn't have a helmet on!" : "%player% has a helmet on")
 
Status
Not open for further replies.