• 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.
Instead of using a periodical to remove 1 from the variable, just do it in the "on damage" event.


code_language.skript:
loop 10 times:
    wait 1 second
    remove 1 from {qal::%victim%}
    remove 1 from {qal::%attacker%}

Just add something like that, but do a check so that if the on damage is triggered again, it doesn't continue running that loop and restarts it.
 
Someone made me a simple script that makes it if you log out, then log back in, you will die (when you are in combat)

Is there a way to change the script since i don't want 'every second' on my server, because it will lag if there are a lot of players and i don't want the plugin to check 30-70 players every second.

UPDATE: Here is my script
code_language.skript:
every second:
    loop all players:
        if {qal::%loop-player%} is bigger than 0:
            remove 1 from {qal::%loop-player%}
        if {qal::%loop-player%} is 0:
            set {qal::%loop-player%} to -1
            stop

on death:
    set {qal::%victim%} to 0
    set {qal::%attacker%} to 0
         
on damage:
    if victim is a player:
        if attacker is a player:
            set {qal::%victim%} to 10
            set {qal::%attacker%} to 10
            if {victim::%attacker%} is not set:
                set {victim::%attacker%} to "%victim%"
                stop
            else:
                if {victim::%attacker%} is not "%victim%":
                    set {victim::%attacker%} to "%victim%"
                    stop
         
on quit:
    if {qal::%player%} is bigger than 0:
        kill player
       
on command "/spawn":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/home":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/hub":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/lobby":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/back":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
It really doesn't lag, I've had 45 people on a server looping all of them more than once a second, and I managed around 19.85 TPS on a non dedicated server. I wouldn't worry about it.
 
Someone made me a simple script that makes it if you log out, then log back in, you will die (when you are in combat)

Is there a way to change the script since i don't want 'every second' on my server, because it will lag if there are a lot of players and i don't want the plugin to check 30-70 players every second.

UPDATE: Here is my script
code_language.skript:
every second:
    loop all players:
        if {qal::%loop-player%} is bigger than 0:
            remove 1 from {qal::%loop-player%}
        if {qal::%loop-player%} is 0:
            set {qal::%loop-player%} to -1
            stop

on death:
    set {qal::%victim%} to 0
    set {qal::%attacker%} to 0
         
on damage:
    if victim is a player:
        if attacker is a player:
            set {qal::%victim%} to 10
            set {qal::%attacker%} to 10
            if {victim::%attacker%} is not set:
                set {victim::%attacker%} to "%victim%"
                stop
            else:
                if {victim::%attacker%} is not "%victim%":
                    set {victim::%attacker%} to "%victim%"
                    stop
         
on quit:
    if {qal::%player%} is bigger than 0:
        kill player
       
on command "/spawn":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/home":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/hub":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/lobby":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/back":
    if {qal::%player%} is bigger than 0:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
You can fix your issue by using the Skript expression: "difference (between|of) %object% and %object%", it basically checks the difference between two values.


code_language.skript:
on damage:
    if victim is a player:
        if attacker is a player:
            set {qal::%victim%} to now
            set {qal::%attacker%} to now
            if {victim::%attacker%} is not set:
                set {victim::%attacker%} to "%victim%"
                stop
            else:
                if {victim::%attacker%} is not "%victim%":
                    set {victim::%attacker%} to "%victim%"
                    stop
on quit:
    if difference between {qal::%player%} and now is less than 10 seconds:
        kill player
       
on command "/spawn":
    if difference between {qal::%player%} and now is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/home":
    if difference between {qal::%player%} and now is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/hub":
    if difference between {qal::%player%} and now is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/lobby":
    if difference between {qal::%player%} and now is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
       
on command "/back":
    if difference between {qal::%player%} and now is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event
 
Here's a more efficient form of the script:

code_language.skript:
on death:
    clear {qal::%victim%}
    clear {qal::%attacker%} #You may want to remove this line to accommodate for PvP w/ more than 2 players

