mirror of
https://github.com/citizenfx/cfx-server-data.git
synced 2025-12-12 06:14:09 +01:00
reorganize resource directories
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
resource_type 'map' { gameTypes = { ['basic-gamemode'] = true } }
|
||||
|
||||
map 'map.lua'
|
||||
64
resources/[gamemodes]/[maps]/fivem-map-hipster/map.lua
Normal file
64
resources/[gamemodes]/[maps]/fivem-map-hipster/map.lua
Normal file
@@ -0,0 +1,64 @@
|
||||
vehicle_generator "airtug" { -54.26639938354492, -1679.548828125, 28.4414, heading = 228.2736053466797 }
|
||||
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -802.311, y = 175.056, z = 72.8446 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -9.96562, y = -1438.54, z = 31.1015 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 0.916756, y = 528.485, z = 174.628 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 1975.86, y = 3821.03, z = 33.4501 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -181.615, y = 852.8, z = 232.701 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 657.723, y = 457.342, z = 144.641 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 134.387, y = 1150.31, z = 231.594 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 726.14, y = 1196.91, z = 326.262 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 740.792, y = 1283.62, z = 360.297 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -437.009, y = 1059.59, z = 327.331 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -428.771, y = 1596.8, z = 356.338 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1348.78, y = 723.87, z = 186.45 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1543.24, y = 830.069, z = 182.132 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -2150.48, y = 222.019, z = 184.602 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -3032.13, y = 22.2157, z = 10.1184 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 3063.97, y = 5608.88, z = 209.245 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -2614.35, y = 1872.49, z = 167.32 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1873.94, y = 2088.73, z = 140.994 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -597.177, y = 2092.16, z = 131.413 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 967.126, y = 2226.99, z = 54.0588 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -338.043, y = 2829, z = 56.0871 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 1082.25, y = -696.921, z = 58.0099 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 1658.31, y = -13.9234, z = 169.992 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2522.98, y = -384.436, z = 92.9928 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 2826.27, y = -656.489, z = 1.87841 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2851.12, y = 1467.5, z = 24.5554 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 2336.33, y = 2535.39, z = 46.5177 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2410.46, y = 3077.88, z = 48.1529 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 2451.15, y = 3768.37, z = 41.3477 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 3337.78, y = 5174.8, z = 18.2108 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1119.33, y = 4978.52, z = 186.26 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2877.3, y = 5911.57, z = 369.618 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 2942.1, y = 5306.73, z = 101.52 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 2211.29, y = 5577.94, z = 53.872 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 1602.39, y = 6623.02, z = 15.8417 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 66.0113, y = 7203.58, z = 3.16 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -219.201, y = 6562.82, z = 10.9706 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -45.1562, y = 6301.64, z = 31.6114 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1004.77, y = 4854.32, z = 274.606 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1580.01, y = 5173.3, z = 19.5813 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1467.95, y = 5416.2, z = 23.5959 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -2359.31, y = 3243.83, z = 92.9037 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -2612.96, y = 3555.03, z = 4.85649 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -2083.27, y = 2616.94, z = 3.08396 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -524.471, y = 4195, z = 193.731 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -840.713, y = 4183.18, z = 215.29 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1576.24, y = 2103.87, z = 67.576 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1634.37, y = 209.816, z = 60.6413 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1495.07, y = 142.697, z = 55.6527 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1715.41, y = -197.722, z = 57.698 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1181.07, y = -505.544, z = 35.5661 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1712.37, y = -1082.91, z = 13.0801 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -1352.43, y = -1542.75, z = 4.42268 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -1756.89, y = 427.531, z = 127.685 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 3060.2, y = 2113.2, z = 1.6613 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 501.646, y = 5604.53, z = 797.91 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = 714.109, y = 4151.15, z = 35.7792 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = -103.651, y = -967.93, z = 296.52 }
|
||||
spawnpoint 'a_m_y_hipster_01' { x = -265.333, y = -2419.35, z = 122.366 }
|
||||
spawnpoint 'a_m_y_hipster_02' { x = 1788.25, y = 3890.34, z = 34.3849 }
|
||||
|
||||
--
|
||||
@@ -0,0 +1,3 @@
|
||||
resource_type 'map' { gameTypes = { ['basic-gamemode'] = true } }
|
||||
|
||||
map 'map.lua'
|
||||
62
resources/[gamemodes]/[maps]/fivem-map-skater/map.lua
Normal file
62
resources/[gamemodes]/[maps]/fivem-map-skater/map.lua
Normal file
@@ -0,0 +1,62 @@
|
||||
spawnpoint 'a_m_y_skater_01' { x = -802.311, y = 175.056, z = 72.8446 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -9.96562, y = -1438.54, z = 31.1015 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 0.916756, y = 528.485, z = 174.628 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 1975.86, y = 3821.03, z = 33.4501 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -181.615, y = 852.8, z = 232.701 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 657.723, y = 457.342, z = 144.641 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 134.387, y = 1150.31, z = 231.594 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 726.14, y = 1196.91, z = 326.262 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 740.792, y = 1283.62, z = 360.297 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -437.009, y = 1059.59, z = 327.331 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -428.771, y = 1596.8, z = 356.338 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1348.78, y = 723.87, z = 186.45 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1543.24, y = 830.069, z = 182.132 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -2150.48, y = 222.019, z = 184.602 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -3032.13, y = 22.2157, z = 10.1184 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 3063.97, y = 5608.88, z = 209.245 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -2614.35, y = 1872.49, z = 167.32 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1873.94, y = 2088.73, z = 140.994 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -597.177, y = 2092.16, z = 131.413 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 967.126, y = 2226.99, z = 54.0588 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -338.043, y = 2829, z = 56.0871 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 1082.25, y = -696.921, z = 58.0099 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 1658.31, y = -13.9234, z = 169.992 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2522.98, y = -384.436, z = 92.9928 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 2826.27, y = -656.489, z = 1.87841 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2851.12, y = 1467.5, z = 24.5554 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 2336.33, y = 2535.39, z = 46.5177 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2410.46, y = 3077.88, z = 48.1529 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 2451.15, y = 3768.37, z = 41.3477 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 3337.78, y = 5174.8, z = 18.2108 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1119.33, y = 4978.52, z = 186.26 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2877.3, y = 5911.57, z = 369.618 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 2942.1, y = 5306.73, z = 101.52 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 2211.29, y = 5577.94, z = 53.872 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 1602.39, y = 6623.02, z = 15.8417 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 66.0113, y = 7203.58, z = 3.16 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -219.201, y = 6562.82, z = 10.9706 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -45.1562, y = 6301.64, z = 31.6114 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1004.77, y = 4854.32, z = 274.606 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1580.01, y = 5173.3, z = 19.5813 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1467.95, y = 5416.2, z = 23.5959 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -2359.31, y = 3243.83, z = 92.9037 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -2612.96, y = 3555.03, z = 4.85649 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -2083.27, y = 2616.94, z = 3.08396 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -524.471, y = 4195, z = 193.731 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -840.713, y = 4183.18, z = 215.29 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1576.24, y = 2103.87, z = 67.576 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1634.37, y = 209.816, z = 60.6413 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1495.07, y = 142.697, z = 55.6527 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1715.41, y = -197.722, z = 57.698 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1181.07, y = -505.544, z = 35.5661 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1712.37, y = -1082.91, z = 13.0801 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -1352.43, y = -1542.75, z = 4.42268 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -1756.89, y = 427.531, z = 127.685 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 3060.2, y = 2113.2, z = 1.6613 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 501.646, y = 5604.53, z = 797.91 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = 714.109, y = 4151.15, z = 35.7792 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = -103.651, y = -967.93, z = 296.52 }
|
||||
spawnpoint 'a_m_y_skater_01' { x = -265.333, y = -2419.35, z = 122.366 }
|
||||
spawnpoint 'a_m_y_skater_02' { x = 1788.25, y = 3890.34, z = 34.3849 }
|
||||
|
||||
--
|
||||
3
resources/[gamemodes]/basic-gamemode/__resource.lua
Normal file
3
resources/[gamemodes]/basic-gamemode/__resource.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
resource_type 'gametype' { name = 'Freeroam' }
|
||||
|
||||
client_script 'basic_client.lua'
|
||||
4
resources/[gamemodes]/basic-gamemode/basic_client.lua
Normal file
4
resources/[gamemodes]/basic-gamemode/basic_client.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
AddEventHandler('onClientMapStart', function()
|
||||
exports.spawnmanager:setAutoSpawn(true)
|
||||
exports.spawnmanager:forceRespawn()
|
||||
end)
|
||||
@@ -1,3 +0,0 @@
|
||||
resource_type 'map' { gameTypes = { race = true } }
|
||||
|
||||
map 'map.lua'
|
||||
@@ -1,31 +0,0 @@
|
||||
spawnpoint 'ig_brucie' { 1127.99, -569.018, 12.5918, heading = 270 }
|
||||
spawnpoint 'ig_brucie' { 1122.99, -569.018, 12.5918, heading = 270 }
|
||||
spawnpoint 'ig_brucie' { 1119.99, -569.018, 12.5918, heading = 270 }
|
||||
spawnpoint 'ig_brucie' { 1116.99, -569.018, 12.5918, heading = 270 }
|
||||
|
||||
checkpoint { pos = { 1175.38, -568.361, 12.9386 } }
|
||||
checkpoint { pos = { 1192.41, -484.373, 12.9902 } }
|
||||
checkpoint { pos = { 1370.24, -454.326, 16.1487 } }
|
||||
checkpoint { pos = { 1380.32, -319.673, 19.2937 } }
|
||||
checkpoint { pos = { 1153.19, -334.017, 17.6384 } }
|
||||
--[[checkpoint { pos = { 1120.66, -272.068, 19.6985 } }
|
||||
checkpoint { pos = { 1014.76, -270.757, 20.9716 } }
|
||||
checkpoint { pos = { 1018.3, -367.436, 18.9644 } }
|
||||
checkpoint { pos = { 634.072, -400.678, 40.1211 } }
|
||||
checkpoint { pos = { 218.425, -400.586, 14.506 } }
|
||||
checkpoint { pos = { 27.9617, -408.632, 13.7693 } }
|
||||
checkpoint { pos = { -0.9286, -625.767, 13.7056 } }
|
||||
checkpoint { pos = { -114.801, -646.633, 13.8117 } }
|
||||
checkpoint { pos = { -123.565, -785.028, 4.2556 } }
|
||||
checkpoint { pos = { 114.514, -730.95, 4.0023 } }
|
||||
checkpoint { pos = { 267.888, -668.781, 4.0181 } }
|
||||
checkpoint { pos = { 337.305, -509.17, 3.7381 } }
|
||||
checkpoint { pos = { 309.906, -407.719, 4.0468 } }
|
||||
checkpoint { pos = { 296.932, -253.16, 3.9989 } }
|
||||
checkpoint { pos = { 157.697, -234.079, 13.8108 } }
|
||||
checkpoint { pos = { 140.173, -389.505, 13.7984 } }
|
||||
checkpoint { pos = { 340.356, -415.681, 31.418 } }
|
||||
checkpoint { pos = { 566.093, -415.848, 39.5434 } }
|
||||
checkpoint { pos = { 909.641, -422.129, 36.4247 } }
|
||||
checkpoint { pos = { 1049.37, -416.408, 17.3975 } }
|
||||
checkpoint { pos = { 1091.72, -553.691, 12.5552 } }]]
|
||||
@@ -1,9 +0,0 @@
|
||||
resource_type 'gametype' { name = 'Race' }
|
||||
|
||||
dependencies {
|
||||
"spawnmanager",
|
||||
"mapmanager"
|
||||
}
|
||||
|
||||
client_script 'race_client.lua'
|
||||
server_script 'race_server.lua'
|
||||
@@ -1,469 +0,0 @@
|
||||
local curCheckpoint, nextCheckpoint
|
||||
local goGoGo
|
||||
|
||||
local playerCar
|
||||
local weFinished
|
||||
local resultsShown
|
||||
|
||||
local checkpoints = {}
|
||||
local playerScores = {}
|
||||
|
||||
local function initializeMap()
|
||||
echo("[RACE] initializeMap\n")
|
||||
|
||||
TriggerServerEvent('race:updateCheckpoints', checkpoints)
|
||||
end
|
||||
|
||||
local function resetGameMode()
|
||||
curCheckpoint = nil
|
||||
nextCheckpoint = nil
|
||||
|
||||
SetMultiplayerHudTime('')
|
||||
|
||||
checkpointCount = 0
|
||||
playerScores = {}
|
||||
|
||||
if IsThisMachineTheServer() then
|
||||
-- load the initial map
|
||||
initializeMap()
|
||||
end
|
||||
|
||||
goGoGo = false
|
||||
weFinished = false
|
||||
resultsShown = false
|
||||
end
|
||||
|
||||
local function updatePositions()
|
||||
local players = {}
|
||||
|
||||
for id, data in pairs(playerScores) do
|
||||
data.playerId = id
|
||||
|
||||
table.insert(players, data)
|
||||
end
|
||||
|
||||
table.sort(players, function(a, b)
|
||||
if a.finishPosition or b.finishPosition then
|
||||
if not b.finishPosition then
|
||||
return true
|
||||
end
|
||||
|
||||
if not a.finishPosition then
|
||||
return false
|
||||
end
|
||||
|
||||
return a.finishPosition < b.finishPosition
|
||||
end
|
||||
|
||||
if a.cp == b.cp then
|
||||
local aPed = a.ped
|
||||
local bPed = b.ped
|
||||
|
||||
local aPos
|
||||
local bPos
|
||||
|
||||
if not DoesCharExist(aPed) or not DoesCharExist(bPed) then
|
||||
aPos = { 0, 0 }
|
||||
bPos = { 0, 0 }
|
||||
else
|
||||
aPos = a.ped.position
|
||||
bPos = b.ped.position
|
||||
end
|
||||
|
||||
local nextCp = checkpoints[a.cp + 1]
|
||||
|
||||
if not nextCp then
|
||||
return a.cp > b.cp
|
||||
end
|
||||
|
||||
local aDist = GetDistanceBetweenCoords2d(aPos[1], aPos[2], nextCp.pos[1], nextCp.pos[2])
|
||||
local bDist = GetDistanceBetweenCoords2d(bPos[1], bPos[2], nextCp.pos[1], nextCp.pos[2])
|
||||
|
||||
return aDist < bDist
|
||||
end
|
||||
|
||||
return a.cp > b.cp
|
||||
end)
|
||||
|
||||
if not playerScores[GetPlayerId().serverId] then
|
||||
return
|
||||
end
|
||||
|
||||
local lastPosition = selfLastPosition
|
||||
|
||||
local i = 1
|
||||
|
||||
for _, v in ipairs(players) do
|
||||
playerScores[v.playerId].position = i
|
||||
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
local selfPosition = playerScores[GetPlayerId().serverId].position
|
||||
selfLastPosition = selfPosition
|
||||
|
||||
if selfPosition ~= lastPosition then
|
||||
TriggerEvent('chatMessage', '', { 0, 0, 0 }, 'position changed to ' .. tostring(selfPosition) .. ' from ' .. tostring(lastPosition))
|
||||
end
|
||||
|
||||
|
||||
-- positions updated, we hope
|
||||
end
|
||||
|
||||
AddEventHandler('race:onPlayerFinished', function(player, data)
|
||||
local selfId = GetPlayerId().serverId
|
||||
|
||||
if not playerScores[player] then
|
||||
local ped = sPlayer.ped
|
||||
|
||||
playerScores[player] = {
|
||||
cp = #checkpoints,
|
||||
ped = ped,
|
||||
vehicle = ped.vehicle
|
||||
}
|
||||
end
|
||||
|
||||
playerScores[player].finishPosition = data.position
|
||||
|
||||
if selfId == player then
|
||||
exports.obituary:printObituary('New world record!')
|
||||
|
||||
TriggerEvent('chatMessage', '', { 0, 0, 0 }, 'you finished!')
|
||||
|
||||
weFinished = true
|
||||
|
||||
tearDownCheckpoint(curCheckpoint)
|
||||
tearDownCheckpoint(nextCheckpoint)
|
||||
|
||||
-- todo: spectate?
|
||||
|
||||
CreateThread(function()
|
||||
Wait(500)
|
||||
|
||||
if playerCar then
|
||||
FreezeCarPosition(playerCar, true)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local sPlayer = GetPlayerByServerId(player)
|
||||
|
||||
if sPlayer then
|
||||
exports.obituary:printObituary('<b>%s</b> finished in %s seconds', sPlayer.name, tostring(data.finishSeconds))
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('onClientGameTypeStart', function()
|
||||
CreateThread(function()
|
||||
--[[while true do
|
||||
Wait(500)
|
||||
|
||||
local player = GetPlayerId()
|
||||
|
||||
TriggerServerEvent('race:updatePos', player.ped.position)
|
||||
end]]
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(250)
|
||||
|
||||
updatePositions()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
function GetPlayerInteger(i)
|
||||
local serverId = i.serverId
|
||||
local players = GetPlayers()
|
||||
|
||||
for k, v in ipairs(players) do
|
||||
if v.serverId == serverId then
|
||||
return k
|
||||
end
|
||||
end
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
local function spawnVehicle(spawnPoint)
|
||||
local carModel
|
||||
|
||||
if not spawnPoint.carModel then
|
||||
carModel = 'admiral'
|
||||
else
|
||||
carModel = spawnPoint.carModel
|
||||
end
|
||||
|
||||
if not tonumber(carModel) then
|
||||
carModel = GetHashKey(carModel, _r)
|
||||
end
|
||||
|
||||
-- is the model actually a model?
|
||||
if not IsModelInCdimage(carModel) then
|
||||
error("invalid spawn model")
|
||||
end
|
||||
|
||||
-- is is even a vehicle?
|
||||
if not IsThisModelAVehicle(carModel) then
|
||||
error("this model ain't a vehicle!")
|
||||
end
|
||||
|
||||
-- spawn a vehicle for our lovely player
|
||||
RequestModel(carModel)
|
||||
LoadAllObjectsNow()
|
||||
|
||||
playerCar = CreateCar(carModel, spawnPoint.x, spawnPoint.y, spawnPoint.z, 0, 1)
|
||||
SetCarHeading(playerCar, spawnPoint.heading)
|
||||
SetCarOnGroundProperly(playerCar)
|
||||
|
||||
WarpCharIntoCar(GetPlayerId().ped, playerCar)
|
||||
|
||||
if not goGoGo then
|
||||
FreezeCarPosition(playerCar, true)
|
||||
end
|
||||
|
||||
LockCarDoors(playerCar, 4)
|
||||
|
||||
-- and done, hopefully.
|
||||
end
|
||||
|
||||
AddEventHandler('race:itsGoTime', function()
|
||||
if playerCar then
|
||||
-- let go of the brakes
|
||||
FreezeCarPosition(playerCar, false)
|
||||
end
|
||||
|
||||
-- gogogo
|
||||
goGoGo = true
|
||||
end)
|
||||
|
||||
string.lpad = function(str, len, char)
|
||||
if char == nil then char = ' ' end
|
||||
return string.rep(char, len - #str) .. str
|
||||
end
|
||||
|
||||
AddEventHandler('race:results', function(time)
|
||||
if playerCar then
|
||||
FreezeCarPosition(playerCar, true)
|
||||
end
|
||||
|
||||
tearDownCheckpoint(curCheckpoint)
|
||||
tearDownCheckpoint(nextCheckpoint)
|
||||
|
||||
SetMultiplayerHudTime('')
|
||||
|
||||
updatePositions()
|
||||
|
||||
local players = {}
|
||||
|
||||
for id, data in pairs(playerScores) do
|
||||
table.insert(players, data)
|
||||
end
|
||||
|
||||
table.sort(players, function(a, b) return a.position < b.position end)
|
||||
|
||||
TriggerEvent('chatMessage', '', { 0, 0, 0 }, 'RESULTS')
|
||||
|
||||
for i, p in ipairs(players) do
|
||||
local name = '**INVALID**'
|
||||
local sp = GetPlayerByServerId(p.playerId)
|
||||
|
||||
if sp then
|
||||
name = sp.name
|
||||
end
|
||||
|
||||
TriggerEvent('chatMessage', '', { 0, 0, 0 }, tostring(i) .. '. ' .. name)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('race:hurryUp', function(time)
|
||||
CreateThread(function()
|
||||
echo("resultsShown: " .. tostring(resultsShown) .. " , weF: " .. tostring(weFinished) .. "\n")
|
||||
|
||||
while not resultsShown and not weFinished do
|
||||
Wait(1000)
|
||||
|
||||
time = time - 1000
|
||||
|
||||
SetMultiplayerHudTime('00:' .. tostring(math.floor(time / 1000)):lpad(2, '0'))
|
||||
echo(tostring(math.floor(time / 1000)):lpad(2, '0') .. ':' .. tostring(math.floor((time % 1000) / 100)):lpad(2, '0') .. "\n")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
AddEventHandler('race:showGoMessage', function(message)
|
||||
TriggerEvent('chatMessage', '', { 0, 0, 0 }, message)
|
||||
end)
|
||||
|
||||
AddEventHandler('onClientMapStart', function(res)
|
||||
resetGameMode()
|
||||
|
||||
requestedGo = true
|
||||
|
||||
TriggerServerEvent('race:requestGo')
|
||||
end)
|
||||
|
||||
AddEventHandler('onClientMapStop', function(res)
|
||||
DoScreenFadeOut(50)
|
||||
end)
|
||||
|
||||
AddEventHandler('race:weGotPorn', function()
|
||||
echo("[RACE] race:weGotPorn\n")
|
||||
|
||||
if not requestedGo then
|
||||
return
|
||||
end
|
||||
|
||||
requestedGo = false
|
||||
|
||||
exports.spawnmanager:setAutoSpawn(false)
|
||||
|
||||
exports.spawnmanager:spawnPlayer(GetPlayerInteger(GetPlayerId()), function(spawnPoint)
|
||||
spawnVehicle(spawnPoint)
|
||||
end)
|
||||
|
||||
TriggerServerEvent('race:requestCheckpoint', '1234')
|
||||
end)
|
||||
|
||||
local function setUpCheckpoint(cp, next)
|
||||
local nextPos, typeNum
|
||||
|
||||
if next then
|
||||
nextPos = next.pos
|
||||
typeNum = 2
|
||||
else
|
||||
nextPos = { 0.0, 0.0, 0.0 }
|
||||
typeNum = 3
|
||||
end
|
||||
|
||||
-- 2 = regular 'ground', 3 = finish 'ground', others are different 3dmarker types
|
||||
cp.handle = CreateCheckpoint(typeNum, cp.pos[1], cp.pos[2], cp.pos[3] + 2.5, nextPos[1], nextPos[2], nextPos[3], 1.0001, _r)
|
||||
cp.blip = AddBlipForCoord(cp.pos[1], cp.pos[2], cp.pos[3], _i)
|
||||
|
||||
if cp == nextCheckpoint then
|
||||
ChangeBlipScale(cp.blip, 0.8)
|
||||
end
|
||||
|
||||
ChangeBlipSprite(cp.blip, 3)
|
||||
end
|
||||
|
||||
function tearDownCheckpoint(cp)
|
||||
if not cp then
|
||||
return
|
||||
end
|
||||
|
||||
if cp.blip then
|
||||
RemoveBlip(cp.blip)
|
||||
cp.blip = nil
|
||||
end
|
||||
|
||||
if cp.handle then
|
||||
DeleteCheckpoint(cp.handle)
|
||||
cp.handle = nil
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('race:setCheckpoint', function(cur, next, later)
|
||||
if curCheckpoint then
|
||||
tearDownCheckpoint(curCheckpoint)
|
||||
end
|
||||
|
||||
if nextCheckpoint then
|
||||
tearDownCheckpoint(nextCheckpoint)
|
||||
end
|
||||
|
||||
curCheckpoint = cur
|
||||
nextCheckpoint = next
|
||||
|
||||
if cur then
|
||||
setUpCheckpoint(curCheckpoint, nextCheckpoint)
|
||||
|
||||
-- make a background thread waiting for the checkpoint to be reached
|
||||
CreateThread(function()
|
||||
local localCur = curCheckpoint
|
||||
|
||||
-- so we exit if the checkpoint target is changed
|
||||
while curCheckpoint == localCur do
|
||||
Wait(25)
|
||||
|
||||
if playerCar then
|
||||
local px, py, pz = GetCarCoordinates(playerCar)
|
||||
local distance = GetDistanceBetweenCoords2d(px, py, localCur.pos[1], localCur.pos[2])
|
||||
|
||||
if distance < 10 then
|
||||
-- pass the fact we reached the checkpoint to the server
|
||||
TriggerServerEvent('race:gotCP', '1234')
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if next then
|
||||
setUpCheckpoint(nextCheckpoint, later)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('race:confirmCP', function()
|
||||
PlayAudioEvent('FRONTEND_GAME_PICKUP_CHECKPOINT')
|
||||
end)
|
||||
|
||||
AddEventHandler('race:updateStatus', function(player, curCP)
|
||||
if curCP == -1 then
|
||||
playerScores[player] = nil
|
||||
end
|
||||
|
||||
local sPlayer = GetPlayerByServerId(player)
|
||||
|
||||
if not sPlayer then
|
||||
return
|
||||
end
|
||||
|
||||
local ped = sPlayer.ped
|
||||
|
||||
playerScores[player] = {
|
||||
cp = curCP,
|
||||
ped = ped,
|
||||
vehicle = ped.vehicle
|
||||
}
|
||||
|
||||
TriggerEvent('chatMessage', '', { 0, 0, 0 }, sPlayer.name .. ' now has cp ' .. curCP)
|
||||
|
||||
updatePositions()
|
||||
end)
|
||||
|
||||
AddEventHandler('onClientMapStop', function()
|
||||
if playerCar then
|
||||
MarkCarAsNoLongerNeeded(playerCar)
|
||||
playerCar = nil
|
||||
end
|
||||
|
||||
if curCheckpoint and curCheckpoint.handle then
|
||||
DeleteCheckpoint(curCheckpoint.handle)
|
||||
end
|
||||
|
||||
if nextCheckpoint and nextCheckpoint.handle then
|
||||
DeleteCheckpoint(nextCheckpoint.handle)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('getMapDirectives', function(add)
|
||||
-- call the remote callback
|
||||
add('checkpoint', function(state, data)
|
||||
table.insert(checkpoints, data)
|
||||
|
||||
state.add('pos', data.pos)
|
||||
|
||||
-- delete callback follows on the next line
|
||||
end, function(state, arg)
|
||||
for i, sp in ipairs(checkpoints) do
|
||||
if sp.pos[1] == state.pos[1] and sp.pos[2] == state.pos[2] and sp.pos[3] == state.pos[3] then
|
||||
table.remove(checkpoints, i)
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@@ -1,209 +0,0 @@
|
||||
local checkpoints = {}
|
||||
local raceId = 0
|
||||
|
||||
RegisterServerEvent('race:updateCheckpoints')
|
||||
|
||||
AddEventHandler('race:updateCheckpoints', function(cps)
|
||||
if #checkpoints > 0 then
|
||||
return
|
||||
end
|
||||
|
||||
checkpoints = cps
|
||||
|
||||
TriggerClientEvent('race:weGotPorn', -1)
|
||||
end)
|
||||
|
||||
local playerData = {}
|
||||
|
||||
local function ensurePlayerData(id)
|
||||
if playerData[id] then
|
||||
return
|
||||
end
|
||||
|
||||
playerData[id] = {
|
||||
curCheckpoint = 0
|
||||
}
|
||||
end
|
||||
|
||||
local raceStarted = false
|
||||
local playerCount = 0
|
||||
|
||||
local function startRace()
|
||||
raceStarted = true
|
||||
|
||||
print("really starting race")
|
||||
|
||||
local function raceCountdown(num)
|
||||
local time = (4000 - (num * 1000))
|
||||
|
||||
print("setting countdown for " .. tostring(time))
|
||||
|
||||
SetTimeout(time, function()
|
||||
print("trig'd countdown for " .. tostring(time))
|
||||
|
||||
if num == 0 then
|
||||
TriggerClientEvent('race:itsGoTime', -1, 0)
|
||||
TriggerClientEvent('race:showGoMessage', -1, 'GO')
|
||||
else
|
||||
TriggerClientEvent('race:showGoMessage', -1, tostring(num))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
raceCountdown(3) -- 3...
|
||||
raceCountdown(2) -- 2...
|
||||
raceCountdown(1) -- 1...
|
||||
raceCountdown(0) -- GOGOGO
|
||||
end
|
||||
|
||||
local function incrementPlayerCount()
|
||||
playerCount = playerCount + 1
|
||||
|
||||
if playerCount > 4 then
|
||||
startRace()
|
||||
end
|
||||
|
||||
if playerCount == 1 then
|
||||
SetTimeout(3000, function()
|
||||
if raceStarted then
|
||||
return
|
||||
end
|
||||
|
||||
print("starting race")
|
||||
|
||||
startRace()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local playersFinished
|
||||
local raceEnded
|
||||
|
||||
AddEventHandler('onMapStart', function()
|
||||
playerCount = 0
|
||||
playersFinished = 0
|
||||
raceId = raceId + 1
|
||||
raceStarted = false
|
||||
raceEnded = false
|
||||
|
||||
playerData = {}
|
||||
checkpoints = {}
|
||||
|
||||
print("mmmmmm race")
|
||||
end)
|
||||
|
||||
local function endRace()
|
||||
raceEnded = true
|
||||
|
||||
TriggerClientEvent('race:results', -1, '1234')
|
||||
|
||||
SetTimeout(7500, function()
|
||||
TriggerEvent('mapmanager:roundEnded')
|
||||
end)
|
||||
end
|
||||
|
||||
AddEventHandler('race:onPlayerFinished', function(player)
|
||||
print(GetPlayerName(player) .. ' finished')
|
||||
|
||||
local data = playerData[player]
|
||||
local finishSeconds = os.clock() - data.startTime
|
||||
|
||||
local position = playersFinished + 1
|
||||
data.position = position
|
||||
playersFinished = position
|
||||
|
||||
TriggerClientEvent('race:onPlayerFinished', -1, player, {
|
||||
finishSeconds = finishSeconds,
|
||||
position = position
|
||||
})
|
||||
|
||||
if playersFinished == playerCount then
|
||||
endRace()
|
||||
elseif playersFinished == 1 then
|
||||
local thisRaceId = raceId
|
||||
|
||||
TriggerClientEvent('race:hurryUp', -1, 30000)
|
||||
|
||||
SetTimeout(30000, function()
|
||||
if raceId ~= thisRaceId or raceEnded then
|
||||
return
|
||||
end
|
||||
|
||||
endRace()
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerActivated', function()
|
||||
if #checkpoints > 0 then
|
||||
TriggerClientEvent('race:weGotPorn', source)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('race:requestGo')
|
||||
|
||||
AddEventHandler('race:requestGo', function()
|
||||
if #checkpoints > 0 then
|
||||
TriggerClientEvent('race:weGotPorn', source)
|
||||
end
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function(player)
|
||||
if playerData[player] and playerData[player].curCheckpoint > 0 then
|
||||
TriggerClientEvent('race:updateStatus', -1, player, -1)
|
||||
|
||||
playerCount = playerCount - 1
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('race:gotCP')
|
||||
|
||||
AddEventHandler('race:gotCP', function()
|
||||
ensurePlayerData(source)
|
||||
|
||||
local data = playerData[source]
|
||||
|
||||
local next = data.curCheckpoint + 1
|
||||
|
||||
if next > #checkpoints then
|
||||
print("omg finished")
|
||||
|
||||
TriggerEvent('race:onPlayerFinished', source)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
data.curCheckpoint = next
|
||||
|
||||
TriggerClientEvent('race:confirmCP', source) -- for sound effects
|
||||
TriggerClientEvent('race:setCheckpoint', source, checkpoints[next], checkpoints[next + 1], checkpoints[next + 2])
|
||||
TriggerClientEvent('race:updateStatus', -1, source, next - 1)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('race:requestCheckpoint')
|
||||
|
||||
AddEventHandler('race:requestCheckpoint', function()
|
||||
print('is it even in here')
|
||||
|
||||
ensurePlayerData(source)
|
||||
|
||||
print(source, 'requesting cp')
|
||||
|
||||
if playerData[source].curCheckpoint == 0 then
|
||||
incrementPlayerCount()
|
||||
|
||||
print(source, 'requesting cp 0')
|
||||
|
||||
local curCP = 1
|
||||
playerData[source].curCheckpoint = curCP
|
||||
playerData[source].startTime = os.clock()
|
||||
|
||||
TriggerClientEvent('race:setCheckpoint', source, checkpoints[curCP], checkpoints[curCP + 1], checkpoints[curCP + 2])
|
||||
TriggerClientEvent('race:updateStatus', -1, source, 0)
|
||||
|
||||
-- should have raceReallyStarted since 4-second countdown
|
||||
if raceStarted then
|
||||
TriggerClientEvent('race:itsGoTime', -1, 0)
|
||||
end
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user