Solved Teams

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

ShaneBee

Supporter +
Addon Developer
Sep 7, 2017
2,248
241
73
Vancouver, Canada
Category:

Suggested name: teams.sk

What I want:
I want a simple little team skript. Where a player could create a team and invite players to it. (Maximum of 2 people add to the team, 3 total including yourself) The players could use the team chat command to chat within their team. Also the ability to teleport to team members. Team members can NOT PVP. I tried to write this myself but i kept running into stupid little problems.

Ideas for commands:
/team - General help command
/team create <name of team> - Creates their team
/team add <player> - Add a player (max 2) to their team
/team kick <player> - Kick a player from your team
/team leave - Leave the team you're in (not your own)
/team disband - Disband your team, removing all players
/team info - info on your team... maybe show team members, online status, location if they are online
/team chat (/tc) - Chat with just your team members, including a [team] prefix, only visible between team members
/team tp <player> - Tp to a team member

Ideas for permissions:
team.create - create a team, invite, kick, disband team, info command.

When I'd like it by: Preferably within a week of this post.
 
Last edited:
A good warmup for my fingers. Took me 23-ish minutes.
Need Tuske.

Untested, Might have bugs, incomplete. Only have created, invite, decline, and leave.
Leave automatically disbands the team if the team leader leaves it.

code_language.skript:
options:
    permission:
    permissionmessage:

function contains(list: objects, check: object) :: boolean:
    loop {_list::*}:
        if loop-value is {_check}:
            return true
    return false
   
   
command /team [<text>] [<text>]:
    permission:{@permission}
    permission message: {@permissionmessage}
    trigger:
        if arg-1 isn't set:
            send "&7&m+--------------------------------+" to player
            send "&c/team create Name" to player
            send "&c/team invite player" to player
            send "&c/team kick player" to player
            send "&c/team leave" to player
            send "&c/team disband" to player
            send "&c/team info" to player
            send "&c/team chat" to player
            send "&7&m+--------------------------------+" to player
        else if arg-1 = "create":
            if arg-2 is set
                if {team.%uuid of player} isn't set:
                    if arg-2 matches "^[a-zA-Z]+$":
                        if {teams::%arg-2%::*} isn't set:
                            set {team.%uuid of player%} to arg-2
                            set {teams::%arg-2%::leader} to player
                            add player to {teams::%arg-2%::members}
                            broadcast "%player% created a new team called %arg-2%!"
                        else:
                            send "Team name taken." to player
                    else:
                        send "No special characters." to player
                else if {team.%uuid of player} is set:
                    send "&7You already have a team, leave or disband!" to player
            else:
                send "&7You need a name!" to player
        else if arg-1 = "invite":
            if arg-2 is set:
                if {team.%uuid of player%} is set:
                    if {teams::%{team.%uuid of player%}%::leader} = player:
                        set {_arg2} to arg-2 parsed as offline player
                        if {_arg2} is online:
                            set {_u} to uuid of {_arg2}
                            if {team.%{_u}%} isn't set:
                                if contains({teams::%arg-2%::members}, {_arg2}) = false:
                                    set {invitedteam.%{_u}%} to {team.%uuid of player%}
                                    send "team invite from %player%" to {_arg2}
                                    send "type /team join" to {_arg2}
                                    send "type /team decline" to {_arg2}
                                    send "expires in 30 seconds" to {_arg2}
                                    set {_s} to true
                                    while {_s} = true:
                                        add 1 to {_s}
                                        if {_s} >= 30:
                                            delete {invitedteam.%{_u}%}
                                            send "Invite expired from %player%" to {_arg2}
                                            set {_s} to false
                                        wait 1 second
                                else:  
                                    send "That player is already in your team!"
                        else:
                            send "That player needs to be online!" to player
                    else:
                        send "Your team leader." to player
                else:
                    send "You don't even have a team." to player
            else:
                send "&7You need a player name!" to player1
        else if arg-1 is "accept":
            if {invitedteam.%uuid of player%} is set:
                if {team.%uuid of player%} isn't set:
                    set {team.%uuid of player} to {invitedteam.%uuid of player%}
                    delete {invitedteam.%uuid of player%}
                    loop {teams::%{team.%uuid of player}%::members}:
                        if loop-value is online:
                            send "%player% joined your team!" to loop-value
                else:
                    send "You already in a team already, leave it before joining a new one." to player
            else:
                send "You do not have any invitations" to player
        else if arg-1 is "decline":
            if {invitedteam.%uuid of player%} is set:
                if {team.%uuid of player%} isn't set:
                    delete {invitedteam.%uuid of player%}
                    loop {teams::%{team.%uuid of player}%::members}:
                        if loop-value is online:
                            send "%player% declined your invitation!" to loop-value
                else:
                    send "You already in a team already, leave it before joining a new one." to player
        else if arg-1 is "leave":
            if {team.%uuid of player%} is set:
                if contains({teams::%{team.%uuid of player%}%::leader}, player) = false:
                    loop {teams::%{team.%uuid of player}%::members}:
                        if loop-value is online:
                            send "%player% left your team!" to loop-value
                else:
                    loop {teams::%{team.%uuid of player}%::members}:
                        if loop-value is online:
                            send "%player% has disbanded your team!" to loop-value
                        delete {teams::%{team.%uuid of player}%::*}
                        delete {team.%uuid of loop-value%}
        else if arg-1 isn't "create" or "add" or "kick" or "leave" or "disband" or "info" or "chat":
            make player execute command "/team"
 
