Jump to content

(MIST) How do I catch Username in multiplayer server


Go to solution Solved by Grimes,

Recommended Posts

Posted

How do I catch Username when the Players trigger event using the MIST radio menu ?  (multiplayer server) Thanks!

local function setFlagsRED(v)
trigger.action.setUserFlag(v.flag, v.val)
missionCommands.removeItemForCoalition(coalition.side.RED, {[1] = v.path[1], [2] = v.path[2]})
end

local Menu_Item = {"Menu1","Menu2"}
local SubMenu_Item_1 = {"Function1", "Function2", "Function3"}
local SubMenu_Item_2 = {"Function1", "Function2"}


local Function_Menu1 = missionCommands.addSubMenuForCoalition(coalition.side.RED, Menu_Item[1], nil)
local Function_Menu2 = missionCommands.addSubMenuForCoalition(coalition.side.RED, Menu_Item[2], nil)

missionCommands.addCommandForCoalition(coalition.side.RED, SubMenu_Item_1[1], Function_Menu1, setFlagsRED, {flag=1, val=true, path={Menu_Item[1], SubMenu_Item_1[1]}})
missionCommands.addCommandForCoalition(coalition.side.RED, SubMenu_Item_1[2], Function_Menu1, setFlagsRED, {flag=2, val=true, path={Menu_Item[1], SubMenu_Item_1[2]}})
missionCommands.addCommandForCoalition(coalition.side.RED, SubMenu_Item_1[3], Function_Menu1, setFlagsRED, {flag=3, val=true, path={Menu_Item[1], SubMenu_Item_1[3]}})

missionCommands.addCommandForCoalition(coalition.side.RED, SubMenu_Item_2[1], Function_Menu2, setFlagsRED, {flag=4, val=true, path={Menu_Item[2], SubMenu_Item_2[1]}})
missionCommands.addCommandForCoalition(coalition.side.RED, SubMenu_Item_2[2], Function_Menu2, setFlagsRED, {flag=5, val=true, path={Menu_Item[2], SubMenu_Item_2[2]}})

 

Posted (edited)

As far as i know you can't. The info group, unit or player is added to the menu item when you add the menu item to the player/group.

Example:

missionCommands.addCommandForGroup(BIRTHgroupId, 'Send JTAC Drone to my location!', rootMenu , addjtacdrone, BIRTHgroupname)

 

BIRTHgroupname is the Group name of the group that receives this menu item, and is passed as a argument to the function "addjtacdrone"

Edited by Kanelbolle
Posted
12 hours ago, hardnick said:

Thank you!
That's a shame...because so often people come and trick and we want to know who did it.

I think I was unclear and you misunderstood. The way you are doing it, you can not.

If all your player slots are different groups, you can pass the group or player to the argument to a function like in my example.

Posted (edited)

Indeed. If you have single-player groups, you can also pass theGroup:getUnit(1):getPlayerName() as argument, and have that name displayed or written to the log.

 

Edited by cfrag
Posted

Thank you very much for your help

I don't understand about missionCommands.addCommandForGroup don't see in this page https://wiki.hoggitworld.com/view/Category:MIST

At first I thought I would use the code below to catch the player who triggers the radio menu, but every time I get it it's my own name lol

serverID = net.get_server_id( )
serverName = net.get_player_info(serverID , 'name')

Anyway, this is really difficult for me, and I really appreciate everyone's help.

Posted (edited)
6 hours ago, hardnick said:

Thank you very much for your help

I don't understand about missionCommands.addCommandForGroup don't see in this page https://wiki.hoggitworld.com/view/Category:MIST

At first I thought I would use the code below to catch the player who triggers the radio menu, but every time I get it it's my own name lol

serverID = net.get_server_id( )
serverName = net.get_player_info(serverID , 'name')

Anyway, this is really difficult for me, and I really appreciate everyone's help.

You can use the search up on the right on the page, here is the direct link:

https://wiki.hoggitworld.com/view/DCS_func_addCommandForGroup

 

You can example use "world.event.S_EVENT_BIRTH" to add the menu to every unit that spawns. (There are other ways, but i like to use this)
https://wiki.hoggitworld.com/view/DCS_event_birth

This uses event handler:

https://wiki.hoggitworld.com/view/DCS_func_addEventHandler

 

 

Edited by Kanelbolle
  • Recently Browsing   0 members

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