Solved Cancel PVP

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

    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.

Ariuw

Member
Sep 6, 2017
42
1
8
Hello. I want to cancel the pvp event if the player is on the same team as other player.

This is my code:

Code:
command /red:
    trigger:
        if {ir.red.%player%} is false:
            if {ir.red} < 8:
                if {ir.red.%player%}:
                    add -1 to {ir.bluee}
                    add 1 to {ir.red}
                set {ir.red.%player%} to true
                set {ir.bluee.%player%} to false
                message "&7You have joined the &cRed &7team"
                set player's tab list name to "&c%player%"

But I've tried to set up it like this and doesn't work:

Code:
on damage:
    if {ir.red::%victim%} is "%{ir.red::%attacker%}%":
        cancel event
        send "&cYou can't hurt your teammates!" to attacker

Does some of yo know how to fix this?
 
remove "%%" from around your variable, that should fix it
 
Okay I think i found your issue
IN your command your variable is set like this = {ir.red.%player%}
in your event, its set like this = {ir.red::%victim%} <--- this one is a list variable
so they are two totally different variables
 
Okay I think i found your issue
IN your command your variable is set like this = {ir.red.%player%}
in your event, its set like this = {ir.red::%victim%} <--- this one is a list variable
so they are two totally different variables
What should I do then? change the variable or what?
 
correct, make them both list variables, or both non list variables... i personally recommend list variables, so replace all the periods in your variables with double colon ::
 
correct, make them both list variables, or both non list variables... i personally recommend list variables, so replace all the periods in your variables with double colon ::
Oh man. I'd love if you can help me with that since I am pretty bad with Skript :S but It's okay if you don't want to wast your time
 
its actually really easy to do,, if you... post your skript here, and ill fix it, and post it back
 
its actually really easy to do,, if you... post your skript here, and ill fix it, and post it back

Yeah sure there you go:

Code:
command /red:
    trigger:
        if {ir.red.%player%} is false:
            if {ir.red} < 8:
                if {ir.red.%player%}:
                    add -1 to {ir.bluee}
                    add 1 to {ir.red}
                set {ir.red.%player%} to true
                set {ir.bluee.%player%} to false
                message "&7You have joined the &cRed &7team"
                set player's tab list name to "&c%player%"
            else:
                message "&7Team full!"
        else:
            message "&7You are already in the &cRed &7team."
          
command /blue:
    trigger:
        if {ir.bluee.%player%} is false:
            if {ir.bluee} < 8:
                if {ir.red.%player%}:
                    add -1 to {ir.red}
                    add 1 to {ir.bluee}
                set {ir.bluee.%player%} to true
                set {ir.red.%player%} to false
                message "&7You have joined the &1Blue &7team"
                set player's tab list name to "&1%player%"
            else:
                message "&7Team full!"
        else:
            message "&7You are already in the &1Blue &7team."
          
on damage:
    if {ir.red::victim} is "{ir.red::attacker}":
        cancel event
        send "&cYou can't hurt your teammates!" to attacker

on damage:
    if {ir.bluee::victim} is "{ir.bluee::attacker}":
        cancel event
        send "&cYou can't hurt your teammates!" to attacker

That's it there's no more code lol
 
Okay this should do the trick
code_language.skript:
command /red:
    trigger:
        if {ir::red::%player%} is false:
            if {ir::red} < 8:
                if {ir::red::%player%}:
                    add -1 to {ir::bluee}
                    add 1 to {ir::red}
                set {ir::red::%player%} to true
                set {ir::bluee::%player%} to false
                message "&7You have joined the &cRed &7team"
                set player's tab list name to "&c%player%"
            else:
                message "&7Team full!"
        else:
            message "&7You are already in the &cRed &7team."
          
command /blue:
    trigger:
        if {ir::bluee::%player%} is false:
            if {ir::bluee} < 8:
                if {ir::red::%player%}:
                    add -1 to {ir::red}
                    add 1 to {ir::bluee}
                set {ir::bluee::%player%} to true
                set {ir::red::%player%} to false
                message "&7You have joined the &6Orange &7team"
                set player's tab list name to "&6%player%"
            else:
                message "&7Team full!"
        else:
            message "&7You are already in the &6Blue &7team."
          
on damage:
    if {ir::red::victim} is "{ir::red::attacker}":
        cancel event
        send "&cYou can't hurt your teammates!" to attacker
 
on damage:
    if {ir::bluee::victim} is "{ir::bluee::attacker}":
        cancel event
        send "&cYou can't hurt your teammates!" to attacker
 
Okay this should do the trick
code_language.skript:
command /red:
    trigger:
        if {ir::red::%player%} is false:
            if {ir::red} < 8:
                if {ir::red::%player%}:
                    add -1 to {ir::bluee}
                    add 1 to {ir::red}
                set {ir::red::%player%} to true
                set {ir::bluee::%player%} to false
                message "&7You have joined the &cRed &7team"
                set player's tab list name to "&c%player%"
            else:
                message "&7Team full!"
        else:
            message "&7You are already in the &cRed &7team."
         
