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 our 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 Knockback Problem (not working)

Discussion in 'Skript' started by D0XY, Jul 17, 2018.

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

    D0XY Active Member

    Joined:
    May 4, 2018
    Messages:
    35
    Likes Received:
    0
    Using Skript on 1.8.9 with no add-ons. Would like to keep it this way.

    Code (Skript):
    1. on leftclick:
    2.     if player’s target is a player;
    3.         if {reach.%player%} is true:
    4.             set {_loc} to location of player’s target
    5.             set {_dis} to distance between player and {_loc}
    6.             if {_dis} > 3:
    7.                 damage player’s target by 1
    8.                 push player’s target upwards with force 0.5
    ^^^
    This is a bit simpler version of the code since I’m trying to recall it all from memory (I’m using my phone atm)

    No errors.


    Problem:

    The damage part works, but it doesn’t push the target.
     
  2. Uzumaki

    Uzumaki Well-Known Member

    Joined:
    Feb 20, 2017
    Messages:
    290
    Likes Received:
    8
    Code (Skript):
    1. on damage of player:
    2.     if {reach.%attacker%} is true:
    3.         if distance between attacker and victim > 3:
    4.             damage attacker by 1
    5.             push attacker upwards with force 0.5
     
    • Agree Agree x 1
  3. D0XY

    D0XY Active Member

    Joined:
    May 4, 2018
    Messages:
    35
    Likes Received:
    0
    That would only work if the victim was already attacked...
     
  4. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,358
    Likes Received:
    85
    Medals:
    On damage is called when the victim is damaged (also when another plugin / minecraft cancels it)
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    157
    try this, I dont have a player on my test server to test with, so i tested with my trusty sheep, and it works
    Code (Skript):
    1. on leftclick:
    2.     if target is a player:
    3.         if {reach.%player%} is true:
    4.             set {_loc} to location of target
    5.             set {_dis} to distance between player and {_loc}
    6.             if {_dis} > 3:
    7.                 damage target by 1
    8.                 push target upwards with force 0.5
     
  6. D0XY

    D0XY Active Member

    Joined:
    May 4, 2018
    Messages:
    35
    Likes Received:
    0
    how dare you

    anyway i'll try it out, thanks

    I know, but if the player is more than 3 blocks away, the player cannot damage the other player. That's why I used on leftclick
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    157
    I mean if it works with sheep it should work with players
     
  8. D0XY

    D0XY Active Member

    Joined:
    May 4, 2018
    Messages:
    35
    Likes Received:
    0
    Also, there's "if target is a player" so it shouldn't work with a sheep.

    Still, not working.

    EDIT #1:

    I was going to test it with a Zombie, and when I removed "if target is a player" it worked. Strange ;/

    anyway thx lol

    EDIT #2:

    yeah, it was working, and then all the sudden it stopped working.

    it still damages the player, but the knockback is only working for mobs now

    EDIT #3:

    it started working again, after a zombie attacked my alt. really strange bug

    EDIT #4:

    and it stopped working again after i went in creative and back.

    EDIT #5: (idk why im editing so much lol)

    found out the culprit. pretty sure it's /tpall. after i let the zombies attack me and my alt, the knockback worked. i went in gmc and tried it, still worked. i did /tpall, and it stopped working

    EDIT #6:

    actually, i found the actual culprit. when i hit the player from under 3 blocks, it stops the knockback even after i go 3 or more blocks away

    EDIT #7:

    the zombie tactic stopped working, still not dealing knockback to players
     
    #8 D0XY, Jul 18, 2018
    Last edited: Jul 18, 2018
  9. TPGamesNL

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,358
    Likes Received:
    85
    Medals:
    That's a lot of edits
    --- Double Post Merged, Jul 18, 2018, Original Post Date: Jul 18, 2018 ---
    But for the thread, try parsing the target (if it's a player) as an entity or player. Also try broadcasting the target, for debugging purposes
     
  10. D0XY

    D0XY Active Member

    Joined:
    May 4, 2018
    Messages:
    35
    Likes Received:
    0
    Actually, this would work. Thanks for the help lol
     
Thread Status:
Not open for further replies.
Loading...