is there a way to check the player's team in an if statement without any skript plugins?

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

UltroGmr

Member
Sep 11, 2021
1
0
1
24
i'm making a capture the flag kind of minigame and i want to make it so that you can be killed if you arent on your teams side, i think i got everything else working but how do i check the player's team or is there an alternative?
 
You can use the On Damage: Event to check when an entity takes damage, and then use victim is a player to make sure that the entity is a player...

As for setting the player's team, you can make a variable like
{%player%.team}, then assign the team of a player with:
set {%player%.team} to *the team you want them to be on*

Finally you can check the team on the damage event with
{%victim%.team} is {%attacker%.team}, and then run the cancel event effect to stop the damage!
 
You can use the On Damage: Event to check when an entity takes damage, and then use victim is a player to make sure that the entity is a player...

As for setting the player's team, you can make a variable like
{%player%.team}, then assign the team of a player with:
set {%player%.team} to *the team you want them to be on*

Finally you can check the team on the damage event with
{%victim%.team} is {%attacker%.team}, and then run the cancel event effect to stop the damage!
You have the right idee in mind but it's executed very poorly
 
You can use the On Damage: Event to check when an entity takes damage, and then use victim is a player to make sure that the entity is a player...

As for setting the player's team, you can make a variable like
{%player%.team}, then assign the team of a player with:
set {%player%.team} to *the team you want them to be on*

Finally you can check the team on the damage event with
{%victim%.team} is {%attacker%.team}, and then run the cancel event effect to stop the damage!
Those variables though...

1. Do not start off your variables with expressions.
2. Do not use nested variables. Use list variables instead. (https://skripthub.net/tutorials/43)

Code:
{%player%.team} -> {team::%player%}
 
Status
Not open for further replies.