Jump to content

Question with S_EVENT_PLAYER_ENTER_UNIT


FlightControl

Recommended Posts

The event S_EVENT_PLAYER_ENTER_UNIT does not seem to fire off when a player enters a unit as a tactical commander. It does only gets fired when a player enters a unit through a client.

 

 

I want to achieve that I can track aLL active players in a multi player mission.

If a players enters a unit either through the client windows or as a tactical commander / JTAC etc, that I can see this...

 

So, the S_EVENT_PLAYER_ENTER_UNIT does not work. So tried an alternative with a scheduler. Checking every 5 seconds if a player joins through the following function.

 

This function NEITHER seems to work, as the coalition.getPlayers function does not seem to return a player when joining a unit as a tactical commander... ???

 

 
function DATABASE:FollowPlayers()
trace.scheduled( self.ClassName, "FollowPlayers", self )
 local ClientUnit = 0
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers(coalition.side.RED), AlivePlayersBlue = coalition.getPlayers(coalition.side.BLUE) }
local unitId
local unitData
local AlivePlayerUnits = {}

for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
 trace.l( self.ClassName, "FollowPlayers", CoalitionData )
 for unitId, unitData in pairs( CoalitionData ) do
  if unitData:isExist() then
   local UnitName = UnitData:getName()
   local GroupName = Unit.getGroup(UnitData):getName()
   local PlayerName = UnitData:getPlayerName()
    trace.l(self.ClassName, "FollowPlayers", "Player : " .. PlayerName .. " Unit : " .. UnitName .. " Group : " .. GroupName )
    if self.Players[PlayerName] == nil then -- I believe this is the place where a Player gets a life in a mission when he enters a unit ...
    self.Players[PlayerName] = {}
    self.Players[PlayerName].HitVehicles = 0
    self.Players[PlayerName].HitPlanes = 0
    self.Players[PlayerName].HitHelicopters = 0
    self.Players[PlayerName].HitShips = 0
    self.Players[PlayerName].HitStatics = 0
    self.Players[PlayerName].HitPlayers = 0
    self.Players[PlayerName].HitUnits = {}
    MessageToUnit( UnitName, "Player " .. PlayerName .. " entered Unit " .. UnitName, 5, "/HIT" )
   end
   self.Players[PlayerName].UnitName = UnitName
   self.Players[PlayerName].GroupName = GroupName
  end
 end
end
end

Who has experience with that and who can help if any.

 

Sven


Edited by FlightControl

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Hi Sven,

I use eventhandler S_EVENT_BIRTH for MP missions. Maybe it works for your purpose too.

 

--player table to save values
playerData {}

--JIP eventhandler (this triggers on the event of a new object entering the DCS world)
JIPevHandler = {}
function JIPevHandler:onEvent(_newObject)
if _newObject.id == world.event.S_EVENT_BIRTH  and timer.getAbsTime() > 1 then
	local _eventObject = (_newObject.initiator)
	timer.scheduleFunction(JIP, _eventObject, timer.getTime() + 3)
end
end
world.addEventHandler(JIPevHandler)

--filter JIP player (now we want to syncronize only if the new object is a player)
function JIP(_eventObject)
local _plrName = _eventObject:getPlayerName()
if _plrName ~= nil  then
	local _unknownPlayer = true
		for i = 1, #playerData do
			if playerData[i].playerName == _plrName  then --we found a player already registered in the player table "playerData"
				_unknownPlayer = false
			end
		end
	
	local _clientGroupId = Group.getID(Unit.getGroup(_eventObject))		
	if _unknownPlayer then -- This is what you could do with a new player, throw him in the table and fire some code
		local _clientId = _eventObject:getID()
		local _clientName = _eventObject:getPlayerName()
		local _clientUnitName = _eventObject:getName()
		local _clientType = _eventObject:getTypeName()
	
		playerData[#playerData + 1] = {
		playerId = _clientId,
		playerGroupId = _clientGroupId,
		playerName = _clientName,
		playerUnitName = _clientUnitName,
		playerType = _clientType,
		}
					
		--### here you could place the code that updates the player that entered for the first time
	end	
	
	--### here you could place code that updates the player and it fires every time as a player becomes a unit even if its found in the player table "playerData"
