Solved PvP TempDisabler

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

Brinnare

Member
Nov 2, 2021
4
0
1
24
I want a skript that disables pvp for a certain player for a certain amount of seconds. Like the player that was mentioned will not be able to hit anyone that's what I mean, but can get hit.
[doublepost=1636623861,1636623178][/doublepost]Like a command /StopHitEventForPlayer [player] [seconds]
 
I want a skript that disables pvp for a certain player for a certain amount of seconds. Like the player that was mentioned will not be able to hit anyone that's what I mean, but can get hit.
[doublepost=1636623861,1636623178][/doublepost]Like a command /StopHitEventForPlayer [player] [seconds]
Code:
command /disablepvp <player> [<timespan=10 seconds>]:
    permission: pvp.disable
    trigger:
        set {pvp::disabled::%arg-1's uuid%} to arg-2 from now
        send "&aPvP is now disabled for &e%arg-2%!" to arg-1
        send "&aDisabled &e%arg-1%'s &aPvP for &e%arg-2%!" to player

on damage of player:
    attacker is a player
    if difference between now and {pvp::disabled::%victim's uuid%} >= 1 seconds:
        cancel event
        send "&cYou can't damage this player" to attacker
    else:
        delete {pvp::disabled::%victim's uuid%}
Something like that should work
 
It's working but in reverse. It's making the arg-1 in the command unable to get hit and can hit. I want it to make the arg-1 unable to hit but is able to get hit
[doublepost=1636732932,1636732777][/doublepost]Like when I type /disablepvp Brinnare, it gives god mode to Brinnare and he can hit others
[doublepost=1636733045][/doublepost]
Code:
command /disablepvp <player> [<timespan=10 seconds>]:
    permission: pvp.disable
    trigger:
        set {pvp::disabled::%arg-1's uuid%} to arg-2 from now
        send "&aPvP is now disabled for &e%arg-2%!" to arg-1
        send "&aDisabled &e%arg-1%'s &aPvP for &e%arg-2%!" to player

on damage of player:
    attacker is a player
    if difference between now and {pvp::disabled::%victim's uuid%} >= 1 seconds:
        cancel event
        send "&cYou can't damage this player" to attacker
    else:
        delete {pvp::disabled::%victim's uuid%}
Something like that should work
Like when I type /disablepvp Brinnare, it gives god mode to Brinnare and he can hit others
[doublepost=1636733300][/doublepost]Thank you I fixed it by editing the code a bit:


command /disablepvp <player> [<timespan=10 seconds>]:
permission: pvp.disable
trigger:
set {pvp::disabled::%arg-1%} to arg-2 from now
send "&aPvP is now disabled for &e%arg-2%!" to arg-1
send "&aDisabled &e%arg-1%'s &aPvP for &e%arg-2%!" to player

on damage of player:
attacker is a player
if difference between now and {pvp::disabled::%attacker%} >= 1 seconds:
cancel event
send "&cYou can't damage this player" to attacker
else:
delete {pvp::disabled::%attacker%}