Linking Lightning to 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.

Juan_010

New Member
Jun 22, 2018
7
0
0
23
So I made a skript where players with the permission "kb.thor" can right click with a golden axe and it strikes lighting at where they're looking. However, I would like to give them money when they kill players with that ability. Is there a way to link the attacker to that lightning?
 
code_language.skript:
on right click on golden axe:
    if player has permission "kb.thor":
        set {linked::%player%} to true
        wait 10 ticks
        set {linked::%player%} to false
 
on death of player:
    if {linked::%attacker%} = true:
       add 10 to balance of attacker
 
code_language.skript:
on right click on golden axe:
    if player has permission "kb.thor":
        set {linked::%player%} to true
        wait 10 ticks
        set {linked::%player%} to false
 
on death of player:
    if {linked::%attacker%} = true:
       add 10 to balance of attacker
I don’t see how that would work, since the player doesn’t directly attack a player when it dies, it strikes lightning at the other player, so there’s not an attacker
 
Can you send your current Skript?
 
I don’t have access to it right now but it goes like this
code_language.skript:
#Thor Section
on right click:
  if player’s tool is a golden axe:
    strike lightning at the targeted block
#Kill Section
on death:
  if attacker is a player:
    if victim is a player:
      add 10 to attacker’s account
 
this probably is the BEST way to hand this, but this works.
A problem here would be, is if multiple players were doing this same action at the same time
code_language.skript:
on right click:
    if player's tool is a golden axe:
        if player has permission "kb.thor":
            set {linked::attacker} to player
            strike lightning at targeted block
            wait 1 second
            delete {linked::attacker}

on death of player:
    if {linked::attacker} is set:
        add 10 to balance of {linked::attacker}
 
code_language.skript:
on right click on golden axe:
    if player has permission "kb.thor":
        set {linked::%player%} to true
        wait 10 ticks
        set {linked::%player%} to false
 
on death of player:
    if {linked::%attacker%} = true:
       add 10 to balance of attacker
I like this one. However, I think when players die, it would trigger this. So, let’s say a Thor Player strikes lightning to someone, and then a completely different player dies from lava, it would count as their kill, since a player died while they were set as linked. I think I’m better off changing Thor’s behavior completely, so it strikes lightning when they actually hit a player.
 
Status
Not open for further replies.