pvp leaving

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

Ter2FIc

Member
Dec 30, 2020
20
0
1
24
Trying to make a code that kills the player who disconnected on pvp...
Code:
on damage:
    set {damage.%victim%} to true
    set {player'soldhealth.%victim%} to victim's health
    wait 5 seconds
    if {player'soldhealth.%victim%} = victim's health:
        set {damage.%victim%} to false

on leave:
    if {damage.%player%} is true:
        set {death.%player%} to true

on join:
    if {death.%player%} is true:
        kill player
 
It's not very efficient because of the every 1 second, but it does it job.. Hopefully
Code:
on damage of player:
    if attacker is a player:
        if {combattag::%attacker%} is not set:
            send "you are in combat dont log out" to attacker
        if {combattag::%victim%} is not set:
            send "you are in combat dont log out" to victim
        set {combattag::%attacker%} to now
        set {combattag::%victim%} to now
        
        
on death of player:
    if attacker is a player:
        delete {combattag::%victim%}
        delete {combattag::%attacker%}
        send "you are no longer in combat" to attacker
        send "you are no longer in combat" to victim
        
on quit:
    if {combattag::%player%} is set:
        delete {combattag::%player%}
        kill player
        
every 1 second:
    loop all players:
        if {combattag::%loop-player%} is set:
            if difference between now and {combattag::%loop-player%} is more than 9.9 seconds:
                delete {combattag::%loop-player%}
                send "you are no longer in combat" to loop-player
                send action bar "" to loop-player
            else:
                set {_x} to difference between now and {combattag::%loop-player%}
                set {_xx} to "%{_x}%"
                replace all "seconds" with "" in {_xx}
                set {_f1::*} to split {_xx} at "."
                set {_rem} to {_f1::1} parsed as a integer
                set {_final} to 10 - {_rem}
                send action bar "you are still in the fight for %{_final}% seconds" to loop-player
 
Status
Not open for further replies.