A good warmup for my fingers. Took me 30 minutes.
Need Tuske.

Untested, Might have bugs, incomplete. Only have created, invite, decline, and leave.
Leave automatically disbands the team if the team leader leaves it.

code_language.skript:
options:
    permission:
    permissionmessage:

function contains(list: objects, check: object) :: boolean:
    loop {_list::*}:
        if loop-value is {_check}:
            return true
    return false
  
  
command /team [<text>] [<text>]:
    permission:{@permission}
    permission message: {@permissionmessage}
    trigger:
        if arg-1 isn't set:
            send "&7&m+--------------------------------+" to player
            send "&c/team create Name" to player
            send "&c/team invite player" to player
            send "&c/team kick player" to player
            send "&c/team leave" to player
            send "&c/team disband" to player
            send "&c/team info" to player
            send "&c/team chat" to player
            send "&7&m+--------------------------------+" to player
        else if arg-1 = "create":
            if arg-2 is set
                if {team.%uuid of player} isn't set:
                    if arg-2 matches "^[a-zA-Z]+$":
                        if {teams::%arg-2%::*} isn't set:
                            set {team.%uuid of player%} to arg-2
                            set {teams::%arg-2%::leader} to player
                            add player to {teams::%arg-2%::members}
                            broadcast "%player% created a new team called %arg-2%!"
                        else:
                            send "Team name taken." to player
                    else:
                        send "No special characters." to player
                else if {team.%uuid of player} is set:
                    send "&7You already have a team, leave or disband!" to player
            else:
                send "&7You need a name!" to player
        else if arg-1 = "invite":
            if arg-2 is set:
                if {team.%uuid of player%} is set:
                    if {teams::%{team.%uuid of player%}%::leader} = player:
                        set {_arg2} to arg-2 parsed as offline player
                        if {_arg2} is online:
                            set {_u} to uuid of {_arg2}
                            if {team.%{_u}%} isn't set:
                                if contains({teams::%arg-2%::members}, {_arg2}) = false:
                                    set {invitedteam.%{_u}%} to {team.%uuid of player%}
                                    send "team invite from %player%" to {_arg2}
                                    send "type /team join" to {_arg2}
                                    send "type /team decline" to {_arg2}
                                    send "expires in 30 seconds" to {_arg2}
                                    set {_s} to true
                                    while {_s} = true:
                                        add 1 to {_s}
                                        if {_s} >= 30:
                                            delete {invitedteam.%{_u}%}
                                            send "Invite expired from %player%" to {_arg2}
                                            set {_s} to false
                                        wait 1 second
                                else: 
                                    send "That player is already in your team!"
                        else:
                            send "That player needs to be online!" to player
                    else:
                        send "Your team leader." to player
                else:
                    send "You don't even have a team." to player
            else:
                send "&7You need a player name!" to player1
        else if arg-1 is "accept":
            if {invitedteam.%uuid of player%} is set:
                if {team.%uuid of player%} isn't set:
                    set {team.%uuid of player} to {invitedteam.%uuid of player%}
                    delete {invitedteam.%uuid of player%}
                    loop {teams::%{team.%uuid of player}%::members}:
                        if loop-value is online:
                            send "%player% joined your team!" to loop-value
                else:
                    send "You already in a team already, leave it before joining a new one." to player
            else:
                send "You do not have any invitations" to player
        else if arg-1 is "decline":
            if {invitedteam.%uuid of player%} is set:
                if {team.%uuid of player%} isn't set:
                    delete {invitedteam.%uuid of player%}
                    loop {teams::%{team.%uuid of player}%::members}:
                        if loop-value is online:
                            send "%player% declined your invitation!" to loop-value
                else:
                    send "You already in a team already, leave it before joining a new one." to player
        else if arg-1 is "leave":
            if {team.%uuid of player%} is set:
                if contains({teams::%{team.%uuid of player%}%::leader}, player) = false:
                    loop {teams::%{team.%uuid of player}%::members}:
                        if loop-value is online:
                            send "%player% left your team!" to loop-value
                else:
                    loop {teams::%{team.%uuid of player}%::members}:
                        if loop-value is online:
                            send "%player% has disbanded your team!" to loop-value
                        delete {teams::%{team.%uuid of player}%::*}
                        delete {team.%uuid of loop-value%}
        else if arg-1 isn't "create" or "add" or "kick" or "leave" or "disband" or "info" or "chat":
            make player execute command "/team"
