# Config

{% tabs %}
{% tab title="Config" %}

```lua
-- Enable debug make sure FiveM client is "Beta Channel" in setting to use more dev command.
Config.Debug = false

Config.MinPlayers = 2 -- Minimum of player to allow counwdown (Set to 1, Trial mode will enable).
Config.MaxPlayers = 20 -- Maximum player allow in lobby.
Config.LobbyTime = 20 -- Countdown timer to start race if minimum player reached Config.MinPlayers. (second)
Config.ArenaTime = 60 -- Duration in game before lobby auto close. (minute)
Config.OwnWorld = true -- Game in another world. Participants and the non participants will not see each other.

Config.Game.PrepareGameDuration = 60 -- Duration before game start after lobby countdown. (second)
Config.Game.PrepareRoundDuration = 60 -- Duration before round start after round end (second)
Config.Game.KillStreakDuration = 7 -- Duration before lost kill streak (second)

Config.Game.Zombie.RepawnTimer = 7 -- How long zome can respawn after death (second)
Config.Game.Zombie.SkillCooldown = 30 -- How long zombie skill can use (second)

Config.Game.Team.ChangeCooldown = 20 -- Cooldown after changing team (second)

-- Config.XP : Display XP rank system on end screen.
-- Example is https://github.com/chaixshot/DarkRP_XP

local DarkRP_XP = exports["DarkRP_XP"]

Config.EndScreen.ResultsPanelTime = 10 -- sec
Config.EndScreen.XP.rankTextSmall = "LEVEL UP"
Config.EndScreen.XP.rankTextBig = "~b~Nice~s~"

Config.EndScreen.XP.GetXpGained = function(source, exp)
	exp = math.floor(exp)
	if GetResourceState("DarkRP_XP") == "started" then -- DarkRP_XP request.
		DarkRP_XP:AddPlayerXPToServer(exp)
		return exp
	else
		return 0
	end
end

-- Current XP in rank system.
Config.EndScreen.XP.GetXpBeforeGain = function(source)
	if GetResourceState("DarkRP_XP") == "started" then -- DarkRP_XP request.
		return DarkRP_XP:GetCurrentPlayerXP()
	else
		return 0
	end
end

-- Minimum XP of current rank.
Config.EndScreen.XP.GetMinLevelXP = function(source)
	if GetResourceState("DarkRP_XP") == "started" then -- DarkRP_XP request.
		return DarkRP_XP:GetXPCeilingForLevel(DarkRP_XP:GetCurrentPlayerLevel()-1)
	else
		return 0
	end
end

-- Maximum XP of current rank.
Config.EndScreen.XP.GetMaxLevelXP = function(source)
	if GetResourceState("DarkRP_XP") == "started" then -- DarkRP_XP request.
		return DarkRP_XP:GetXPCeilingForLevel(DarkRP_XP:GetCurrentPlayerLevel())
	else
		return 0
	end
end

-- Current rank.
Config.EndScreen.XP.GetCurrentRank = function(source)
	if GetResourceState("DarkRP_XP") == "started" then -- DarkRP_XP request.
		return DarkRP_XP:GetCurrentPlayerLevel()
	else
		return 1
	end
end

-- Rank next from current rank.
Config.EndScreen.XP.GetNextRank = function(source)
	if GetResourceState("DarkRP_XP") == "started" then -- DarkRP_XP request.
		return DarkRP_XP:GetCurrentPlayerLevel()+1
	else
		return 1
	end
end

Config.EndScreen.Money.Text = { -- Display money on end screen.
	topText = "",
	bottomText = "",
	rightHandStat = "",
	rightHandStatIcon = 3, --0 or 1 = checked, 2 = X, 3 = no icon
}

--- Map coords for custom map
Config.Location["zm_front_2020"] = {
	["mapObj"] = "zm_front_2020", -- .ydr model to spawn as a map, remove the line if not have.
	["spawnpoint"] = { -- Random spawn point
		{x=1876.477, y=2724.802, z=114.763},
		{x=1862.099, y=2744.018, z=114.764},
		{x=1847.54, y=2765.058, z=114.764},
		{x=1821.926, y=2794.339, z=114.764},
		{x=1858.381, y=2781.046, z=117.438},
	},
}
```

{% endtab %}

{% tab title="Server Event" %}

```lua
---Player display name, can change to RP name.
---@param source integer Player server id
---@return string Player name
event.getPlayerName = function(source --[[ number ]])
	return GetPlayerName(source)
end

--- give money to player when win race
--- "money" come from event.calculateReward() "reward"
---@param source integer Player server id
---@param money integer
event.giveMoney = function(source, money)
	--[[ Example for ESX
	ESX = nil
	TriggerEvent("esx:getSharedObject", function(obj) ESX = obj end)
	local xPlayer = ESX.GetPlayerFromId(source)
	xPlayer.addMoney(money)
	]]--
end

---comment
---@param player table
---@param isRedWin boolean
---@param isBlueWin boolean
---@return number
---@return number
event.calculateReward = function(player, isRedWin, isBlueWin)
	local reward_money = player.Hit * 900 + player.score * 200
	local reward_exp = player.Hit * 110 + player.score * 100

	if player.Team == "red" then
		if isRedWin then

		else
			reward_money /= 2
			reward_exp /= 2
		end
	elseif player.Team == "blue" then
		if isBlueWin then
			
		else
			reward_money /= 2
			reward_exp /= 2
		end
	end

	event.giveMoney(player.source, reward_money)

	return reward_money, reward_exp -- Return money and exp value back to server.
end

---Normal chat event
---@param source integer Player server id
---@param text string
event.chatMessage = function(source --[[ number ]], text --[[ string ]]) 
	TriggerClientEvent('chatMessage', source, "[Racing]", { 255, 87, 35 }, text)
end
```

