DCS hook onPlayerTryChangeSlot

From DCS World Wiki - Hoggitworld.com
Revision as of 01:28, 15 May 2021 by Grimes (talk | contribs) (Created page with "{{Template:DCS_hooks_callbacks |fName= onPlayerTryChangeSlot |vNum= 2.5.0 |par1= hook |par2= |par3= |par4= |desc= Occurs when a player clicks on...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Envrioment: Server
Function: onPlayerTryChangeSlot Added with: 2.5.0
Member Of: hook
Syntax: nothing hook.onPlayerTryChangeSlot(number playerId, number side, string slotId )
Description: Occurs when a player clicks on a new slot to try and enter a given aircraft. Can be used for slot blocking purposes within a mission or to force players access to one team or the other.

playerId is who is attempting to join a slot

side is the coalition the aircraft belongs to

slotId is an identifier for the slot the player is trying to join. The identifier is based on the unitID for a given aircraft. However with multicrew seats the slotId has an additional "_x" added to the unitId to specify which seat it is.


IMPORTANT: If any value is returned with this function then any other callback that uses it will be ignored. If no choice is to be made, then do NOT return any value. DCS itself uses this callback as part of the multicrew slot interface. By returning true the pilot will not get the prompt or have any choice in allowing another player from entering their aircraft.


Return Value: nothing
Return Actions: Value 1: boolean
  True: Allows the user into the slot
  False prevents the user from entering the slot.
Examples: Checks a list of players indexed by UCID to see if they have a coalition value assigned to them. If they do and the side is not the same then it denies the request. Otherwise it creates the entry with the specified side and does not return the function as to allow any other callback that might check for onPlayerTryChangeSlot to do its code.
  function myCall.onPlayerTryChangeSlot(playerId, side, slotId)
      local ucid = net.get_player_info(id, 'ucid')
      if someList[ucid] and someList[ucid].coa ~= side then
          return false
      else
         someList[ucid] = {coa = side}
      end
  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: