Difference between revisions of "DCS hook onPlayerChangeSlot"

From DCS World Wiki - Hoggitworld.com
 
Line 37: Line 37:
 
List of Callbacks: {{listOfDCSHooks}}
 
List of Callbacks: {{listOfDCSHooks}}
  
|examples=  
+
|examples= The following populates a table indexed by player names with the last slot they were in.
 +
 
 +
  local hook = {}
 +
  local playerUnitList = {}
 +
  function hook.onPlayerChangeSlot(playerID)
 +
        local playerName = net.get_player_info(playerID, 'name')
 +
        local slot = net.get_player_info(playerID, 'slot')
 +
        playerUnitList[playerName] = slot
 +
    end
 +
   
 
|notes=  
 
|notes=  
 
}}
 
}}
 
[[Category:DCS Hooks|onPlayerChangeSlot]]
 
[[Category:DCS Hooks|onPlayerChangeSlot]]

Latest revision as of 23:09, 18 August 2023


Envrioment: Server
Function: onPlayerChangeSlot Added with: 2.5.0
Member Of: hook
Syntax: nothing hook.onPlayerChangeSlot(number playerId )
Description: Occurs when a player successfully moves into a new slot. This will not be called for example if they try to RIO for a player and the pilot rejects the request.


Return Value: nothing
Return Actions:
Examples: The following populates a table indexed by player names with the last slot they were in.
  local hook = {}
  local playerUnitList = {}
  function hook.onPlayerChangeSlot(playerID) 
       local playerName = net.get_player_info(playerID, 'name')
       local slot = net.get_player_info(playerID, 'slot')
       playerUnitList[playerName] = slot
   end
Related Functions: List of Callbacks: onMissionLoadBegin, onMissionLoadProgress, onMissionLoadEnd, onSimulationStart, onSimulationStop, onSimulationFrame, onSimulationPause, onSimulationResume, onGameEvent, onNetConnect, onNetMissionChanged, onNetConnect, onNetDisconnect, onPlayerConnect, onPlayerDisconnect, onPlayerStart, onPlayerStop, onPlayerChangeSlot, onPlayerTryConnect, onPlayerTrySendChat, onPlayerTryChangeSlot
Notes: