[Example Resource][ES] Team System & Chat Roles

This is an EssentialMode script I wrote that allows players to choose teams, it can be built on with quite a lot more. It also offers custom chat roles based on what team a player is on.

Type /team in chat to get a list of the teams, then type /team >team name< e.g. /team lspd

This is kind of just an example of how to make teams and custom chat roles, so If you use this, don’t be an asshole, give credit.

Requires EssentialMode, nothing else.

Configuration

In order to set up custom teams or change the current ones, open the server.lua file and look for these lines.

Here you can set up new teams, the id must be manually put in, the name is what will appear next to a player’s name in chat, the cmd is what a player has to type to change team, e.g. “/team lspd” and the colour is obvious.

Download

Download [Example resource, no version]

5 Likes

Awesome job brother.
Question… how long does the role stay on this user.
If they disconnect and come back. Does the role save ?

2 Likes

If they disconnect and come back it resets to the default team.

Wonder if making this permission based, where say permission 2-4 can use the /team id. Making the choice by admin and not the user.
Say in RP assigning new clients police role for the session.

Feel free to do what you want with it as it’s just an example script as I’ve seen a lot of people ask about making a team script as well as custom chat roles.

Awesome job thanks!..

Here is appearing 2 chat

I have a suggestion can you make that you get the automatically assigned role when choosing your ped so for example, if I changed to cop then it updates the role.

How do you change the default server role?

-- When the player is fully loaded we set their default team data
AddEventHandler( 'es:playerLoaded', function( source ) 
	TriggerClientEvent( 'wk:SetTeam', source, defaultTeam.id )
	playerTeams[ source ] = teams.civilian
end )

Hey there, edwin! So what I’ve just posted above is a code snippet from the serverside script. All you would probably need to change is

playerTeams[ source ] = teams.civilian

Here, you would need to change the teams.civilian to whichever team you want. For example:

local teams = 
{
	civilian = { id = 1, name = "Civilian",   cmd = "civ",    colour = { 255, 221, 0 } },
	lspd     = { id = 2, name = "LSPD",       cmd = "lspd",   colour = { 50, 50, 255 } },

If I wanted people to spawn as LSPD the code would look like…

playerTeams[ source ] = teams.lspd

Just a reminder, you would use the first string, not the name or command.

Hope this helps!

1 Like

how do i add more? or am i just stuck with the few default ones i have. i would like to add a few more chat roles but when i do the server wont start

1 Like

Configuration

In order to set up custom teams or change the current ones, open the server.lua file and look for these lines.

Here you can set up new teams, the id must be manually put in, the name is what will appear next to a player’s name in chat, the cmd is what a player has to type to change team, e.g. “/team lspd” and the colour is obvious.

Follow the pattern, so if I wanted to add say san andreas state police, I would add this under the last item:

sasp = { id = 7, name = "SASP", cmd = "sasp", colour = { 50 50, 255 } }

I know that yes, but i was asking once i fill all those up i wanna have another row, can i do that?

Yes, you can set up as many as you want.

and how would i do that?

Read the bottom of my second to last post.

and when i do exactly what you said the script stops working, i do /team in chat and nothing happens :confused:

Did you put a comma at the end of the second to last item in the table?

No i did not and thats why, thank you for the help i appreciate it!

1 Like

do you have a list or a link for the other colors that I can use? xd