command /blue:
    trigger:
        if {ir::bluee::%player%} is false:
            if {ir::bluee} < 8:
                if {ir::red::%player%}:
                    add -1 to {ir::red}
                    add 1 to {ir::bluee}
                set {ir::bluee::%player%} to true
                set {ir::red::%player%} to false
                message "&7You have joined the &6Orange &7team"
                set player's tab list name to "&6%player%"
            else:
                message "&7Team full!"
        else:
            message "&7You are already in the &6Blue &7team."
         
on damage:
    if {ir::red::victim} is "{ir::red::attacker}":
        cancel event
        send "&cYou can't hurt your teammates!" to attacker
 
on damage:
    if {ir::bluee::victim} is "{ir::bluee::attacker}":
        cancel event
        send "&cYou can't hurt your teammates!" to attacker

I just tried it and I am getting this:

upload_2018-8-18_5-14-32.png
 
Those are just "possible" warnings. They don't actually affect your skript. They are just simple warnings stating that they might be conflicting.
You can turn off those warnings in your skript config if you want
[doublepost=1534580274,1534580173][/doublepost]Also, i just noticed a slight mistake in the last part, so i fixed it for ya
code_language.skript:
on damage:
    if {ir::red::%victim%} is {ir::red::%attacker%}:
        cancel event
        send "&cYou can't hurt your teammates!" to attacker
 
on damage:
    if {ir::bluee::%victim%} is {ir::bluee::%attacker%}:
        cancel event
        send "&cYou can't hurt your teammates!" to attacker
 
Those are just "possible" warnings. They don't actually affect your skript. They are just simple warnings stating that they might be conflicting.
You can turn off those warnings in your skript config if you want
[doublepost=1534580274,1534580173][/doublepost]Also, i just noticed a slight mistake in the last part, so i fixed it for ya
code_language.skript:
on damage:
    if {ir::red::%victim%} is {ir::red::%attacker%}:
        cancel event
        send "&cYou can't hurt your teammates!" to attacker
 
on damage:
    if {ir::bluee::%victim%} is {ir::bluee::%attacker%}:
        cancel event
        send "&cYou can't hurt your teammates!" to attacker

I just figured out that when I use both /red or /blue it says that I am already on the team. and also I can damage my 'teammate'
 
Okay, so problem #1... that is because in your command, if the variable is not false it says you are already part of the team. That is because the variable hasn't been set yet.
That can be fixed with a simple join event, checking if the variable isn't set (meaning a player has never joined a team) then to set it as false
code_language.skript:
on join:
    if {ir::red::%player%} is not set:
        set {ir::red::%player%} to false
    if {ir::bluee::%player%} is not set:
        set {ir::bluee::%player%} to false
Problem #2 This should fix it
code_language.skript:
on damage:
    if {ir::red::%victim%} is true:
        if {ir::red::%attacker%} is true:
            cancel event
            send "&cYou can't hurt your teammates!" to attacker
 
on damage:
    if {ir::bluee::%victim%} is true:
        if {ir::bluee::%attacker%} is true:
            cancel event
            send "&cYou can't hurt your teammates!" to attacker
 
Okay, so problem #1... that is because in your command, if the variable is not false it says you are already part of the team. That is because the variable hasn't been set yet.
That can be fixed with a simple join event, checking if the variable isn't set (meaning a player has never joined a team) then to set it as false
code_language.skript:
on join:
    if {ir::red::%player%} is not set:
        set {ir::red::%player%} to false
    if {ir::bluee::%player%} is not set:
        set {ir::bluee::%player%} to false
Problem #2 This should fix it
code_language.skript:
on damage:
    if {ir::red::%victim%} is true:
        if {ir::red::%attacker%} is true:
            cancel event
            send "&cYou can't hurt your teammates!" to attacker
 
on damage:
    if {ir::bluee::%victim%} is true:
        if {ir::bluee::%attacker%} is true:
            cancel event
            send "&cYou can't hurt your teammates!" to attacker

Well.. yeah but now it says that team is full. Maybe it's because of the "on join" thing? I don't know :emoji_frowning:
 
try add this to the beginning of your skript, reload the skript, and give it a whirl
code_language.skript:
on load:
    if {ir::red} is not set:
        set {ir::red} to 0
    if {ir::bluee} is not set:
        set {ir::bluee} to 0
 
try add this to the beginning of your skript, reload the skript, and give it a whirl
code_language.skript:
on load:
    if {ir::red} is not set:
        set {ir::red} to 0
    if {ir::bluee} is not set:
        set {ir::bluee} to 0
Yes this fixed it!!! Thank you so much for the great support!
 
yep.... so i created this simple command to clear the teams
just do /teamclear (red or bluee) <--- also, I noticed you are spelling blue with an extra e... i wasn't sure if that was on purpose or not, but i did the same in the command
code_language.skript:
command /teamclear <text>: #! Use either red or bluee
    trigger:
        if arg-1 is red:
            loop {ir::bluee::*}:
                set {ir::bluee::%loop-index%} to false
            set {ir::red} to 0
        if arg-1 is bluee:
            loop {ir::bluee::*}:
                set {ir::bluee::%loop-index%} to false
            set {ir::bluee} to 0
 
Status
Not open for further replies.