1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Help me plz

Discussion in 'Help' started by DragonDeveloper, Sep 8, 2020.

  1. DragonDeveloper

    DragonDeveloper Creeper

    Messages:
    4
    I want to make it so that when BOTH players hit each other, then the action below occurs, but, for some reason, when 1 player hits, then the action is performed for both of them (2 player did not even hit). How to make sure that when BOTH players hit each other then the action below occurs? I will be grateful.
     

    Attached Files:

  2. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    Make a $last_player_hit variable for each player and save the name of the player which the player hits on EntityDamageEvent, then just check if both players have hit each other during the last 0,2 seconds or similar.
     
    Primus likes this.
  3. DragonDeveloper

    DragonDeveloper Creeper

    Messages:
    4
    Could you send me the code? I will be grateful.
     
  4. Provsnoobgaming

    Provsnoobgaming Baby Zombie

    Messages:
    134
    GitHub:
    provsalt
    No one will be willing to spoonfeed you. He has already described how it's done. Do your own research on how you could write that in your own code.
     
    Diduhless and Primus like this.
  5. Primus

    Primus Zombie Pigman

    Messages:
    749
    Or if time is not important, you could get the damager's last damage cause and perform checks to see if the entity getting damaged now, was the entity who damaged him previously.
     
  6. Diduhless

    Diduhless Baby Zombie

    Messages:
    199
    GitHub:
    Diduhless
    I just reread this again, and you're entirely right, the last damage cause damager is already saved so there's no need to create new variables
     
    Primus likes this.
  7. DragonDeveloper

    DragonDeveloper Creeper

    Messages:
    4
    Can you please tell me in more detail what I need to do? The code is not needed, you can only throw off the principle of operation. Thank.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.