on damage:
    if victim is a player:
        if attacker is a player:
            set {qal::%victim%} to now #This is now a time variable, which will make this script much more efficient
            set {qal::%attacker%} to now #This is also a time var now
            if {victim::%attacker%} is not set:
                set {victim::%attacker%} to victim #This can just be 'victim' rather than '"%victim%"'
                stop
            else:
                if {victim::%attacker%} is not victim:
                    set {victim::%attacker%} to victim
                    stop

on quit:
    if difference between now and {qal::%player%} is less than 10 seconds: #Changed since we're using a time var now
        kill player

on command "/spawn":
    if difference between now and {qal::%player%} is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event

on command "/home":
    if difference between now and {qal::%player%} is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event

on command "/hub":
    if difference between now and {qal::%player%} is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event

on command "/lobby":
    if difference between now and {qal::%player%} is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event

on command "/back":
    if difference between now and {qal::%player%} is less than 10 seconds:
        message "&cYou are currently in combat and can't execute that command."
        cancel event

on login:
    if difference between now and {qal::%player%} is greater than 10 seconds:
        clear {qal::%player%} #Clears the unnecessary stored value
[doublepost=1488219386,1488219089][/doublepost]
You can fix your issue by using the Skript expression: "difference (between|of) %object% and %object%", it basically checks the difference between two values.

Jinx!
 
Thanks guys
[doublepost=1488219683][/doublepost]
So i just remove ' clear {qal::%attacker%}' on line 4 and thats it? :emoji_slight_smile:
[doublepost=1488219741][/doublepost]
Alright, thanks. Some people in the Spigot forums about a month ago said Skript was the worst plugin and it used all of their server Ram etc...
[doublepost=1488220355][/doublepost]
UPDATE:
[18:31:59 WARN]: [Skript] an entity cannot be saved, i.e. the contents of the variable {victim::%the attacker%} will be lost when the server stops. (Combat.sk, line 16: set {victim::%attacker%} to victim#This can just be 'victim' rather than '"%victim%"'')
[18:31:59 WARN]: [Skript] an entity cannot be saved, i.e. the contents of the variable {victim::%the attacker%} will be lost when the server stops. (Combat.sk, line 20: set {victim::%attacker%} to victim')
[doublepost=1488223607][/doublepost]
bump
you posted like 20 mins ago, don't bump...
 
Thanks guys
[doublepost=1488219683][/doublepost]
So i just remove ' clear {qal::%attacker%}' on line 4 and thats it? :emoji_slight_smile:
[doublepost=1488219741][/doublepost]
Alright, thanks. Some people in the Spigot forums about a month ago said Skript was the worst plugin and it used all of their server Ram etc...
[doublepost=1488220355][/doublepost]
UPDATE:
[18:31:59 WARN]: [Skript] an entity cannot be saved, i.e. the contents of the variable {victim::%the attacker%} will be lost when the server stops. (Combat.sk, line 16: set {victim::%attacker%} to victim#This can just be 'victim' rather than '"%victim%"'')
[18:31:59 WARN]: [Skript] an entity cannot be saved, i.e. the contents of the variable {victim::%the attacker%} will be lost when the server stops. (Combat.sk, line 20: set {victim::%attacker%} to victim')
[doublepost=1488223607][/doublepost]
bump


Yep, remove the "clear {qal::%attacker%}" if you don't want players to get unflagged right after killing someone. That way, that can't kill one player to escape another. But that also means they'll have to wait 10 seconds after killing someone to do anything, so your call.

I don't think those entity errors will be problem since you'd want the PvP vars to reset after a restart anyway. But if it does cause issues, set the vars to 'uuid of victim' instead, as that will be saved through a restart.
 
Alright i removed the thing that you said but when i start the server it says that error message, is there a way to remove it?
[doublepost=1488231363,1488231304][/doublepost]
Its okay if they reset but i just wanna remove those error messages in console at start :emoji_slight_smile:
[doublepost=1488232195][/doublepost]
is there a way to remove that error message at the start -- it is really annoying lol "___"

Nah, there isn't any way as far as I'm aware.
 
Status
Not open for further replies.