Ah... thank you for creating 1/4 of what I needed.

I will keep this post open to see if anyone else wants to create the full skript I asked for.
Thanks again for your reply!
[doublepost=1533440068,1533241049][/doublepost]Hey still need help on this if anyone has any ideas
 
Last edited:
Ah... thank you for creating 3/4 of what I needed.

I will keep this post open to see if anyone else wants to create the full skript I asked for.
Thanks again for your reply!
[doublepost=1533440068,1533241049][/doublepost]Hey still need help on this if anyone has any ideas
what's wrong?
 
well there was a handful of errors due to the fact that you wrote things like this "{team.%uuid of player}" missing the last % in that.
The leave command doesn't work, and the chat is non existent. And the PVP feature is non existent nor is the TP feature. The basic need for this system was so players could team up, chat with each other, not PVP each other and TP to each other. None of those 3 things are written in this skript.
 
Maybe for the PvP part this (idk I just quickly looked over the script @Farid made):
code_language.skript:
on damage:
    attacker is set
    victim is a player
    attacker is a player
    {team.%uuid of victim%} is {team.%uuid of attacker%}
    cancel event
    send "" to attacker # optional
and for the chat something like this:
code_language.skript:
command /teamchat <text>:
    aliases: /tc
    trigger:
        set {_uuid} to uuid of player
        {team.%{_uuid}%} is set
        loop {teams::%{team.%{_uuid}%::members}:
            send "&7[&a%player%&7] &f%arg-1%" to loop-value
[doublepost=1533450261,1533450122][/doublepost]And maybe for the teleport something like this:
code_language.skript:
command /teamtp <player>:
    trigger:
        set {_uuid1} to uuid of player
        set {_uuid2} to uuid of arg-1
        if {team.%{_uuid1}%} != {team.%{_uuid2}%}:
            message "&cThat player is not on your team!"
            stop
        teleport player to arg-1
        message "&aYou teleported to %arg-1%"
        send "&a%player% teleported to you!" to arg-1