Jump to content

Scripting help needed: passing the player name to a "F10-Other" in game command ?


Flighter

Recommended Posts

Hi guys.

I need your valuable help on the following :

On a server environment I have some extra commands in the "F10-Other" menu.

How do I pass the player's name activating one of my menu-commands to the server ?

 

I have tried every method I could think of, but have fallen short..

I have tried

 

  • by adding the command either from mission editor (Trigger a "DO SCRIPT" with a "RADIO ITEM ADD" and a global variable) or
  • from server side by executing something like :
    local myCommand = missionCommands.addCommandForCoalition(coalition.side.BLUE, 'My Test Command', nil, myFunction, 'Hello from flighter' )

The menus appear and the code is run fine, but I cannot pass the player's name.

For example I can see 'Hello from flighter' been passed on to myFunction and can display it to all connected with eg trigger.action.outText

 

So, what do I need to replace the |NEEDED CODE| token below to have the player's name passed as a parameter to "myFunction" ?

 

local myCommand = missionCommands.addCommandForCoalition(coalition.side.BLUE, 'My Test Command', nil, myFunction, |NEEDED CODE| )

Any other method or idea is also welcome !

 

Cheers !

Flighter


Edited by Flighter

JUSTDOGFIGHT server - For Nickname reservation, stats, server map, instructions and other content visit our site justdogfight.com

 

🙂 Smile 🙂

Link to comment
Share on other sites

Currently the only way you can do it is to add the command on a per group basis and pass the groupId in the command. Keep in mind you should limit the size of the group to 1 so that commands don't apply to multiple people.

 

missionCommands.addCommandForGroup(3, 'My Test Command', nil, myFunction, {sender = 3})

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Hi Grimes, thanks for the fast answer.

I hadn't thought of the way you suggest. I will look into it and see if I can make it programmatically on the "player join" event handler.

 

One more question if you have the time :

I have connected my client to the server. On the client I have Lua console (from dcs-witchcraft). Exploring the environment, I find this interesting fuction called "LoGetPilotName". Running it (always on the client through the console interface in my browser) I get my valuable player name (eg "return LoGetPilotName()") gives me "Flighter".

So now I create a DoScript command in the mission (on the server ofc) and try to use it but I get the nil error message for the function. Obviously the environment running in DoScript is not the same with the Lua consoles's (or I do not call it through the proper path or I simply do it wrong). Do you know any way to set the correct environment so the client running the DoScript sees the same env as the lua console ? The would solve all my problems.

Many thanks again.

JUSTDOGFIGHT server - For Nickname reservation, stats, server map, instructions and other content visit our site justdogfight.com

 

🙂 Smile 🙂

Link to comment
Share on other sites

  • Recently Browsing   0 members

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