- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 171
 
play: refactor #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            patrikjuvonen
  merged 9 commits into
  multitheftauto:master
from
sacr1ficez:play-refactor
  
      
      
   
  Dec 29, 2022 
      
    
  
     Merged
                    play: refactor #363
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            9 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      1192e46
              
                Refactor play.
              
              
                sacr1ficez 6ee0fcc
              
                Add missing table clear.
              
              
                sacr1ficez ef2b9a4
              
                Separate tables.
              
              
                sacr1ficez 9767394
              
                Shorten lines.
              
              
                sacr1ficez 61207ca
              
                Delete white spaces.
              
              
                sacr1ficez 710733d
              
                Update play_config.lua
              
              
                sacr1ficez 0ad3c87
              
                Update
              
              
                sacr1ficez d6e5fd3
              
                Introduce requested changes.
              
              
                sacr1ficez 5f2295d
              
                Update [gamemodes]/[play]/play/play_players.lua
              
              
                sacr1ficez File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
This file was deleted.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,13 +1,14 @@ | ||
| <meta> | ||
| <oop>true</oop> | ||
| <info author="BrophY" description="A playtest/freeroam mode" version="1.5" type="gamemode" /> | ||
| <include resource="freeroam" /> | ||
| <script src="broph.lua"/> | ||
| <info author="BrophY" description="A playtest/freeroam mode" version="2.0" type="gamemode"/> | ||
| <include resource="freeroam"/> | ||
| <script src="play_config.lua" type="server"/> | ||
| <script src="play_players.lua" type="server"/> | ||
| <script src="play_vehicles.lua" type="server"/> | ||
| <script src="play.lua" type="server"/> | ||
| 
     | 
||
| <settings> | ||
| <setting name="*playerRespawnTime" value="[4000]" friendlyname="Player respawn time" desc="Player respawn time after dying in milliseconds. Anything below 50 is auto-set to 50" /> | ||
| <setting name="*vehicleRespawnTime" value="[60000]" friendlyname="Vehicle respawn time" group="Spawnpoint vehicles" desc="Vehicle respawn time after it is taken. Anything below 50 is auto-set to 50" /> | ||
| <setting name="*vehicleExpireTime" value="[600000]" friendlyname="Vehicle expire time" group="Spawnpoint vehicles" desc="Vehicle disappear time after abandoned, timer resets if any player re-enters the vehicle. Anything below 50 is auto-set to 50" /> | ||
| <setting name="*playerRespawnTime" value="[4000]" friendlyname="Player respawn time" desc="Player respawn time after dying in milliseconds. Anything below 0 is auto-set to 0"/> | ||
| <setting name="*vehicleRespawnTime" value="[60000]" friendlyname="Vehicle respawn time" group="Spawnpoint vehicles" desc="Vehicle respawn time after it is taken. Anything below 0 is auto-set to 0"/> | ||
| <setting name="*vehicleExpireTime" value="[600000]" friendlyname="Vehicle expire time" group="Spawnpoint vehicles" desc="Vehicle disappear time after abandoned, timer resets if any player re-enters the vehicle. Anything below 0 is auto-set to 0"/> | ||
| </settings> | ||
| 
     | 
||
| </meta> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -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) | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -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}, | ||
                
      
                  Dutchman101 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| {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} | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -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 | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.