BB. Posted January 5, 2014 Share Posted January 5, 2014 This script can multi-play the course which the user created. The flow of a race "FreeRun" -> "Qualify" -> "Starting Grid" -> "Final" DOWNLOAD SCRIPT FILE http://www.en.wiki.eagle.ru/attachment.php?attachmentid=92655&stc=1&d=1388939082 DOWNLOAD 4 COURSE http://www.en.wiki.eagle.ru/attachment.php?attachmentid=92656&stc=1&d=1388939082 Stage-1 : F-15x10 Stage-2 : MiG-29x10 Stage-3 : UH-1x10 Stage-4 : P-51x12 (Time Attack Ver) *User create course 1. MIST load 2. This script load 3. If there is a fanfare file, it will load sound file. (DefaultFlagNumber8. When you change a flag number, please change the line:760 of lua file. ) 4. Course guide (static objects) create Left side is made into the name "LeftSide #001" ... "LeftSide #002" ... "LeftSide #999"(Maximum number) Right side is made into the name "RightSide #001" ... "RightSide #002" ... "RightSide #999"(Maximum number) Note : LeftSide #Number = RightSide #Number 5. Grid Zone create TriggerZone Name "Grid1" ... "Grid2" ... "Grid99"(Maximum number) Please create a smoke zone near a grid zone. Zone name "GridSmoke1" ... "GridSmoke99"(Maximum number) Note : Grid number = GridSmoke number 6. RaceZone create This trigger zone should cover the whole course. Record time will be erased if a player comes out of this zone. 7. Client Plane or Heli create Grid number = Client AirPlane 8. UserSetting Edit PoleNumber = 67 --Please fill in the placed number of "Course guide". Example "LeftSide #067" and "RightSide #067" MaxPlayer = 10 --Please fill in the placed number of Grid & Client AirPlane. --Checkpoint Pole Number CheckPoint = {} CheckPoint[1] = 13 CheckPoint[2] = 32 CheckPoint[3] = 53 FreeRunTime = 600 --(sec) QualifyTime = 600 --(sec) PenaltyVolume = 2 --Course Out Penalty PrematureStartPenalty = 15 --(sec) maxalt = 3000 --meter The maximum altitude. It will be "course out" if it becomes higher than this. LapNumber = 3 --Final Race LapNumber smokecolor = "Orange" --Grid Smoke Color (Green , Red , White , Orange , Blue) FanfareWaitTime = 11 --(sec) Fanfare sound play time PrematureStartSpeed = 1 --Premature start check speedKnown problem When it respawn after the pilot ejected, a script stops. If "Russia Infantry Soldier Rus" is specified as a course guide, will be nil error. (bug?) If four or more players participate, it cannot fly with server PC. (Very high load) I am a programming beginner. Since I think that there are many problems and improving points, please point out a correction part. Thank you.MP_RaceScript_v1.0.zipBigBird AirRace CousePack.zip konnichiwa Link to comment Share on other sites More sharing options...
camsr Posted January 5, 2014 Share Posted January 5, 2014 IDK how airraces work, but how does the game know you stay on the course or not take a shortcut? Link to comment Share on other sites More sharing options...
BB. Posted January 6, 2014 Author Share Posted January 6, 2014 IDK how airraces work, but how does the game know you stay on the course or not take a shortcut? I'm sorry if the meaning of a question is misunderstood. 1 konnichiwa Link to comment Share on other sites More sharing options...
Shahdoh Posted January 6, 2014 Share Posted January 6, 2014 This is great coding for Air Racing. Couple things I would like to see implemented. Some way to trigger the start as opposed to it starting right at mission load. Along those lines, allowing it to reset and be raced again without having to reload the mission. The courses BB has created are a lot of fun and the code works really well. I will be looking to modifying my courses to use the code as well if we can work in the above issues. Great job! Link to comment Share on other sites More sharing options...
camsr Posted January 6, 2014 Share Posted January 6, 2014 Very cool! Thanks for the detailed explaination. Link to comment Share on other sites More sharing options...
BB. Posted January 11, 2014 Author Share Posted January 11, 2014 Multiplay RaceScript_v1.04b (TestVersion) http://www.en.wiki.eagle.ru/attachment.php?attachmentid=92893&stc=1&d=1389455251 Change log A fanfare flag number can be specified by UserSetting. The race re-starting (reset) function was added. Race will be reset if the flag 10 is set ON. (Default Flag10. When you change a flag number, please change the line 19 of UserSetting. ). Example: RaceReset I am creating the script which saves a course record now. It will take some time before it is complete. ThanksMP_RaceScript_v1.04b.zip konnichiwa Link to comment Share on other sites More sharing options...
Liger Zero Posted January 27, 2014 Share Posted January 27, 2014 He BB awsome work one the race script. Im using it now to creat an airrace for the LLTM this year. Is there a Way to save the fastest lap in free run? i noticed that the time dissapears when you crash. Thats because i want to create a Time trial run Link to comment Share on other sites More sharing options...
Liger Zero Posted January 29, 2014 Share Posted January 29, 2014 BB we (JoeKurr and me) are also working on the script now. Here are some changes we are trying to test this week *Missed Gate- have to turn around to complete a lap. *Lighter server load *After leaving the triggerzone (flying away crashing or exit) The player fastest time will be deleted after 60sec This last mentioned must make sure your time stays if you crash or rejoin But you'll have to choose the same jet/heli. *easy to maintain and adjust Link to comment Share on other sites More sharing options...
Joe Kurr Posted January 29, 2014 Share Posted January 29, 2014 As Liger Zero said I took the liberty to do a rewrite of your script in order to make it easier to maintain and add functionality. At the moment I have the triggerzone part working: - Every second, the script checks if there are new units inside the trigger zone and adds them to the players list - Every 10 seconds, the script checks if units have left the trigger zone, and removes them from the players list. The remove timer can be set to a higher value at a later time, to enable crashed pilots to get a new aircraft and not lose their time. The script also doesn't stop after eject / rejoin. _zoneName = "RaceZone" _updateText = true _players = {} -- Initialize the script -- This function gets called only once, at the beginning of the mission function Init() mist.scheduleFunction(RaceTimer, nil, timer.getTime(), 0.01) mist.scheduleFunction(NewPlayerTimer, nil, timer.getTime(), 1) mist.scheduleFunction(RemovePlayerTimer, nil, timer.getTime(), 10) end -- The main timer, this is where the checks will be done, -- for now it only shows the players inside the trigger zone function RaceTimer() local text = string.format("Elapsed time: %d seconds", timer.getTime()) if #_players > 0 then text = string.format("%s\n%d players found", text, #_players) for playerIndex, player in ipairs(_players) do text = string.format("%s\n%d. %s", text, playerIndex, player.Name) end else text = string.format("%s\nNo players found", text) end logString(text) _updateText = false end -- Check for new players inside the trigger zone, and add them to the list -- This function gets called once every second. function NewPlayerTimer() local allUnits = mist.makeUnitTable( { '[all][plane][helicopter]' } ) local unitsInZone = mist.getUnitsInZones(allUnits, { _zoneName } ) for unitIndex, unit in ipairs(unitsInZone) do playerExists = false for playerIndex, player in ipairs(_players) do local unitName = "" if unit:getPlayerName() then unitName = unit:getPlayerName() else unitName = unit:getName() end if player.Name == unitName then playerExists = true break end end if not playerExists then table.insert(_players, newPlayer(unit)) _updateText = true end end end -- Check for players who have left the trigger zone, and remove them from the list. -- This function gets called once every 10 seconds, interval will be higher when script is done function RemovePlayerTimer() local allUnits = mist.makeUnitTable( { '[all][plane][helicopter]' } ) local unitsInZone = mist.getUnitsInZones(allUnits, { _zoneName } ) local playerExists = false for playerIndex, player in ipairs(_players) do playerExists = false for unitIndex, unit in ipairs(unitsInZone) do local unitName = "" if unit:getPlayerName() then unitName = unit:getPlayerName() else unitName = unit:getName() end if player.Name == unitName then playerExists = true break end end if not playerExists then table.remove(_players, playerIndex) _updateText = true end end end -- Create a new player and populate statistics for the new player -- Gets called from NewPlayerTimer function newPlayer(playerUnit) local unitName = playerUnit:getName() local playerName = "" if playerUnit:getPlayerName() then playerName = playerUnit:getPlayerName() else playerName = unitName end local player = { Name = playerName, Unit = Unit.getByName(unitName), UnitName = unitName, Location = {} } return player end function logString(message) trigger.action.outText(message, 10) end -- Initialize the script and start the timers Init() I'll see if I can add the actual race code shortly. 1 Dutch Flanker Display Team | LLTM 2010 Tiger Spirit Award Link to comment Share on other sites More sharing options...
BB. Posted February 4, 2014 Author Share Posted February 4, 2014 Thank you for improving. konnichiwa Link to comment Share on other sites More sharing options...
Joe Kurr Posted February 4, 2014 Share Posted February 4, 2014 You're welcome. Have a look here, it's a working airrace script I made, inspired by your script. Maybe you can use it to improve yours as well :) Dutch Flanker Display Team | LLTM 2010 Tiger Spirit Award Link to comment Share on other sites More sharing options...
steve2112 Posted January 5, 2016 Share Posted January 5, 2016 i just got NTTR and i'm totally psych'ed about making a Vegas air race. i need to study all these script, figure out what's going on. i'm sure i'll have a lot of questions. My kit: i7-4790K@4GHz / 8GB - GTX 980ti + rift CV1 - X52 pro - Multi Keyboard Remapper - 2DOF motion sim (in development) Link to comment Share on other sites More sharing options...
Midnight Posted January 5, 2016 Share Posted January 5, 2016 If it is RENO racing you are looking for.. http://forums.eagle.ru/showthread.php?t=146354 Hope to see your mission soon BB Note: Shadoh helped with the script, so many thanks to him. Scenery by me. Link to comment Share on other sites More sharing options...
guimcdo Posted November 22, 2017 Share Posted November 22, 2017 Hello BB, thanks for your nice job. As you said, the load is too important for 4 and more player, I just try your first script. I'll try your version 1.04b, but I'm afraid the load problem keep alive. Did you try to incorporate the script optimization from Joe Kurr in your script? I don't know how to use his optimization. Thanks again Link to comment Share on other sites More sharing options...
Recommended Posts