end
end

--this is a looping procedure that checks every second if a player exists otherwise it wil be deleted from the player table (this needs some fine tuning to determine if player disconnected...!)
function checkPlayerExistence()
	local _j = 1
while _j <= #playerData do
	local _plr = Unit.getByName(playerData[_j].playerUnitName)
	if _plr == nil then
		table.remove(playerData, _j)
	else
		_j = _j + 1
	end
end
timer.scheduleFunction(checkPlayerExistence, nil, timer.getTime() + 1)
end

--initial start of the player check loop
timer.scheduleFunction(checkPlayerExistence, nil, timer.getTime() + 5)

 

original thread

 

.


Edited by piXel496
missing }
Link to comment
Share on other sites

Hello PiXel496,

 

Thank you for your answer. Although I find your answer encouraging, I am afraid that it is facing the same issue as I am having at this moment.

 

The function Unit:getPlayerName() will not return a player name if that player has joined a unit as a Tactical, JTAC or Game Commander.

 

Your above function is more or less the same attempt that I've made as a work-around for the lack of S_EVENT_PLAYER_ENTER_UNIT messages. And even if such a message would arrive, it seems to be impossible to find all players currently logged into the server through a client or as a commander who has joined a unit.

 

Can you please confirm that your logic is working with the CA module joining units as a commander also???

 

If this is not the case, then something should be done here....

 

Isn't it unlogic that players joining units as commanders cannot be identified through the unit:getPlayerName()???

 

Maybe I am missing something here. Please verbose...

 

kind regards,

Sven

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Can you please confirm that your logic is working with the CA module joining units as a commander also???

Negative. I don't have Combined Arms.

 

Isn't it unlogic that players joining units as commanders cannot be identified through the unit:getPlayerName()

Positive. The player-object should have a name.

 

Then I fear your question remains.. I had issues with S_EVENT_PLAYER_ENTER_UNIT in the passed and was hoping S_EVENT_BIRTH would catch your commander today.

 

 

 

 

:cry:

Link to comment
Share on other sites

I've been examining what Speed coded in slmod. He seems to get the client player names using a totally different technique...

 

he seems to have access to a "net" object in the slmod scripts, from where he can load the player name, using the following call:

 

playername = net.get_name(client_id)

 

Digging further.

 

But i am afraid that an answer is far away at this time. And i suspect that the DCS world internal scripting logic has pending issues with this matter. Either a workaround to be found, or, DCS confirms that this is a bug and a fix will be made...

 

sv.

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

The first thing that i am going to test, if the same happens in earlier versions of DCS worls. Because the last version 1.2.14 contains lots of changes to the CA module introduced recently, I suspect that the function Unit:getPlayerName() (returning a blank name when a player has joined that unit through a Game/Tactical or JTAC commander), is a bug that has been recently introduced...

 

So, I'll do these tests first with version 1.2.8 and 1.2.11 and i'll post the findings...

 

Sven

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Same behaviour in 1.2.11.

The underlying event log documents what happens in a HIT event, when a red tank is destroying a blue tank.

 

I have taken control of the red tank as a game commander in the CA module... Within the HIT event module, i query the event.initiator:getPlayerName() to identify the player name. That function returns a blank there, which cannot be! It should return my player name!

 

 

00191.758 INFO SCRIPTING: Event: 15-01-10_09-26-30~ 00:02:03~ S_EVENT_SHOT~ 16777473~ Unit #001~ red~ GROUND~ T-72B~ AI~ SHELL~ 125mm HE~ ~ ~ ~ ~ ~

00192.397 INFO SCRIPTING: Event: 15-01-10_09-26-30~ 00:02:04~ S_EVENT_HIT~ 16777473~ Unit #001~ red~ GROUND~ T-72B~ AI~ SHELL~ 125mm HE~ 16777729~ Unit #1~ blue~ GROUND~ M-2 Bradley~ AI

