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 Get the attacker of a tnt

Discussion in 'Skript' started by KroterPvP, Mar 27, 2018.

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

    KroterPvP Active Member

    Joined:
    Apr 10, 2017
    Messages:
    178
    Likes Received:
    7
    I'm having troubles when getting the attacker in my skript. I will explain it a bit. The script spawns a primed tnt and sometimes the player gets killed by it. The problem is that skript doesn't know who was the person who killed the player (I'm trying to know who placed the tnt storing it in a variable but I can't do it).
    Code (Skript):
    1. on rightclick with tnt:
    2.     name of player's tool is "&eTNT &7(Click derecho)":
    3.         clicked block is not air:
    4.             if "%region at player%" contains "lobby":
    5.                 stop
    6.             else:
    7.                 set {tntof::%player%} to player
    8.                 send "%{tntof::%player%}%" to player
    9.                 set {_block.loc} to block 1 up event-location
    10.                 if block at {_block.loc} is air:
    11.                     remove 1 tnt from player's inventory
    12.                     spawn 1 primed TNT at location of {_block.loc}
    13.                     set fuse time of last spawned primed tnt to 60
    14.                 else:
    15.                     send "&7Busca espacio en el suelo para utilizar explosivos"
    16.         else:
    17.             send "&7Mira al suelo para utilizar explosivos"
    18. on damage:
    19. #The problem is that using attacker here will not be 100%
    20. #efficient because It will be refired to the last player who
    21. #hitted victim and not the player who placed the tnt.
    22.     if {tntof::%attacker%} is set:
    23.         #do stuff
    - No console errors.
    - Skript 2.2 Bensku dev24, SkRayFall, QkQuery, Skellet (I'm using them for other skripts, not for this one).

    Thanks
     
    #1 KroterPvP, Mar 27, 2018
    Last edited: Mar 27, 2018
  2. Best Answer:
    Post #2 by AsuDev, Mar 27, 2018
  3. AsuDev

    VIP

    Joined:
    Jan 27, 2017
    Messages:
    243
    Likes Received:
    21
    I do not know if this will work, but you can try:

    Code (Skript):
    1.  
    2. remove 1 of tnt from player's inventory
    3. spawn 1 primed TNT at location of {_block.loc}
    4. set metadata value "attacker" of last spawned primed tnt to "%player%"
    5. set fuse time of last spawned primed tnt to 60
    6.  
    7. #something along these lines
    8. on damage:
    9.     set {_attacker} to metadata value "attacker" of attacker
    10.     set {_attacker} to {_attacker} parsed as player
    11.  
     
  4. KroterPvP

    KroterPvP Active Member

    Joined:
    Apr 10, 2017
    Messages:
    178
    Likes Received:
    7
    Yep, it's running :emoji_slight_smile:

    Thanks
     
  5. Peivi

    Peivi Member

    Joined:
    Jan 28, 2018
    Messages:
    25
    Likes Received:
    0
    Please put this as solved skript :emoji_stuck_out_tongue:

    Rhanks

    -Peivi
     
Thread Status:
Not open for further replies.

Share This Page

Loading...