From 1192e4614b6fc375f661572aa105780e312082cd Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Tue, 2 Nov 2021 06:44:00 +0100
Subject: [PATCH 1/9] Refactor play.
---
[gamemodes]/[play]/play/meta.xml | 14 +-
[gamemodes]/[play]/play/play.lua | 20 +
[gamemodes]/[play]/play/play_players.lua | 39 ++
.../play/{broph.lua => play_vehicles.lua} | 345 +++++++++---------
4 files changed, 235 insertions(+), 183 deletions(-)
create mode 100644 [gamemodes]/[play]/play/play.lua
create mode 100644 [gamemodes]/[play]/play/play_players.lua
rename [gamemodes]/[play]/play/{broph.lua => play_vehicles.lua} (51%)
diff --git a/[gamemodes]/[play]/play/meta.xml b/[gamemodes]/[play]/play/meta.xml
index 90e1cf2f0..4532482a9 100644
--- a/[gamemodes]/[play]/play/meta.xml
+++ b/[gamemodes]/[play]/play/meta.xml
@@ -1,13 +1,13 @@
- true
-
-
-
+
+
+
+
+
-
+
-
-
+
\ No newline at end of file
diff --git a/[gamemodes]/[play]/play/play.lua b/[gamemodes]/[play]/play/play.lua
new file mode 100644
index 000000000..b8b8afb0e
--- /dev/null
+++ b/[gamemodes]/[play]/play/play.lua
@@ -0,0 +1,20 @@
+function onResourceStartPlay()
+ resetMapInfo()
+ createVehicles()
+
+ local playersTable = getElementsByType("player")
+
+ for playerID = 1, #playersTable do
+ local playerElement = playersTable[playerID]
+
+ playSpawnPlayer(playerElement)
+ end
+
+ addEventHandler("onPlayerJoin", root, onPlayerJoinOrWasted)
+ addEventHandler("onPlayerWasted", root, onPlayerJoinOrWasted)
+ addEventHandler("onPlayerQuit", root, onPlayerQuit)
+ addEventHandler("onVehicleEnter", resourceRoot, onVehicleEnter)
+ addEventHandler("onVehicleExit", resourceRoot, onVehicleExit)
+ addEventHandler("onElementDestroy", resourceRoot, onVehicleElementDestroy)
+end
+addEventHandler("onResourceStart", resourceRoot, onResourceStartPlay)
\ No newline at end of file
diff --git a/[gamemodes]/[play]/play/play_players.lua b/[gamemodes]/[play]/play/play_players.lua
new file mode 100644
index 000000000..80e3458cf
--- /dev/null
+++ b/[gamemodes]/[play]/play/play_players.lua
@@ -0,0 +1,39 @@
+local playerSkins = {0, 1, 2, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312}
+local playerSpawns = { {-711, 957, 12.4, 90}, {2005, 1543, 13.5, 270}, {2485, -1667, 13.3, 0}, {-2405, -598, 132.6, 128} }
+local spawnsCount = #playerSpawns
+local skinsCount = #playerSkins
+
+function playSpawnPlayer(playerElement)
+ local validPlayer = isElement(playerElement)
+
+ if validPlayer then
+ local randomSpawn = math.random(1, spawnsCount)
+ local spawnData = playerSpawns[randomSpawn]
+ local posX, posY, posZ, rotX = spawnData[1] + math.random(-3, 3), spawnData[2] + math.random(-3, 3), spawnData[3], spawnData[4]
+ local randomSkin = math.random(1, skinsCount)
+ local skinID = playerSkins[randomSkin]
+
+ spawnPlayer(playerElement, posX, posY, posZ, rotX, skinID, 0, 0, nil)
+ fadeCamera(playerElement, true)
+ setCameraTarget(playerElement, playerElement)
+ end
+end
+
+function onPlayerJoinOrWasted()
+ local joinEvent = eventName == "onPlayerJoin"
+
+ if joinEvent then
+ playSpawnPlayer(source)
+ else
+ local playerRespawnTime = get("playerRespawnTime")
+
+ playerRespawnTime = tonumber(playerRespawnTime) or 5000
+ playerRespawnTime = playerRespawnTime > 50 and playerRespawnTime or 50
+
+ setTimer(playSpawnPlayer, playerRespawnTime, 1, source)
+ end
+end
+
+function onPlayerQuit()
+ destroyPlayerVehicles(source)
+end
\ No newline at end of file
diff --git a/[gamemodes]/[play]/play/broph.lua b/[gamemodes]/[play]/play/play_vehicles.lua
similarity index 51%
rename from [gamemodes]/[play]/play/broph.lua
rename to [gamemodes]/[play]/play/play_vehicles.lua
index 9be80f532..bb5524799 100644
--- a/[gamemodes]/[play]/play/broph.lua
+++ b/[gamemodes]/[play]/play/play_vehicles.lua
@@ -1,176 +1,169 @@
-local vehiclesToSpawn =
-{
- {557, -676.43225097656, 962.98449707031, 12.507791519165, 92.063659667969},
- {557, -676.67596435547, 968.88238525391, 12.507817268372, 89.458343505859},
- {429, -696.71008300781, 947.44274902344, 11.961327552795, 43.260345458984},
- {429, -700.66668701172, 946.43811035156, 12.032683372498, 41.218505859375},
- {541, -708.88635253906, 939.77947998047, 12.079864501953, 180.60076904297},
- {481, -679.98175048828, 931.08044433594, 11.648596763611, 88.025085449219},
- {481, -679.97430419922, 932.28381347656, 11.64875125885, 87.565948486328},
- {469, -655.177734375, 963.35192871094, 12.175182342529, 89.811737060547},
- {468, -681.74114990234, 912.31903076172, 11.776277542114, 189.92042541504},
- {468, -680.06512451172, 912.44622802734, 11.779381752014, 191.75022888184},
- {468, -678.29089355469, 912.71087646484, 11.77979183197, 200.86720275879},
- {493, -649.33892822266, 867.71429443359, -0.10552111268044, 228.00956726074},
- {473, -661.28826904297, 876.15618896484, -0.30112856626511, 227.04469299316},
- {484, -647.07635498047, 876.42327880859, 0.22773677110672, 226.89099121094},
- {568, -696.35430908203, 929.35675048828, 12.135828971863, 178.99200439453},
- {511, -696.59759521484, 897.68084716797, 13.838381767273, 176.86285400391},
- {402, -686.66400146484, 969.24591064453, 11.975840568542, 89.380676269531},
- {475, -687.01416015625, 963.00555419922, 11.94958114624, 89.711608886719},
- {457, -686.92352294922, 966.03717041016, 11.767498970032, 89.163909912109},
- {469, 2526.2607421875, -1677.2861328125, 19.913991928101, 91.994018554688},
- {468, 2508.7177734375, -1680.568359375, 13.305373191833, 47.999267578125},
- {468, 2506.615234375, -1682.3544921875, 13.305373191833, 47.999267578125},
- {468, 2504.4423828125, -1684.208984375, 13.305373191833, 47.999267578125},
- {557, 2512.4736328125, -1675.9833984375, 13.937532424927, 89.983520507813},
- {557, 2512.6044921875, -1669.4228515625, 13.869720458984, 90.005493164063},
- {402, 2473.427734375, -1692.513671875, 13.326358795166, 0},
- {568, 2466.70703125, -1687.779296875, 13.489582061768, 272.4938659668},
- {457, 2505.09765625, -1651.40625, 13.352488517761, 135.99975585938},
- {475, 2459.9892578125, -1670.1943359375, 13.249677658081, 0},
- {541, 2452.68359375, -1670.029296875, 13.199068069458, 0},
- {429, 2447.8662109375, -1669.93359375, 13.184649467468, 359.99447631836},
- {429, 2443.0263671875, -1669.81640625, 13.260643005371, 359.99447631836},
- {557, -2398.5610351563, -611.85290527344, 133.04846191406, 36},
- {557, -2393.6850585938, -608.3828125, 133.04846191406, 35.996704101563},
- {402, -2393.4907226563, -599.73876953125, 132.58843994141, 125.5},
- {568, -2396.79296875, -594.94836425781, 132.74308776855, 125.49682617188},
- {457, -2407.7419433594, -577.97015380859, 132.47640991211, 126.00003051758},
- {475, -2403.4738769531, -585.46215820313, 132.54843139648, 126.00003051758},
- {541, -2399.7482910156, -590.07781982422, 132.34843444824, 123.99987792969},
- {429, -2416.1259765625, -589.61535644531, 132.3984375, 213.99717712402},
- {429, -2411.0979003906, -586.19421386719, 132.3984375, 213.99717712402},
- {468, -2389.4606933594, -604.095703125, 132.53031921387, 123.99996948242},
- {468, -2388.0568847656, -606.24896240234, 132.53031921387, 123.99719238281},
- {468, -2386.5554199219, -608.55224609375, 132.53031921387, 123.99719238281},
- {469, -2444.1838378906, -604.26513671875, 132.51147460938, 300.00003051758},
- {468, 2030.5123291016, 1557.0339355469, 10.580312728882, 272},
- {468, 2030.7028808594, 1559.1748046875, 10.580312728882, 271.99951171875},
- {468, 2031.1046142578, 1561.4478759766, 10.580312728882, 271.99951171875},
- {557, 2025.6492919922, 1535.8363037109, 11.120292663574, 270.00003051758},
- {557, 2024.8865966797, 1526.9187011719, 11.120292663574, 270.00003051758},
- {402, 2024.3311767578, 1519.9007568359, 10.760312080383, 270.00003051758},
- {568, 2024.1086425781, 1515.0710449219, 10.79531288147, 270.00003051758},
- {457, 2024.5035400391, 1510.8114013672, 10.549660682678, 270.00003051758},
- {475, 2024.2908935547, 1506.1636962891, 10.72031211853, 270.00003051758},
- {541, 2024.7091064453, 1499.3103027344, 10.520312309265, 270.00003051758},
- {429, 2025.9349365234, 1490.2434082031, 10.5703125, 270.00003051758},
- {429, 2025.6474609375, 1494.671875, 10.5703125, 270.00003051758},
- {469, 2024.5600585938, 1623.0500488281, 12.002040863037, 270.00003051758},
-}
-
-local spawnpoints =
-{
- {-711,957,12.4,90},
- {2005,1543,13.5,270},
- {2485,-1667,13.3,0},
- {-2405,-598,132.6,128},
-}
-
-local vehicleDestroyTimers = {}
-local validSkins = {0, 1, 2, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312}
-local playerVehicles = {}
-
-local function spawn(player)
-
- if player and isElement(player) then
- local x,y,z,r = unpack(spawnpoints[math.random(1,#spawnpoints)])
- spawnPlayer(player,x+math.random(-3,3),y+math.random(-3,3),z,r,validSkins[math.random(1,#validSkins)],0,0)
- fadeCamera(player, true)
- setCameraTarget(player, player)
- end
-end
-
-local function onJoin()
-
- spawn(source)
-
-end
-
-local function onWasted()
-
- local t = tonumber(get("playerRespawnTime")) or 5000
- setTimer(spawn,(t > 50 and t or 50),1,source)
-
-end
-
-local function destroyPlayerVehicles()
-
- local vehicles = playerVehicles[source]
-
- for _,vehicle in ipairs(vehicles) do
- if isElement(vehicle) then
- destroyElement(vehicle)
- end
- end
-
- playerVehicles[source] = nil
-
-end
-
-local function onEnter(player)
-
- local t = tonumber(get("vehicleRespawnTime")) or 60000
- source.damageProof = false
- source.frozen = false
- local vehicledata = vehiclesToSpawn[source]
- setTimer(createNewVehicle,(t > 50 and t or 50),1,vehicledata)
- vehiclesToSpawn[source] = nil
- if not playerVehicles[player] then
- playerVehicles[player] = {}
- addEventHandler("onPlayerQuit",player,destroyPlayerVehicles)
- end
- table.insert(playerVehicles[player],source)
- removeEventHandler("onVehicleEnter",source,onEnter)
-
-end
-
-local function destroyVehicle(vehicle)
-
- if vehicle and isElement(vehicle) and getElementType(vehicle) == "vehicle" then
- destroyElement(vehicle)
- end
-end
-
-local function destroyTimer()
-
- if vehicleDestroyTimers[source] and isTimer(vehicleDestroyTimers[source]) then killTimer(vehicleDestroyTimers[source]) end
- removeEventHandler("onVehicleEnter",source,destroyTimer)
-
-end
-
-local function onExit()
-
- local t = tonumber(get("vehicleExpireTime")) or 600000
- vehicleDestroyTimers[source] = setTimer(destroyVehicle,(t > 50 and t or 50),1,source)
- addEventHandler("onVehicleEnter",source,destroyTimer)
-
-end
-
-function createNewVehicle(vehicledata)
-
- local m,x,y,z,r = unpack(vehicledata)
- local vehicle = Vehicle(m,x,y,z,0,0,r)
- vehicle.damageProof = true
- vehicle.frozen = true
- vehiclesToSpawn[vehicle] = vehicledata
- addEventHandler("onVehicleEnter",vehicle,onEnter)
- addEventHandler("onVehicleExit",vehicle,onExit)
-
-end
-
-local function initScript()
-
- resetMapInfo()
- local players = getElementsByType("player")
-
- for _,player in ipairs(players) do spawn(player) end
- for _,vehicledata in ipairs(vehiclesToSpawn) do createNewVehicle(vehicledata) end
-
- addEventHandler("onPlayerJoin",root,onJoin)
- addEventHandler("onPlayerWasted",root,onWasted)
-
-end
-
-addEventHandler("onResourceStart",resourceRoot,initScript)
+local vehicleTimers = {}
+local playerVehicles = {}
+local vehiclesToSpawn = {}
+local vehicleSpawns = {
+ {557, -676.43225097656, 962.98449707031, 12.507791519165, 92.063659667969},
+ {557, -676.67596435547, 968.88238525391, 12.507817268372, 89.458343505859},
+ {429, -696.71008300781, 947.44274902344, 11.961327552795, 43.260345458984},
+ {429, -700.66668701172, 946.43811035156, 12.032683372498, 41.218505859375},
+ {541, -708.88635253906, 939.77947998047, 12.079864501953, 180.60076904297},
+ {481, -679.98175048828, 931.08044433594, 11.648596763611, 88.025085449219},
+ {481, -679.97430419922, 932.28381347656, 11.64875125885, 87.565948486328},
+ {469, -655.177734375, 963.35192871094, 12.175182342529, 89.811737060547},
+ {468, -681.74114990234, 912.31903076172, 11.776277542114, 189.92042541504},
+ {468, -680.06512451172, 912.44622802734, 11.779381752014, 191.75022888184},
+ {468, -678.29089355469, 912.71087646484, 11.77979183197, 200.86720275879},
+ {493, -649.33892822266, 867.71429443359, -0.10552111268044, 228.00956726074},
+ {473, -661.28826904297, 876.15618896484, -0.30112856626511, 227.04469299316},
+ {484, -647.07635498047, 876.42327880859, 0.22773677110672, 226.89099121094},
+ {568, -696.35430908203, 929.35675048828, 12.135828971863, 178.99200439453},
+ {511, -696.59759521484, 897.68084716797, 13.838381767273, 176.86285400391},
+ {402, -686.66400146484, 969.24591064453, 11.975840568542, 89.380676269531},
+ {475, -687.01416015625, 963.00555419922, 11.94958114624, 89.711608886719},
+ {457, -686.92352294922, 966.03717041016, 11.767498970032, 89.163909912109},
+ {469, 2526.2607421875, -1677.2861328125, 19.913991928101, 91.994018554688},
+ {468, 2508.7177734375, -1680.568359375, 13.305373191833, 47.999267578125},
+ {468, 2506.615234375, -1682.3544921875, 13.305373191833, 47.999267578125},
+ {468, 2504.4423828125, -1684.208984375, 13.305373191833, 47.999267578125},
+ {557, 2512.4736328125, -1675.9833984375, 13.937532424927, 89.983520507813},
+ {557, 2512.6044921875, -1669.4228515625, 13.869720458984, 90.005493164063},
+ {402, 2473.427734375, -1692.513671875, 13.326358795166, 0},
+ {568, 2466.70703125, -1687.779296875, 13.489582061768, 272.4938659668},
+ {457, 2505.09765625, -1651.40625, 13.352488517761, 135.99975585938},
+ {475, 2459.9892578125, -1670.1943359375, 13.249677658081, 0},
+ {541, 2452.68359375, -1670.029296875, 13.199068069458, 0},
+ {429, 2447.8662109375, -1669.93359375, 13.184649467468, 359.99447631836},
+ {429, 2443.0263671875, -1669.81640625, 13.260643005371, 359.99447631836},
+ {557, -2398.5610351563, -611.85290527344, 133.04846191406, 36},
+ {557, -2393.6850585938, -608.3828125, 133.04846191406, 35.996704101563},
+ {402, -2393.4907226563, -599.73876953125, 132.58843994141, 125.5},
+ {568, -2396.79296875, -594.94836425781, 132.74308776855, 125.49682617188},
+ {457, -2407.7419433594, -577.97015380859, 132.47640991211, 126.00003051758},
+ {475, -2403.4738769531, -585.46215820313, 132.54843139648, 126.00003051758},
+ {541, -2399.7482910156, -590.07781982422, 132.34843444824, 123.99987792969},
+ {429, -2416.1259765625, -589.61535644531, 132.3984375, 213.99717712402},
+ {429, -2411.0979003906, -586.19421386719, 132.3984375, 213.99717712402},
+ {468, -2389.4606933594, -604.095703125, 132.53031921387, 123.99996948242},
+ {468, -2388.0568847656, -606.24896240234, 132.53031921387, 123.99719238281},
+ {468, -2386.5554199219, -608.55224609375, 132.53031921387, 123.99719238281},
+ {469, -2444.1838378906, -604.26513671875, 132.51147460938, 300.00003051758},
+ {468, 2030.5123291016, 1557.0339355469, 10.580312728882, 272},
+ {468, 2030.7028808594, 1559.1748046875, 10.580312728882, 271.99951171875},
+ {468, 2031.1046142578, 1561.4478759766, 10.580312728882, 271.99951171875},
+ {557, 2025.6492919922, 1535.8363037109, 11.120292663574, 270.00003051758},
+ {557, 2024.8865966797, 1526.9187011719, 11.120292663574, 270.00003051758},
+ {402, 2024.3311767578, 1519.9007568359, 10.760312080383, 270.00003051758},
+ {568, 2024.1086425781, 1515.0710449219, 10.79531288147, 270.00003051758},
+ {457, 2024.5035400391, 1510.8114013672, 10.549660682678, 270.00003051758},
+ {475, 2024.2908935547, 1506.1636962891, 10.72031211853, 270.00003051758},
+ {541, 2024.7091064453, 1499.3103027344, 10.520312309265, 270.00003051758},
+ {429, 2025.9349365234, 1490.2434082031, 10.5703125, 270.00003051758},
+ {429, 2025.6474609375, 1494.671875, 10.5703125, 270.00003051758},
+ {469, 2024.5600585938, 1623.0500488281, 12.002040863037, 270.00003051758}
+}
+
+function createVehicles()
+ for vehicleID = 1, #vehicleSpawns do
+ local vehicleData = vehicleSpawns[vehicleID]
+
+ createPlayVehicle(vehicleData)
+ end
+end
+
+function createPlayVehicle(vehicleData)
+ local modelID, posX, posY, posZ, rotX = vehicleData[1], vehicleData[2], vehicleData[3], vehicleData[4], vehicleData[5]
+ local vehicleElement = createVehicle(modelID, posX, posY, posZ, 0, 0, rotX)
+
+ setVehicleDamageProof(vehicleElement, true)
+ setElementFrozen(vehicleElement, true)
+ vehiclesToSpawn[vehicleElement] = vehicleData
+end
+
+function destroyVehicle(vehicleElement)
+ local validVehicle = isElement(vehicleElement)
+
+ if validVehicle then
+ destroyElement(vehicleElement)
+ end
+
+ destroyVehicleTimer(vehicleElement)
+end
+
+function destroyPlayerVehicles(playerElement)
+ local savedVehicles = playerVehicles[playerElement]
+
+ if savedVehicles then
+
+ for vehicleID = 1, #savedVehicles do
+ local vehicleElement = savedVehicles[vehicleID]
+ local validVehicle = isElement(vehicleElement)
+
+ if validVehicle then
+ destroyElement(vehicleElement)
+ end
+
+ destroyVehicleTimer(vehicleElement)
+ end
+
+ playerVehicles[playerElement] = nil
+ end
+end
+
+function destroyVehicleTimer(vehicleElement)
+ local vehicleTimer = vehicleTimers[vehicleElement]
+
+ if vehicleTimer then
+ local validTimer = isTimer(vehicleTimer)
+
+ if validTimer then
+ killTimer(vehicleTimer)
+ end
+
+ vehicleTimers[vehicleElement] = nil
+ end
+end
+
+function onVehicleEnter(playerElement)
+ local vehicleRespawnTime = get("vehicleRespawnTime")
+ local vehicleData = vehiclesToSpawn[source]
+
+ vehicleRespawnTime = tonumber(vehicleRespawnTime) or 60000
+ vehicleRespawnTime = vehicleRespawnTime > 50 and vehicleRespawnTime or 50
+ vehiclesToSpawn[source] = nil
+
+ setVehicleDamageProof(source, false)
+ setElementFrozen(source, false)
+ setTimer(createPlayVehicle, vehicleRespawnTime, 1, vehicleData)
+
+ local savedVehicles = playerVehicles[playerElement]
+
+ if not savedVehicles then
+ playerVehicles[playerElement] = {}
+ savedVehicles = playerVehicles[playerElement]
+ end
+
+ local playerVehiclesCount = #savedVehicles + 1
+
+ savedVehicles[playerVehiclesCount] = source
+ destroyVehicleTimer(source)
+end
+
+function onVehicleExit()
+ local vehicleExpireTime = get("vehicleExpireTime")
+
+ vehicleExpireTime = tonumber(vehicleExpireTime) or 600000
+ vehicleExpireTime = vehicleExpireTime > 50 and vehicleExpireTime or 50
+ vehicleTimers[source] = setTimer(destroyVehicle, vehicleExpireTime, 1, source)
+end
+
+function onVehicleElementDestroy()
+ local validElement = isElement(source)
+
+ if validElement then
+ local vehicleType = getElementType(source) == "vehicle"
+
+ if vehicleType then
+ destroyVehicleTimer(source)
+ end
+ end
+end
\ No newline at end of file
From 6ee0fcc9fd152573affe8f755672e54b2907e98d Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Tue, 2 Nov 2021 06:58:51 +0100
Subject: [PATCH 2/9] Add missing table clear.
---
[gamemodes]/[play]/play/play_vehicles.lua | 1 +
1 file changed, 1 insertion(+)
diff --git a/[gamemodes]/[play]/play/play_vehicles.lua b/[gamemodes]/[play]/play/play_vehicles.lua
index bb5524799..8413949bc 100644
--- a/[gamemodes]/[play]/play/play_vehicles.lua
+++ b/[gamemodes]/[play]/play/play_vehicles.lua
@@ -164,6 +164,7 @@ function onVehicleElementDestroy()
if vehicleType then
destroyVehicleTimer(source)
+ vehiclesToSpawn[source] = nil
end
end
end
\ No newline at end of file
From ef2b9a4701d7e6ecca35c087e1b4ebcd5f4399fa Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Tue, 2 Nov 2021 08:40:39 +0100
Subject: [PATCH 3/9] Separate tables.
---
[gamemodes]/[play]/play/meta.xml | 1 +
[gamemodes]/[play]/play/play_config.lua | 68 +++++++++++++++++++++++
[gamemodes]/[play]/play/play_players.lua | 2 -
[gamemodes]/[play]/play/play_vehicles.lua | 60 --------------------
4 files changed, 69 insertions(+), 62 deletions(-)
create mode 100644 [gamemodes]/[play]/play/play_config.lua
diff --git a/[gamemodes]/[play]/play/meta.xml b/[gamemodes]/[play]/play/meta.xml
index 4532482a9..4fec56fe6 100644
--- a/[gamemodes]/[play]/play/meta.xml
+++ b/[gamemodes]/[play]/play/meta.xml
@@ -1,6 +1,7 @@
+
diff --git a/[gamemodes]/[play]/play/play_config.lua b/[gamemodes]/[play]/play/play_config.lua
new file mode 100644
index 000000000..617529e02
--- /dev/null
+++ b/[gamemodes]/[play]/play/play_config.lua
@@ -0,0 +1,68 @@
+playerSkins = {0, 1, 2, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312}
+playerSpawns = {
+ {-711, 957, 12.4, 90},
+ {2005, 1543, 13.5, 270},
+ {2485, -1667, 13.3, 0},
+ {-2405, -598, 132.6, 128}
+}
+
+vehicleSpawns = {
+ {557, -676.43225097656, 962.98449707031, 12.507791519165, 92.063659667969},
+ {557, -676.67596435547, 968.88238525391, 12.507817268372, 89.458343505859},
+ {429, -696.71008300781, 947.44274902344, 11.961327552795, 43.260345458984},
+ {429, -700.66668701172, 946.43811035156, 12.032683372498, 41.218505859375},
+ {541, -708.88635253906, 939.77947998047, 12.079864501953, 180.60076904297},
+ {481, -679.98175048828, 931.08044433594, 11.648596763611, 88.025085449219},
+ {481, -679.97430419922, 932.28381347656, 11.64875125885, 87.565948486328},
+ {469, -655.177734375, 963.35192871094, 12.175182342529, 89.811737060547},
+ {468, -681.74114990234, 912.31903076172, 11.776277542114, 189.92042541504},
+ {468, -680.06512451172, 912.44622802734, 11.779381752014, 191.75022888184},
+ {468, -678.29089355469, 912.71087646484, 11.77979183197, 200.86720275879},
+ {493, -649.33892822266, 867.71429443359, -0.10552111268044, 228.00956726074},
+ {473, -661.28826904297, 876.15618896484, -0.30112856626511, 227.04469299316},
+ {484, -647.07635498047, 876.42327880859, 0.22773677110672, 226.89099121094},
+ {568, -696.35430908203, 929.35675048828, 12.135828971863, 178.99200439453},
+ {511, -696.59759521484, 897.68084716797, 13.838381767273, 176.86285400391},
+ {402, -686.66400146484, 969.24591064453, 11.975840568542, 89.380676269531},
+ {475, -687.01416015625, 963.00555419922, 11.94958114624, 89.711608886719},
+ {457, -686.92352294922, 966.03717041016, 11.767498970032, 89.163909912109},
+ {469, 2526.2607421875, -1677.2861328125, 19.913991928101, 91.994018554688},
+ {468, 2508.7177734375, -1680.568359375, 13.305373191833, 47.999267578125},
+ {468, 2506.615234375, -1682.3544921875, 13.305373191833, 47.999267578125},
+ {468, 2504.4423828125, -1684.208984375, 13.305373191833, 47.999267578125},
+ {557, 2512.4736328125, -1675.9833984375, 13.937532424927, 89.983520507813},
+ {557, 2512.6044921875, -1669.4228515625, 13.869720458984, 90.005493164063},
+ {402, 2473.427734375, -1692.513671875, 13.326358795166, 0},
+ {568, 2466.70703125, -1687.779296875, 13.489582061768, 272.4938659668},
+ {457, 2505.09765625, -1651.40625, 13.352488517761, 135.99975585938},
+ {475, 2459.9892578125, -1670.1943359375, 13.249677658081, 0},
+ {541, 2452.68359375, -1670.029296875, 13.199068069458, 0},
+ {429, 2447.8662109375, -1669.93359375, 13.184649467468, 359.99447631836},
+ {429, 2443.0263671875, -1669.81640625, 13.260643005371, 359.99447631836},
+ {557, -2398.5610351563, -611.85290527344, 133.04846191406, 36},
+ {557, -2393.6850585938, -608.3828125, 133.04846191406, 35.996704101563},
+ {402, -2393.4907226563, -599.73876953125, 132.58843994141, 125.5},
+ {568, -2396.79296875, -594.94836425781, 132.74308776855, 125.49682617188},
+ {457, -2407.7419433594, -577.97015380859, 132.47640991211, 126.00003051758},
+ {475, -2403.4738769531, -585.46215820313, 132.54843139648, 126.00003051758},
+ {541, -2399.7482910156, -590.07781982422, 132.34843444824, 123.99987792969},
+ {429, -2416.1259765625, -589.61535644531, 132.3984375, 213.99717712402},
+ {429, -2411.0979003906, -586.19421386719, 132.3984375, 213.99717712402},
+ {468, -2389.4606933594, -604.095703125, 132.53031921387, 123.99996948242},
+ {468, -2388.0568847656, -606.24896240234, 132.53031921387, 123.99719238281},
+ {468, -2386.5554199219, -608.55224609375, 132.53031921387, 123.99719238281},
+ {469, -2444.1838378906, -604.26513671875, 132.51147460938, 300.00003051758},
+ {468, 2030.5123291016, 1557.0339355469, 10.580312728882, 272},
+ {468, 2030.7028808594, 1559.1748046875, 10.580312728882, 271.99951171875},
+ {468, 2031.1046142578, 1561.4478759766, 10.580312728882, 271.99951171875},
+ {557, 2025.6492919922, 1535.8363037109, 11.120292663574, 270.00003051758},
+ {557, 2024.8865966797, 1526.9187011719, 11.120292663574, 270.00003051758},
+ {402, 2024.3311767578, 1519.9007568359, 10.760312080383, 270.00003051758},
+ {568, 2024.1086425781, 1515.0710449219, 10.79531288147, 270.00003051758},
+ {457, 2024.5035400391, 1510.8114013672, 10.549660682678, 270.00003051758},
+ {475, 2024.2908935547, 1506.1636962891, 10.72031211853, 270.00003051758},
+ {541, 2024.7091064453, 1499.3103027344, 10.520312309265, 270.00003051758},
+ {429, 2025.9349365234, 1490.2434082031, 10.5703125, 270.00003051758},
+ {429, 2025.6474609375, 1494.671875, 10.5703125, 270.00003051758},
+ {469, 2024.5600585938, 1623.0500488281, 12.002040863037, 270.00003051758}
+}
\ No newline at end of file
diff --git a/[gamemodes]/[play]/play/play_players.lua b/[gamemodes]/[play]/play/play_players.lua
index 80e3458cf..cbd0e37c1 100644
--- a/[gamemodes]/[play]/play/play_players.lua
+++ b/[gamemodes]/[play]/play/play_players.lua
@@ -1,5 +1,3 @@
-local playerSkins = {0, 1, 2, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312}
-local playerSpawns = { {-711, 957, 12.4, 90}, {2005, 1543, 13.5, 270}, {2485, -1667, 13.3, 0}, {-2405, -598, 132.6, 128} }
local spawnsCount = #playerSpawns
local skinsCount = #playerSkins
diff --git a/[gamemodes]/[play]/play/play_vehicles.lua b/[gamemodes]/[play]/play/play_vehicles.lua
index 8413949bc..d67841106 100644
--- a/[gamemodes]/[play]/play/play_vehicles.lua
+++ b/[gamemodes]/[play]/play/play_vehicles.lua
@@ -1,66 +1,6 @@
local vehicleTimers = {}
local playerVehicles = {}
local vehiclesToSpawn = {}
-local vehicleSpawns = {
- {557, -676.43225097656, 962.98449707031, 12.507791519165, 92.063659667969},
- {557, -676.67596435547, 968.88238525391, 12.507817268372, 89.458343505859},
- {429, -696.71008300781, 947.44274902344, 11.961327552795, 43.260345458984},
- {429, -700.66668701172, 946.43811035156, 12.032683372498, 41.218505859375},
- {541, -708.88635253906, 939.77947998047, 12.079864501953, 180.60076904297},
- {481, -679.98175048828, 931.08044433594, 11.648596763611, 88.025085449219},
- {481, -679.97430419922, 932.28381347656, 11.64875125885, 87.565948486328},
- {469, -655.177734375, 963.35192871094, 12.175182342529, 89.811737060547},
- {468, -681.74114990234, 912.31903076172, 11.776277542114, 189.92042541504},
- {468, -680.06512451172, 912.44622802734, 11.779381752014, 191.75022888184},
- {468, -678.29089355469, 912.71087646484, 11.77979183197, 200.86720275879},
- {493, -649.33892822266, 867.71429443359, -0.10552111268044, 228.00956726074},
- {473, -661.28826904297, 876.15618896484, -0.30112856626511, 227.04469299316},
- {484, -647.07635498047, 876.42327880859, 0.22773677110672, 226.89099121094},
- {568, -696.35430908203, 929.35675048828, 12.135828971863, 178.99200439453},
- {511, -696.59759521484, 897.68084716797, 13.838381767273, 176.86285400391},
- {402, -686.66400146484, 969.24591064453, 11.975840568542, 89.380676269531},
- {475, -687.01416015625, 963.00555419922, 11.94958114624, 89.711608886719},
- {457, -686.92352294922, 966.03717041016, 11.767498970032, 89.163909912109},
- {469, 2526.2607421875, -1677.2861328125, 19.913991928101, 91.994018554688},
- {468, 2508.7177734375, -1680.568359375, 13.305373191833, 47.999267578125},
- {468, 2506.615234375, -1682.3544921875, 13.305373191833, 47.999267578125},
- {468, 2504.4423828125, -1684.208984375, 13.305373191833, 47.999267578125},
- {557, 2512.4736328125, -1675.9833984375, 13.937532424927, 89.983520507813},
- {557, 2512.6044921875, -1669.4228515625, 13.869720458984, 90.005493164063},
- {402, 2473.427734375, -1692.513671875, 13.326358795166, 0},
- {568, 2466.70703125, -1687.779296875, 13.489582061768, 272.4938659668},
- {457, 2505.09765625, -1651.40625, 13.352488517761, 135.99975585938},
- {475, 2459.9892578125, -1670.1943359375, 13.249677658081, 0},
- {541, 2452.68359375, -1670.029296875, 13.199068069458, 0},
- {429, 2447.8662109375, -1669.93359375, 13.184649467468, 359.99447631836},
- {429, 2443.0263671875, -1669.81640625, 13.260643005371, 359.99447631836},
- {557, -2398.5610351563, -611.85290527344, 133.04846191406, 36},
- {557, -2393.6850585938, -608.3828125, 133.04846191406, 35.996704101563},
- {402, -2393.4907226563, -599.73876953125, 132.58843994141, 125.5},
- {568, -2396.79296875, -594.94836425781, 132.74308776855, 125.49682617188},
- {457, -2407.7419433594, -577.97015380859, 132.47640991211, 126.00003051758},
- {475, -2403.4738769531, -585.46215820313, 132.54843139648, 126.00003051758},
- {541, -2399.7482910156, -590.07781982422, 132.34843444824, 123.99987792969},
- {429, -2416.1259765625, -589.61535644531, 132.3984375, 213.99717712402},
- {429, -2411.0979003906, -586.19421386719, 132.3984375, 213.99717712402},
- {468, -2389.4606933594, -604.095703125, 132.53031921387, 123.99996948242},
- {468, -2388.0568847656, -606.24896240234, 132.53031921387, 123.99719238281},
- {468, -2386.5554199219, -608.55224609375, 132.53031921387, 123.99719238281},
- {469, -2444.1838378906, -604.26513671875, 132.51147460938, 300.00003051758},
- {468, 2030.5123291016, 1557.0339355469, 10.580312728882, 272},
- {468, 2030.7028808594, 1559.1748046875, 10.580312728882, 271.99951171875},
- {468, 2031.1046142578, 1561.4478759766, 10.580312728882, 271.99951171875},
- {557, 2025.6492919922, 1535.8363037109, 11.120292663574, 270.00003051758},
- {557, 2024.8865966797, 1526.9187011719, 11.120292663574, 270.00003051758},
- {402, 2024.3311767578, 1519.9007568359, 10.760312080383, 270.00003051758},
- {568, 2024.1086425781, 1515.0710449219, 10.79531288147, 270.00003051758},
- {457, 2024.5035400391, 1510.8114013672, 10.549660682678, 270.00003051758},
- {475, 2024.2908935547, 1506.1636962891, 10.72031211853, 270.00003051758},
- {541, 2024.7091064453, 1499.3103027344, 10.520312309265, 270.00003051758},
- {429, 2025.9349365234, 1490.2434082031, 10.5703125, 270.00003051758},
- {429, 2025.6474609375, 1494.671875, 10.5703125, 270.00003051758},
- {469, 2024.5600585938, 1623.0500488281, 12.002040863037, 270.00003051758}
-}
function createVehicles()
for vehicleID = 1, #vehicleSpawns do
From 9767394fc1fd902bc9d809795b04266a0f2a471e Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Tue, 2 Nov 2021 09:10:54 +0100
Subject: [PATCH 4/9] Shorten lines.
---
[gamemodes]/[play]/play/play_config.lua | 38 +++++++++++++++++++++++-
[gamemodes]/[play]/play/play_players.lua | 4 ++-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/[gamemodes]/[play]/play/play_config.lua b/[gamemodes]/[play]/play/play_config.lua
index 617529e02..18d6f9d25 100644
--- a/[gamemodes]/[play]/play/play_config.lua
+++ b/[gamemodes]/[play]/play/play_config.lua
@@ -1,4 +1,40 @@
-playerSkins = {0, 1, 2, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312}
+playerSkins = {
+ 0, 1, 2, 7, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 41,
+ 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60,
+ 61, 62, 63, 64, 66, 67, 68, 69, 70,
+ 71, 72, 73, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 87, 88, 89, 90,
+ 91, 92, 93, 94, 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 104, 105, 106, 107, 108,
+ 109, 110, 111, 112, 113, 114, 115, 116, 117,
+ 118, 120, 121, 122, 123, 124, 125, 126, 127,
+ 128, 129, 130, 131, 132, 133, 134, 135, 136,
+ 137, 138, 139, 140, 141, 142, 143, 144, 145,
+ 146, 147, 148, 150, 151, 152, 153, 154, 155,
+ 156, 157, 158, 159, 160, 161, 162, 163, 164,
+ 165, 166, 167, 168, 169, 170, 171, 172, 173,
+ 174, 175, 176, 177, 178, 179, 180, 181, 182,
+ 183, 184, 185, 186, 187, 188, 189, 190, 191,
+ 192, 193, 194, 195, 196, 197, 198, 199, 200,
+ 201, 202, 203, 204, 205, 206, 207, 209, 210,
+ 211, 212, 213, 214, 215, 216, 217, 218, 219,
+ 220, 221, 222, 223, 224, 225, 226, 227, 228,
+ 229, 230, 231, 232, 233, 234, 235, 236, 237,
+ 238, 239, 240, 241, 242, 243, 244, 245, 246,
+ 247, 248, 249, 250, 251, 252, 253, 254, 255,
+ 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283,
+ 284, 285, 286, 287, 288, 290, 291, 292, 293,
+ 294, 295, 296, 297, 298, 299, 300, 301, 302,
+ 303, 304, 305, 306, 307, 308, 309, 310, 311,
+ 312
+}
+
playerSpawns = {
{-711, 957, 12.4, 90},
{2005, 1543, 13.5, 270},
diff --git a/[gamemodes]/[play]/play/play_players.lua b/[gamemodes]/[play]/play/play_players.lua
index cbd0e37c1..db2c55bca 100644
--- a/[gamemodes]/[play]/play/play_players.lua
+++ b/[gamemodes]/[play]/play/play_players.lua
@@ -7,10 +7,12 @@ function playSpawnPlayer(playerElement)
if validPlayer then
local randomSpawn = math.random(1, spawnsCount)
local spawnData = playerSpawns[randomSpawn]
- local posX, posY, posZ, rotX = spawnData[1] + math.random(-3, 3), spawnData[2] + math.random(-3, 3), spawnData[3], spawnData[4]
+ local posX, posY, posZ, rotX = spawnData[1], spawnData[2], spawnData[3], spawnData[4]
local randomSkin = math.random(1, skinsCount)
local skinID = playerSkins[randomSkin]
+ posX, posY = posX + math.random(-3, 3), posY + math.random(-3, 3)
+
spawnPlayer(playerElement, posX, posY, posZ, rotX, skinID, 0, 0, nil)
fadeCamera(playerElement, true)
setCameraTarget(playerElement, playerElement)
From 61207ca81b5337c8b2ccc8e7b803fb6a705ba48e Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Tue, 2 Nov 2021 09:14:28 +0100
Subject: [PATCH 5/9] Delete white spaces.
---
[gamemodes]/[play]/play/play_config.lua | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/[gamemodes]/[play]/play/play_config.lua b/[gamemodes]/[play]/play/play_config.lua
index 18d6f9d25..e9a19e076 100644
--- a/[gamemodes]/[play]/play/play_config.lua
+++ b/[gamemodes]/[play]/play/play_config.lua
@@ -36,10 +36,10 @@ playerSkins = {
}
playerSpawns = {
- {-711, 957, 12.4, 90},
- {2005, 1543, 13.5, 270},
- {2485, -1667, 13.3, 0},
- {-2405, -598, 132.6, 128}
+ {-711, 957, 12.4, 90},
+ {2005, 1543, 13.5, 270},
+ {2485, -1667, 13.3, 0},
+ {-2405, -598, 132.6, 128}
}
vehicleSpawns = {
From 710733d3273be34d046a9844319c8158fe417f43 Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Tue, 2 Nov 2021 09:16:04 +0100
Subject: [PATCH 6/9] Update play_config.lua
---
[gamemodes]/[play]/play/play_config.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/[gamemodes]/[play]/play/play_config.lua b/[gamemodes]/[play]/play/play_config.lua
index e9a19e076..ee12f3c1c 100644
--- a/[gamemodes]/[play]/play/play_config.lua
+++ b/[gamemodes]/[play]/play/play_config.lua
@@ -35,7 +35,7 @@ playerSkins = {
312
}
-playerSpawns = {
+playerSpawns = {
{-711, 957, 12.4, 90},
{2005, 1543, 13.5, 270},
{2485, -1667, 13.3, 0},
From 0ad3c87e4665d05d0c7c3e1979556421dab3c49b Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Tue, 16 Nov 2021 13:42:15 +0100
Subject: [PATCH 7/9] Update
---
[gamemodes]/[play]/play/play.lua | 8 +++----
[gamemodes]/[play]/play/play_players.lua | 22 ++++++++-----------
[gamemodes]/[play]/play/play_vehicles.lua | 26 ++++++-----------------
3 files changed, 19 insertions(+), 37 deletions(-)
diff --git a/[gamemodes]/[play]/play/play.lua b/[gamemodes]/[play]/play/play.lua
index b8b8afb0e..722509a1c 100644
--- a/[gamemodes]/[play]/play/play.lua
+++ b/[gamemodes]/[play]/play/play.lua
@@ -5,13 +5,11 @@ function onResourceStartPlay()
local playersTable = getElementsByType("player")
for playerID = 1, #playersTable do
- local playerElement = playersTable[playerID]
-
- playSpawnPlayer(playerElement)
+ playSpawnPlayer(playersTable[playerID])
end
- addEventHandler("onPlayerJoin", root, onPlayerJoinOrWasted)
- addEventHandler("onPlayerWasted", root, onPlayerJoinOrWasted)
+ addEventHandler("onPlayerJoin", root, onPlayerJoin)
+ addEventHandler("onPlayerWasted", root, onPlayerWasted)
addEventHandler("onPlayerQuit", root, onPlayerQuit)
addEventHandler("onVehicleEnter", resourceRoot, onVehicleEnter)
addEventHandler("onVehicleExit", resourceRoot, onVehicleExit)
diff --git a/[gamemodes]/[play]/play/play_players.lua b/[gamemodes]/[play]/play/play_players.lua
index db2c55bca..f568b8842 100644
--- a/[gamemodes]/[play]/play/play_players.lua
+++ b/[gamemodes]/[play]/play/play_players.lua
@@ -2,9 +2,7 @@ local spawnsCount = #playerSpawns
local skinsCount = #playerSkins
function playSpawnPlayer(playerElement)
- local validPlayer = isElement(playerElement)
-
- if validPlayer then
+ if isElement(playerElement) then
local randomSpawn = math.random(1, spawnsCount)
local spawnData = playerSpawns[randomSpawn]
local posX, posY, posZ, rotX = spawnData[1], spawnData[2], spawnData[3], spawnData[4]
@@ -19,19 +17,17 @@ function playSpawnPlayer(playerElement)
end
end
-function onPlayerJoinOrWasted()
- local joinEvent = eventName == "onPlayerJoin"
+function onPlayerJoin()
+ playSpawnPlayer(source)
+end
- if joinEvent then
- playSpawnPlayer(source)
- else
- local playerRespawnTime = get("playerRespawnTime")
+function onPlayerWasted()
+ local playerRespawnTime = get("playerRespawnTime")
- playerRespawnTime = tonumber(playerRespawnTime) or 5000
- playerRespawnTime = playerRespawnTime > 50 and playerRespawnTime or 50
+ playerRespawnTime = tonumber(playerRespawnTime) or 5000
+ playerRespawnTime = playerRespawnTime > 50 and playerRespawnTime or 50
- setTimer(playSpawnPlayer, playerRespawnTime, 1, source)
- end
+ setTimer(playSpawnPlayer, playerRespawnTime, 1, source)
end
function onPlayerQuit()
diff --git a/[gamemodes]/[play]/play/play_vehicles.lua b/[gamemodes]/[play]/play/play_vehicles.lua
index d67841106..b313e33f7 100644
--- a/[gamemodes]/[play]/play/play_vehicles.lua
+++ b/[gamemodes]/[play]/play/play_vehicles.lua
@@ -4,9 +4,7 @@ local vehiclesToSpawn = {}
function createVehicles()
for vehicleID = 1, #vehicleSpawns do
- local vehicleData = vehicleSpawns[vehicleID]
-
- createPlayVehicle(vehicleData)
+ createPlayVehicle(vehicleSpawns[vehicleID])
end
end
@@ -20,9 +18,7 @@ function createPlayVehicle(vehicleData)
end
function destroyVehicle(vehicleElement)
- local validVehicle = isElement(vehicleElement)
-
- if validVehicle then
+ if isElement(vehicleElement) then
destroyElement(vehicleElement)
end
@@ -36,9 +32,8 @@ function destroyPlayerVehicles(playerElement)
for vehicleID = 1, #savedVehicles do
local vehicleElement = savedVehicles[vehicleID]
- local validVehicle = isElement(vehicleElement)
- if validVehicle then
+ if isElement(vehicleElement) then
destroyElement(vehicleElement)
end
@@ -53,9 +48,8 @@ function destroyVehicleTimer(vehicleElement)
local vehicleTimer = vehicleTimers[vehicleElement]
if vehicleTimer then
- local validTimer = isTimer(vehicleTimer)
- if validTimer then
+ if isTimer(vehicleTimer) then
killTimer(vehicleTimer)
end
@@ -97,14 +91,8 @@ function onVehicleExit()
end
function onVehicleElementDestroy()
- local validElement = isElement(source)
-
- if validElement then
- local vehicleType = getElementType(source) == "vehicle"
-
- if vehicleType then
- destroyVehicleTimer(source)
- vehiclesToSpawn[source] = nil
- end
+ if isElement(source) and getElementType(source) == "vehicle" then
+ destroyVehicleTimer(source)
+ vehiclesToSpawn[source] = nil
end
end
\ No newline at end of file
From d6e5fd36261a1c722fdfe3141ec5dcf82f5857fb Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Thu, 21 Apr 2022 21:52:02 +0200
Subject: [PATCH 8/9] Introduce requested changes.
---
[gamemodes]/[play]/play/meta.xml | 10 +++++-----
[gamemodes]/[play]/play/play.lua | 4 ++--
[gamemodes]/[play]/play/play_config.lua | 2 +-
[gamemodes]/[play]/play/play_players.lua | 10 +++++-----
[gamemodes]/[play]/play/play_vehicles.lua | 8 ++++----
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/[gamemodes]/[play]/play/meta.xml b/[gamemodes]/[play]/play/meta.xml
index 4fec56fe6..40276c26b 100644
--- a/[gamemodes]/[play]/play/meta.xml
+++ b/[gamemodes]/[play]/play/meta.xml
@@ -1,5 +1,5 @@
-
+
@@ -7,8 +7,8 @@
-
-
-
+
+
+
-
\ No newline at end of file
+
diff --git a/[gamemodes]/[play]/play/play.lua b/[gamemodes]/[play]/play/play.lua
index 722509a1c..ba334a69c 100644
--- a/[gamemodes]/[play]/play/play.lua
+++ b/[gamemodes]/[play]/play/play.lua
@@ -1,4 +1,4 @@
-function onResourceStartPlay()
+local function onResourceStartPlay()
resetMapInfo()
createVehicles()
@@ -15,4 +15,4 @@ function onResourceStartPlay()
addEventHandler("onVehicleExit", resourceRoot, onVehicleExit)
addEventHandler("onElementDestroy", resourceRoot, onVehicleElementDestroy)
end
-addEventHandler("onResourceStart", resourceRoot, onResourceStartPlay)
\ No newline at end of file
+addEventHandler("onResourceStart", resourceRoot, onResourceStartPlay)
diff --git a/[gamemodes]/[play]/play/play_config.lua b/[gamemodes]/[play]/play/play_config.lua
index ee12f3c1c..4c8964b53 100644
--- a/[gamemodes]/[play]/play/play_config.lua
+++ b/[gamemodes]/[play]/play/play_config.lua
@@ -101,4 +101,4 @@ vehicleSpawns = {
{429, 2025.9349365234, 1490.2434082031, 10.5703125, 270.00003051758},
{429, 2025.6474609375, 1494.671875, 10.5703125, 270.00003051758},
{469, 2024.5600585938, 1623.0500488281, 12.002040863037, 270.00003051758}
-}
\ No newline at end of file
+}
diff --git a/[gamemodes]/[play]/play/play_players.lua b/[gamemodes]/[play]/play/play_players.lua
index f568b8842..cd777cb01 100644
--- a/[gamemodes]/[play]/play/play_players.lua
+++ b/[gamemodes]/[play]/play/play_players.lua
@@ -3,17 +3,17 @@ local skinsCount = #playerSkins
function playSpawnPlayer(playerElement)
if isElement(playerElement) then
- local randomSpawn = math.random(1, spawnsCount)
+ local randomSpawn = math.random(spawnsCount)
local spawnData = playerSpawns[randomSpawn]
local posX, posY, posZ, rotX = spawnData[1], spawnData[2], spawnData[3], spawnData[4]
- local randomSkin = math.random(1, skinsCount)
+ local randomSkin = math.random(skinsCount)
local skinID = playerSkins[randomSkin]
posX, posY = posX + math.random(-3, 3), posY + math.random(-3, 3)
spawnPlayer(playerElement, posX, posY, posZ, rotX, skinID, 0, 0, nil)
fadeCamera(playerElement, true)
- setCameraTarget(playerElement, playerElement)
+ setCameraTarget(playerElement)
end
end
@@ -25,11 +25,11 @@ function onPlayerWasted()
local playerRespawnTime = get("playerRespawnTime")
playerRespawnTime = tonumber(playerRespawnTime) or 5000
- playerRespawnTime = playerRespawnTime > 50 and playerRespawnTime or 50
+ playerRespawnTime = playerRespawnTime < 0 and 0 or playerRespawnTime
setTimer(playSpawnPlayer, playerRespawnTime, 1, source)
end
function onPlayerQuit()
destroyPlayerVehicles(source)
-end
\ No newline at end of file
+end
diff --git a/[gamemodes]/[play]/play/play_vehicles.lua b/[gamemodes]/[play]/play/play_vehicles.lua
index b313e33f7..de60f29f4 100644
--- a/[gamemodes]/[play]/play/play_vehicles.lua
+++ b/[gamemodes]/[play]/play/play_vehicles.lua
@@ -9,7 +9,7 @@ function createVehicles()
end
function createPlayVehicle(vehicleData)
- local modelID, posX, posY, posZ, rotX = vehicleData[1], vehicleData[2], vehicleData[3], vehicleData[4], vehicleData[5]
+ local modelID, posX, posY, posZ, rotX = unpack(vehicleData)
local vehicleElement = createVehicle(modelID, posX, posY, posZ, 0, 0, rotX)
setVehicleDamageProof(vehicleElement, true)
@@ -62,7 +62,7 @@ function onVehicleEnter(playerElement)
local vehicleData = vehiclesToSpawn[source]
vehicleRespawnTime = tonumber(vehicleRespawnTime) or 60000
- vehicleRespawnTime = vehicleRespawnTime > 50 and vehicleRespawnTime or 50
+ vehicleRespawnTime = vehicleRespawnTime < 0 and 0 or vehicleRespawnTime
vehiclesToSpawn[source] = nil
setVehicleDamageProof(source, false)
@@ -86,7 +86,7 @@ function onVehicleExit()
local vehicleExpireTime = get("vehicleExpireTime")
vehicleExpireTime = tonumber(vehicleExpireTime) or 600000
- vehicleExpireTime = vehicleExpireTime > 50 and vehicleExpireTime or 50
+ vehicleExpireTime = vehicleExpireTime < 0 and 0 or vehicleExpireTime
vehicleTimers[source] = setTimer(destroyVehicle, vehicleExpireTime, 1, source)
end
@@ -95,4 +95,4 @@ function onVehicleElementDestroy()
destroyVehicleTimer(source)
vehiclesToSpawn[source] = nil
end
-end
\ No newline at end of file
+end
From 5f2295dbc5ff191e63eabd4480eab960203cd954 Mon Sep 17 00:00:00 2001
From: srslyyyy <51768772+srslyyyy@users.noreply.github.com>
Date: Fri, 22 Apr 2022 11:58:47 +0200
Subject: [PATCH 9/9] Update [gamemodes]/[play]/play/play_players.lua
Co-authored-by: patrikjuvonen <22572159+patrikjuvonen@users.noreply.github.com>
---
[gamemodes]/[play]/play/play_players.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/[gamemodes]/[play]/play/play_players.lua b/[gamemodes]/[play]/play/play_players.lua
index cd777cb01..546f7cd2b 100644
--- a/[gamemodes]/[play]/play/play_players.lua
+++ b/[gamemodes]/[play]/play/play_players.lua
@@ -5,7 +5,7 @@ function playSpawnPlayer(playerElement)
if isElement(playerElement) then
local randomSpawn = math.random(spawnsCount)
local spawnData = playerSpawns[randomSpawn]
- local posX, posY, posZ, rotX = spawnData[1], spawnData[2], spawnData[3], spawnData[4]
+ local posX, posY, posZ, rotX = unpack(spawnData)
local randomSkin = math.random(skinsCount)
local skinID = playerSkins[randomSkin]