00192.451 INFO SCRIPTING: Event: 15-01-10_09-26-30~ 00:02:04~ S_EVENT_DEAD~ 16777729~ Unit #1~ blue~ GROUND~ M-2 Bradley~ AI~ ~ ~ ~ ~ ~ ~ ~

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Dear ED,

 

The Unit.getPlayerName() does not return the player name when a player joins a unit as a Game Commander, Tactical Commander (using RIGHT-ALT-J)

 

I've made the following test mission to prove it ...

 

It contains 4 units: 2 planes and 2 ground forces.

I've made a continuous trigger in that mission, with the following code:

 
RUTank = (Unit.getByName( 'RU TANK'))
USTank = Unit.getByName('US TANK')
RUPlane = Unit.getByName('RU PLANE')
USPlane = Unit.getByName('US PLANE')
local Msg = ""
if RUTank and RUTank:getPlayerName() then
Msg = Msg .. "RU TANK Player Name = " .. RUTank:getPlayerName() .. ' / '
end
if USTank and USTank:getPlayerName() then
Msg = Msg .. "US TANK Player Name = " .. USTank:getPlayerName() .. ' / '
end

if USPlane and USPlane:getPlayerName() then
Msg = Msg .. "US PLANE Player Name = " .. USPlane:getPlayerName() .. ' / '
end
if RUPlane and RUPlane:getPlayerName() then
Msg = Msg .. "RU PLANE Player Name = " .. RUPlane:getPlayerName()
end
trigger.action.outText(Msg, 10)

The code simply displays the player name if a player joins a unit. So you can use this mission to test yourself. When a player joins a plane unit, the getPlayerName() function works, when the player joins a unit as a Commander using RIGHT-ALT-J (in map view), it does not work...

 

Don't know if you consider this as an issue. The consequence is that only players that join planes or helicopters can be tracked. For Commanders not...

 

When ED can and would fix this issue, it would allow mission developers to track players (and build a scoring framework) on a consistent basis...

 

So, please check this mission, and validate if this is a design issue, a bug or something that was never meant to work this way ...

 

Sven

Scoring.miz

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

AFAIK it has never worked with CA controlled units, only "client" aircraft. For a while multiplayer didn't register which units were controlled by the player, but I think this has changed. I'll forward the request as it would be useful.

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

Yep. Thanks grimes. Got already confirmation from ED that it will be checked. This fix would be really welcome for a lot of mission designers I guess :-)

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

  • 3 years later...

Any news on this after more than three years?

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

  • 2 months later...

Will this ever be fixed by Eagle Dynamics? Ever?

Come on guys ... P.L.E.A.S.E. ... We're asking kindly to consider this ... P.L.E.A.S.E. ...

 

P.L.E.A.S.E. ...

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

Is there any place where relevant bugs are listed, maybe with a ranking? So it would be a little bit easier to remind ED to work a little bit on it and to rethink their priorities.

 

 

Polite but visible.

Waiting for the return of: -TLP- -True LAN Play- Multiplayer without permanent internet connection to ED master-server. Plane wishlist: Antonov - AN-2

Link to comment
Share on other sites

Is there any place where relevant bugs are listed, maybe with a ranking? So it would be a little bit easier to remind ED to work a little bit on it and to rethink their priorities.

 

 

Polite but visible.

 

 

Prioritization of bug resolvement is the most complicated algorithm that exists my friend. Especially for end-users.

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

ED are doing work on CA (nineline menthioned it somewhere), maybe they can fix this issue when doing that ?

METAR weather for DCS World missions

 

Guide to help out new DCS MOOSE Users -> HERE

Havoc Company Dedicated server info Connect IP: 94.23.215.203

SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245

Please contact me HERE if you have any server feedback or METAR issues/requests

Link to comment
Share on other sites

  • 8 months later...
Any news on this after more than three years?

Any news on this after more than four years?

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...
  • Recently Browsing   0 members

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