local team1 = {
name = "Team 1",
color = {255, 0, 0}, -- red color
spawnPoints = {
{x = 100.0, y = 100.0, z = 24.0, h = 0.0}, -- replace with team's spawn points
-- add more spawn points as needed
},
players = {}
}
local team2 = {
name = "Team 2",
color = {0, 0, 255}, -- blue color
spawnPoints = {
{x = 200.0, y = 200.0, z = 24.0, h = 0.0}, -- replace with team's spawn points
-- add more spawn points as needed
},
players = {}
}
function addToTeam(player, team)
table.insert(team.players, player)
TriggerClientEvent("paintball:setTeam", player, team) -- send team info to the client
end
RegisterServerEvent("paintball:addToTeam")
AddEventHandler("paintball:addToTeam", function(teamID)
local player = source
if teamID == 1 then
addToTeam(player, team1)
elseif teamID == 2 then
addToTeam(player, team2)
else
print("Invalid teamID")
end
end)
local currentPlayerTeam = nil
RegisterNetEvent("paintball:setTeam")
AddEventHandler("paintball:setTeam", function(team)
currentPlayerTeam = team
-- Set player color, mark team area, etc.
end)
RegisterCommand("jointeam", function(source, args)
local teamID = tonumber(args[1])
if teamID == 1 or teamID == 2 then
TriggerServerEvent("paintball:addToTeam", teamID)
else
print("Invalid teamID")
end
end)
Now, players can join teams using /jointeam 1 or /jointeam 2. You can build upon this foundation to implement other functionalities like spawning players at respective spawn points or keeping track of each team's score.