{% endtab %}

{% tab title="Client Event" %}

```lua
---Change player skin to normal, change for RP clothes
event.ClothNormal = function()
	-- vRPClients.TriggerServerCallback({'esx_skin:getPlayerSkin', function(skin)
		local model = nil
		-- if skin.sex == 0 then
			model = GetHashKey("mp_m_freemode_01")
		-- else
			-- model = GetHashKey("mp_f_freemode_01")
		-- end
		RequestModelC(model)
		SetPlayerModel(PlayerId(), model)
		SetPedDefaultComponentVariation(PlayerPedId())
		-- TriggerEvent('skinchanger:loadSkin', skin)
		-- TriggerEvent('skinchanger:modelLoaded')
		SetPedRelationshipGroupHash(PlayerPedId(), GetHashKey("PLAYER"))
		SetEntityOnlyDamagedByRelationshipGroup(PlayerPedId(), false, GetHashKey("GANG_1"))
		SetEntityOnlyDamagedByRelationshipGroup(PlayerPedId(), false, GetHashKey("GANG_2"))
		ClearPedBloodDamage(PlayerPedId())
		ResetPedVisibleDamage(PlayerPedId())
		ClearPedLastWeaponDamage(PlayerPedId())
	-- end})
end

---Call to revive player, RP api
event.revivePlayer = function()
	local heading = GetEntityHeading(PlayerPedId())
	local coords = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 0.0, 0.0)
	NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, heading, 0, false)
	TriggerEvent('playerSpawned', coords.x, coords.y, coords.z, heading)
	ClearPedBloodDamage(PlayerPedId())
	ClearEntityLastDamageEntity(PlayerPedId())
	AnimpostfxStop("DeathFailOut")
end

---Player display name, change to RP name?.
---@param playerID integer Player client id
---@return string
event.getPlayerName = function(playerID)
	local source = GetPlayerServerId(playerID)
	if Main.PlayersDataBySource[source] then
		return Main.PlayersDataBySource[source].playerName
	else
		return GetPlayerName(playerID)
	end
end

---Maybe your want to bypass anticheats somehow.
---@param entity integer PlayerPedId(), vehicleid
---@param x number Coord x
---@param y number Coord y
---@param z number Coord z
event.teleportToCoords = function(entity , x, y, z)
	RequestCollisionAtCoord(x, y, z)
	SetEntityCoords(entity, x, y, z, true, false, false, true)
end

---Top left notification event
---@param msg1 string
---@param msg2 string
---@param msg3 string
event.showHelpNotification = function(msg1, msg2, msg3)
	BeginTextCommandDisplayHelp("THREESTRINGS")
	AddTextComponentSubstringPlayerName(msg1)
	AddTextComponentSubstringPlayerName(msg2 and "~n~"..msg2 or "")
	AddTextComponentSubstringPlayerName(msg3 and "~n~"..msg3 or "")
	EndTextCommandDisplayHelp(0, false, true, -1)
end

---Bottom left notification event
---@param msg string
---@param noSound boolean
event.ShowNotification = function(msg, noSound)
	BeginTextCommandThefeedPost('STRING')
	AddTextComponentSubstringPlayerName(msg)
	local id = EndTextCommandThefeedPostTicker(false, true)
	ThefeedRemoveItem(id-5)
	if not noSound then
		PlaySound(-1, "Boss_Message_Orange", "GTAO_Boss_Goons_FM_Soundset", 0, 0, 1)
	end
end

-- Hide your ui for beautiful script screen, Do not loop on this it slowdown main script
event.onUiToggle = function(show --[[ Boolean ]])
	-- CreateThread(function()
	if show then
		DisplayRadar(true)
	else
		DisplayRadar(false)
	end
	-- end)
end

-- Call on game start
AddEventHandler("DarkRP_ZombieSurvival:OnSessionStart", function()
	NetworkSetFriendlyFireOption(true) -- For PVE server.
end)

-- Call on game end
AddEventHandler("DarkRP_ZombieSurvival:OnSessionEnd", function()
	-- NetworkSetFriendlyFireOption(false)
end)
```

{% endtab %}

{% tab title="Translate" %}

```lua
local Translate = {
	["hud_killed"] = {
		["en"] = "~r~KILLED",
		["br"] = "~r~morto",
		["cn"] = "~r~被杀",
		["de"] = "~r~getötet",
		["es"] = "~r~asesinado",
		["fr"] = "~r~tué",
		["it"] = "~r~ucciso",
		["jp"] = "~r~kill",
		["kr"] = "~r~죽었다",
		["mx"] = "~r~asesinado",
		["pl"] = "~r~zabity",
		["ru"] = "~r~убит",
		["tw"] = "~r~被殺",
	},
}

local langTable = {[1]="en", [2]="fr", [3]="de", [4]="it", [5]="es", [6]="br", [7]="pl", [8]="ru", [9]="kr", [10]="tw", [11]="jp", [12]="mx", [13]="cn"} 
GetTranslate = function(str, ...)
	local language = GetCurrentLanguage() + 1
	if Translate[str] then
		if Translate[str][langTable[language]] then
			if ... then
				return string.format(Translate[str][langTable[language]], ...)
			else
				return Translate[str][langTable[language]]
			end
		end
		if ... then
			return string.format(Translate[str]["en"], ...)
		else
			return Translate[str]["en"]
		end
	end
	return str
end
```

{% endtab %}
{% endtabs %}
