Jump to content

net.dostring_in() quandaries - can you help?


Recommended Posts

Posted

I'm trying to get some simple server-side stuff done (mostly experimental so I can understand how the scripts in /Hooks work) and only a few feet in I'm afraid I feel like I'm at sea...

 

Now I understand the the environment (state) for the server where my hook script runs in is separate from the mission that is running. I also read that there is mysterious function net.dostring_in(statename, code) that may allow me to invoke code in a mission that may be running, and that should allow me to access some mission framework methods like trigger.action.getUserFlag()

The problem: I can't seem to get it to work. Let's start with the following: I create a new mission in caucasus, save it as 'testM.miz'. In ME I add a simple global script 'simpleT' via DOSCRIPT at start, defined as follows:

 

simpleT = {}

function simpleT.helloWorld()

   return "it works!"

end

 

Now, is there any way I can invoke the mission's simpleT.helloWorld method from the server-side hook environment? The docs led me to believe that I could achieve this by issuing

 

   net.dostring_in("mission", "return simpleT.helloWorld();")

 

but that got me nowhere (never got an error, never got "it works!"). Studying some scripts that are available and do cool stuff like dynamic slot blocking, I can see a couple of interesting thing:

 

  • Contrary what the docs say, they use dostring_in("server", ***) -- 'server', not 'mission', for which is cant find documented anywhere. This leads me to believe that 'mission' may simply be a placeholder for named environments. How do I know the names of these environments and what is the name of the environment that contains the mission and simpleT? Naturally, I've tried, but dostring_in("server", "return simpleT.helloWorld();") also did not get the result I was hoping for.
  • Is it even possible to invoke simpleT.helloWorld() via dostring_in, and if so, how? What am I doing wrong?
  • Interestingly, all dostring_in invocations I can find seem to call trigger.action.getUserFlag() - is this coincidence, or is that the only mission API call that is open to invocation via dostring_in()? I.e. are the methods whitelisted? If so, which are on the whitelist? Are there other mission API methods available for dostring_in() 

 

Thank you for any pointers,

-ch

 

Posted

Hi, yea I think you're correct in most of what you understand at the minute, of course you cant normally run the function or have access to the net class in the mission (normally), and as far as I know it only returns from the flag function, but the netdostring function is pretty powerful and contrary to popular understanding it can run any code in any of the lua states, it just doesnt return via normal methods, so you have to think outside the box. To experiment you can 'return' via the print function and observe the log file live to see any results. That way you should be able to refine your understanding. Hit me up on Discord if you need any more info I'll try to help.

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

  • Recently Browsing   0 members

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