Hello !
This is a very simple Team game mode with 1v1 option, it is for simple fun
use command chooseteam and choose your team, while in your team any player that you kill thats on another team will be sent back to theiir respawn point on their death, you also have F5 which resets yourself back to your starting point for 1v1's. This was just some quick to have some fun.
RegisterCommand('chooseteam', function()
lib.registerContext({
id = 'team_menu',
title = 'Choose Team',
options = {
{
title = 'Team A',
event = 'chooseTeam:client',
args = 'A'
},
{
title = 'Team B',
event = 'chooseTeam:client',
args = 'B'
}
}
})
lib.showContext('team_menu')
end)
RegisterNetEvent('chooseTeam:client')
AddEventHandler('chooseTeam:client', function(team)
playerTeam = team
lib.notify({
title = 'Team Joined',
description = 'You have joined Team ' .. team,
type = 'success'
})
end)
function handleDeath()
if isDead then
if playerTeam == 'A' then
local coords = vector3(-2787.17, -1984.73, 202.14)
respawnPlayer(coords)
elseif playerTeam == 'B' then
local coords = vector3(-2790.51, -1865.08, 202.14)
respawnPlayer(coords)
else
lib.notify({
title = 'No Team Assigned',
description = 'You did not choose a team!',
type = 'error'
})
end
isDead = false
end
end
function respawnPlayer(coords)
local ped = PlayerPedId()
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, 0.0, true, false)
SetEntityCoords(ped, coords.x, coords.y, coords.z)
SetEntityHeading(ped, 0.0)
TriggerEvent('hospital:client:Revive')
lib.notify({
title = 'Respawned',
description = 'You have been respawned at your team’s base!',
type = 'success'
})
end
AddEventHandler('gameEventTriggered', function(event, data)
if event == 'CEventNetworkEntityDamage' then
local victim = data[1]
local victimDied = data[4]
if NetworkGetPlayerIndexFromPed(victim) == PlayerId() and victimDied and IsEntityDead(PlayerPedId()) then
if not isDead then
isDead = true
TriggerEvent('QBCore:Client:OnPlayerDeath')
handleDeath()
end
end
end
end)
RegisterKeyMapping('resetposition', 'Reset to Starting Point', 'keyboard', 'F5')
RegisterCommand('resetposition', function()
if playerTeam == 'A' then
local coords = vector3(-2787.17, -1984.73, 202.14)
respawnPlayer(coords)
elseif playerTeam == 'B' then
local coords = vector3(-2790.51, -1865.08, 202.14)
respawnPlayer(coords)
else
lib.notify({
title = 'No Team Assigned',
description = 'You did not choose a team!',
type = 'error'
})
end
end, false)
Put it any client
PLEASE DONT BULLY MY AIMING tysm