Jump to content

How to display players name in a message


Knock-Knock

Recommended Posts

Been trying without luck, to figure out how to show the given players / clients name in a message, when this player / client enters a given trigger zone.

How do I go about that?

- Jack of many DCS modules, master of none.

- Personal wishlist: F-15A, F-4S Phantom II, JAS 39A Gripen, SAAB 35 Draken, F-104 Starfighter, Panavia Tornado IDS.

 

| Windows 11 | i5-12400 | 64Gb DDR4 | RTX 3080 | 2x M.2 | 27" 1440p | Rift CV1 | Thrustmaster Warthog HOTAS | MFG Crosswind pedals |

Link to comment
Share on other sites

Has to be done via scripting as far as I'm aware. There's a few ways to go about it, but just as an example to put you on the right track. Create a unit for the player, create trigger with condition of unit in zone and select your zone and player unit, then action do script: (substitute Pilot #001 for what ever the pilot section is set as for your unit. It defaults to 'Pilot #xxx)

 

trigger.action.outText(Unit.getByName('Pilot #001'):getPlayerName(),10)

 

As I said this is just to show you how to get the players name. Depending on what you're trying to achieve and if it's for single player or multiplayer, it could be worthwhile checking if it's in the zone via the script as well.

 

Edit: At work and typed this on my phone so I can't double check it works, but it should. I would also link the hoggit wiki for you to look at the unit functions but it seems to be down at the moment.

-16AGR- 16th Air Guards Regiment is always looking for pilots - http://www.16agr.com

 

EWRS - Early Warning Radar Script

 

Specs:

 

 

Gigabyte Sniper Z5-S

Intel i5-4670k 3.4GHz OC'd 3.9GHz w/ Thermaltake 120mm Water 3.0 Pro Liquid CPU Cooler

16GB RAM

Gigabyte GTX 1080

TM Hotas Warthog: SN: 06976

Saitek Pro Flight Combat Rudder Pedals

TrackIR5 with TrackClipPro & Oculus Rift

2x 28" 4k UHD Monitors (3840x2160 each) + 1280x1024

 

 

Link to comment
Share on other sites

Not sure about your context (i.e. only using the Mission Editor, or using a Lua script/file for everything). Unfortunately you need to have some scripting, as obtaining the player name is done through the Unit object's "getPlayerName()" method.

 

Assuming you're trying to do everything in the mission editor with minimal scripting, you could do the following:

 

For each human spawn-able aircraft create a separate trigger:

 

Condition: UNIT INSIDE ZONE(<unit-name>, <zone-name>)

Action: DO SCRIPT: trigger.action.outText(Unit.getByName(<unit-name>):getPlayerName(), 20)

 

 

Of course it would be cleaner using a Lua script to check if any group is in the zone, then figure out what group/unit it is and displaying the player name. The above is just to keep it simple with respect to using the Mission Editor.

 

Relent

Link to comment
Share on other sites

LOL Steggles, I guess great minds think alike :)... You had faster fingers than me

 

 

EDIT - just to add, you probably want to display more than just the player name, so here's a slight expansion of the example above to display more text in the message (replace Player1 and Trigger1 with the actual values in your mission):

 

Condition: UNIT INSIDE ZONE(Player1, Trigger1)

Action: DO SCRIPT: trigger.action.outText(Unit.getByName("Player1"):getPlayerName() .. " entered trigger zone Trigger1", 20)

 

The trigger.action.outText() method has two parameters, the text to be displayed, and the duration of the message. The ".." is used to concatenate multiple string values so that the combination of them is treated as one string (i.e. one parameter to the method).

 

Not sure how much scripting you've done, so this may be too rudimentary, but I'm going on the assumption that you haven't done any scripting.

 

Good luck!


Edited by 609_Relentov
Link to comment
Share on other sites

That is correct, I havent done any scripting. Im plunching into the deep end :)

Thx gents, I will give these a try this afternoon.

 

 

What I have running is ment for multiplayer, and single player. Its a practice sandbox, with multiple planes to choose from, and when a player enters a zone, this spawns a set of hostiles randomly from a pool of planes, for the specific plane type, that the player just flew into the zone. All that I have working, but rather than just displaying 'You entered Red airspace', I was trying to replace 'You' with the given players name.

- Jack of many DCS modules, master of none.

- Personal wishlist: F-15A, F-4S Phantom II, JAS 39A Gripen, SAAB 35 Draken, F-104 Starfighter, Panavia Tornado IDS.

 

| Windows 11 | i5-12400 | 64Gb DDR4 | RTX 3080 | 2x M.2 | 27" 1440p | Rift CV1 | Thrustmaster Warthog HOTAS | MFG Crosswind pedals |

Link to comment
Share on other sites

Condition: UNIT INSIDE ZONE(Player1, Trigger1)

Action: DO SCRIPT: trigger.action.outText(Unit.getByName("Player1"):getPlayerName() .. " entered trigger zone Trigger1", 20)

 

 

Using the above, I have it working. A lot of triggers though, but good thing there is a clone function :)

 

Once again, thank you :thumbup:

- Jack of many DCS modules, master of none.

- Personal wishlist: F-15A, F-4S Phantom II, JAS 39A Gripen, SAAB 35 Draken, F-104 Starfighter, Panavia Tornado IDS.

 

| Windows 11 | i5-12400 | 64Gb DDR4 | RTX 3080 | 2x M.2 | 27" 1440p | Rift CV1 | Thrustmaster Warthog HOTAS | MFG Crosswind pedals |

Link to comment
Share on other sites

  • Recently Browsing   0 members

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