Jump to content

How to use the function net.load_mission() on dedicated server?


Psyko-fr

Recommended Posts

Hello guys!

I'm actually coding for our private server a script who load a submenu for changing the running mission. It will give the possibility to all players to choose a mission registered on a table, and load it.

Exemple of the submenu's

local Mmenu= missionCommands.addSubMenu("LOAD MISSION MENU")
    local subMn1= missionCommands.addCommand("RESTART MISSION", Mmenu, Restart, {MissNumb = 0})
    
    local subTRG1 = missionCommands.addSubMenu("TRAININGS PACK 1", Mmenu)
    
        local subTRG11= missionCommands.addSubMenu("NEVADA", subTRG1)
            local subTRG111= missionCommands.addCommand("GOOD WEATHER", subTRG11, LoadMiss, {MissNumb = 1})
            local subTRG112= missionCommands.addCommand("MID WEATHER", subTRG11, LoadMiss, {MissNumb = 2})
            local subTRG113= missionCommands.addCommand("BAD WEATHER", subTRG11, LoadMiss, {MissNumb = 3})

 

However, i'm unable to run the command net.load_mission(my_mission.miz). The function run properly (all the debug text appears except the last) but the net.load_mission() doesn't execute.

the load function :

local function LoadMiss(val)
    trigger.action.outText("**Launching LoadFunc...**",5 ,0) 
--debug text

    Missval = val.MissNumb
    trigger.action.outText("**Missval = "..tostring(Missval).."**",5 ,0)  
--debug text
    trigger.action.outText("**Changing mission... **"..tostring(MissTBL[Missval]).."**",5 ,0) --debug text
    net.load_mission(lfs.writeDir() .. "Missions\\SERVEUR\\" .. ""..tostring(MissTBL[Missval]).."")
    trigger.action.outText("**Load command sent...**",5 ,0)  
--debug text

end

Accord to the documentation found on wiki.hoggitworld.com, it seems that I have to use a hook to enable this function.

My level on lua coding is quite poor, so how can I do this hook? And what I have to write on this hook?

Thanks for your help!

Psyko - FFS-03

A-10C virtual pilot

Link to comment
Share on other sites

  • 2 weeks later...

There are many errors in the way this is written, but I think the key reason it doesn't work is that the net.load_mission is not available to the 'mission luaState'. Try this...

local function load_next_miz()
  local code = [[
      _G.net.load_next_mission()
  ]]
  return pcall(net.dostring_in, 'gui', code)
end

 

Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans.

Discord: PravusJSB#9484   twitch.tv/pravusjsb  https://www.patreon.com/XSAF  https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu

Work with me on Fiverr: https://www.fiverr.com/pravusjsb

Link to comment
Share on other sites

I've taken a completely different approach to this problem. I combine my scripting with ME triggers. In the mission editor I set a TRIGGERS ONCE with CONDITIONS FLAG IS TRUE(####) and ACTIONS LOAD MISSION(Mission Name.miz)

Then, in my scripting I simple use a function to: trigger.action.setUserFlag(####, true)

 

[PC] ASUS X570E - Ryzen 9  5950X - RX 6900 XT - 32GB 3600Mhz

Hornet, A-4E-C, Huey, Ka-50, Mi-8, F-15E, F-14

Join us on Death Dealers PvE server.

Link to comment
Share on other sites

  • 3 months later...

I'm late to this part and ma trying to do something the same thing.  

The "net.load_mission" function isn't working. I am very much a lua noob, so not sure what your code does.  Also not sure what is meant by "the key reason it doesn't work is that the net.load_mission is not available to the 'mission luaState'. "

 

Thanks

----------------

AKA_Clutter

 

Win 10 Pro, Intel i7 8700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, Oculus Rift S, HP Reverb G2, CH Fighterstick, Pro Throttle and Pro Rudder Pedals HOTAS, TM Warthog HOTAS, MFG Rudder Pedals, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...