diff --git a/[gamemodes]/[play]/play/broph.lua b/[gamemodes]/[play]/play/broph.lua
deleted file mode 100644
index 9be80f532..000000000
--- a/[gamemodes]/[play]/play/broph.lua
+++ /dev/null
@@ -1,176 +0,0 @@
-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)
diff --git a/[gamemodes]/[play]/play/meta.xml b/[gamemodes]/[play]/play/meta.xml
index 90e1cf2f0..40276c26b 100644
--- a/[gamemodes]/[play]/play/meta.xml
+++ b/[gamemodes]/[play]/play/meta.xml
@@ -1,13 +1,14 @@
- true
-
-
-
+
+
+
+
+
+
-
-
-
+
+
+
-
diff --git a/[gamemodes]/[play]/play/play.lua b/[gamemodes]/[play]/play/play.lua
new file mode 100644
index 000000000..ba334a69c
--- /dev/null
+++ b/[gamemodes]/[play]/play/play.lua
@@ -0,0 +1,18 @@
+local function onResourceStartPlay()
+ resetMapInfo()
+ createVehicles()
+
+ local playersTable = getElementsByType("player")
+
+ for playerID = 1, #playersTable do
+ playSpawnPlayer(playersTable[playerID])
+ end
+
+ addEventHandler("onPlayerJoin", root, onPlayerJoin)
+ addEventHandler("onPlayerWasted", root, onPlayerWasted)
+ addEventHandler("onPlayerQuit", root, onPlayerQuit)
+ addEventHandler("onVehicleEnter", resourceRoot, onVehicleEnter)
+ addEventHandler("onVehicleExit", resourceRoot, onVehicleExit)
+ addEventHandler("onElementDestroy", resourceRoot, onVehicleElementDestroy)
+end
+addEventHandler("onResourceStart", resourceRoot, onResourceStartPlay)
diff --git a/[gamemodes]/[play]/play/play_config.lua b/[gamemodes]/[play]/play/play_config.lua
new file mode 100644
index 000000000..4c8964b53
--- /dev/null
+++ b/[gamemodes]/[play]/play/play_config.lua
@@ -0,0 +1,104 @@
+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}
+}
diff --git a/[gamemodes]/[play]/play/play_players.lua b/[gamemodes]/[play]/play/play_players.lua
new file mode 100644
index 000000000..546f7cd2b
--- /dev/null
+++ b/[gamemodes]/[play]/play/play_players.lua
@@ -0,0 +1,35 @@
+local spawnsCount = #playerSpawns
+local skinsCount = #playerSkins
+
+function playSpawnPlayer(playerElement)
+ if isElement(playerElement) then
+ local randomSpawn = math.random(spawnsCount)
+ local spawnData = playerSpawns[randomSpawn]
+ local posX, posY, posZ, rotX = unpack(spawnData)
+ 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)
+ end
+end
+
+function onPlayerJoin()
+ playSpawnPlayer(source)
+end
+
+function onPlayerWasted()
+ local playerRespawnTime = get("playerRespawnTime")
+
+ playerRespawnTime = tonumber(playerRespawnTime) or 5000
+ playerRespawnTime = playerRespawnTime < 0 and 0 or playerRespawnTime
+
+ setTimer(playSpawnPlayer, playerRespawnTime, 1, source)
+end
+
+function onPlayerQuit()
+ destroyPlayerVehicles(source)
+end
diff --git a/[gamemodes]/[play]/play/play_vehicles.lua b/[gamemodes]/[play]/play/play_vehicles.lua
new file mode 100644
index 000000000..de60f29f4
--- /dev/null
+++ b/[gamemodes]/[play]/play/play_vehicles.lua
@@ -0,0 +1,98 @@
+local vehicleTimers = {}
+local playerVehicles = {}
+local vehiclesToSpawn = {}
+
+function createVehicles()
+ for vehicleID = 1, #vehicleSpawns do
+ createPlayVehicle(vehicleSpawns[vehicleID])
+ end
+end
+
+function createPlayVehicle(vehicleData)
+ local modelID, posX, posY, posZ, rotX = unpack(vehicleData)
+ local vehicleElement = createVehicle(modelID, posX, posY, posZ, 0, 0, rotX)
+
+ setVehicleDamageProof(vehicleElement, true)
+ setElementFrozen(vehicleElement, true)
+ vehiclesToSpawn[vehicleElement] = vehicleData
+end
+
+function destroyVehicle(vehicleElement)
+ if isElement(vehicleElement) 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]
+
+ if isElement(vehicleElement) then
+ destroyElement(vehicleElement)
+ end
+
+ destroyVehicleTimer(vehicleElement)
+ end
+
+ playerVehicles[playerElement] = nil
+ end
+end
+
+function destroyVehicleTimer(vehicleElement)
+ local vehicleTimer = vehicleTimers[vehicleElement]
+
+ if vehicleTimer then
+
+ if isTimer(vehicleTimer) 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 < 0 and 0 or vehicleRespawnTime
+ 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 < 0 and 0 or vehicleExpireTime
+ vehicleTimers[source] = setTimer(destroyVehicle, vehicleExpireTime, 1, source)
+end
+
+function onVehicleElementDestroy()
+ if isElement(source) and getElementType(source) == "vehicle" then
+ destroyVehicleTimer(source)
+ vehiclesToSpawn[source] = nil
+ end
+end