Module MPVehicleGE

MPVehicleGE API.

Author of this documentation is Neverless

Usage:

  • local gameVehicleID = getGameVehicleID("0-0") -- internal access
    
  • local gameVehicleID = MPVehicleGE.getGameVehicleID("0-0") -- external access
    

Functions

getGameVehicleID (serverVehicleID) Resolves a serverVehicleID into the gameVehicleID
getServerVehicleID (gameVehicleID) Reolves a gameVehicleID into the serverVehicleID
getVehicleByServerID (serverVehicleID) Returns the vehicle table for this Vehicle
getVehicleByGameID (gameVehicleID) Returns the vehicle table for this Vehicle
getPlayerByName (name) Returns this Players table and ID
isOwn (gameVehicleID) Checks if the given vehicle belongs to this Client
getOwnMap () Returns a table that contains a list of all Vehicles that are owned by this Client
getVehicleMap () Returns a table of all known multiplayer vehicles
getDistanceMap () Returns a table containing the distance from each Multiplayer Vehicle to this Clients Point of View
getNicknameMap () Returns a table containing all Multiplayer gameVehicleID's with their Ownernames
setPlayerNickPrefix (targetName, tagSource, text) Adds a Prefix to a given PlayerTag.
setPlayerNickSuffix (targetName, tagSource, text) Adds a Suffix to a given PlayerTag.
hideNicknames (hide) Turns On or Off the Nametag drawing from BeamMP
getPlayers () Returns the whole Players table
getVehicles () Returns the whole Vehicles table
setVehicleRole (playerIDVehicleID, roleName[, displayName]) Sets a custom role and name to a vehicle
removeVehicleRole (playerIDVehicleID) Removes a custom Role and Name from a Vehicle
createRole (roleName[, tag[, shorttag[, red[, green[, blue]]]]]) Creates a custom role to be used with setVehicleRole.
removeRole (roleName) Removes a custom role.

Tables

roleToInfo Contains Information about Backend authorized Roles
roleToInfo_subtable (in table) Specifies the table in roleToInfo
simplified_vehicles Contains the known simplified Vehicle versions.
custom_roleToInfo Contains the Custom Roles created with createRole
custom_vehicleRoles Contains only the Vehicles that have set Custom roles to it with setVehicleRole
custom_vehicleRoles_subtable (in table) Specifies the table in custom_vehicleRoles
players Contains all known Players.
players_subtable (in table) Specifies the table in players
players_nickPrefixes (in table) Specifies the nickPrefixes table for players_subtable
players_nickSuffixes (in table) Specifies the nickSuffixes table for players_subtable
players_role (in table) Specifies the role table for players_subtable
players_vehicles (in table) Specifies the vehicles table for players_subtable.
vehicles Contains all known Multiplayer Vehicles.
vehicles_subtable (in table) Specifies the table in vehicles
vehicles_spectators (in table) Specifies the spectators table in vehicles_subtable.
vehicles_spawnQueue (in table) Specifies the spawnQueue table in vehicles_subtable
vehiclesMap Resolves gameVehicleID to serverVehicleID
distanceMap Contains the Distances in meters from the Clients POV to the known Multiplayer Vehicles


Functions

getGameVehicleID (serverVehicleID)
Resolves a serverVehicleID into the gameVehicleID

Parameters:

  • serverVehicleID string X-Y. Where X is the PlayerID and Y the Players VehicleID

Returns:

    integer If success eg. 11171

Or

    -1 If either the Vehicle is unknown or the Vehicle is not Spawned on the Client

Usage:

    local gameVehicleID = getGameVehicleID("0-0")
getServerVehicleID (gameVehicleID)
Reolves a gameVehicleID into the serverVehicleID

Parameters:

  • gameVehicleID integer

Returns:

    string If success. serverVehicleID eg. "0-0"

Or

    nil If either the gameVehicleID is unknown or invalid

Usage:

    local serverVehicleID = getServerVehicleID(11171)
getVehicleByServerID (serverVehicleID)
Returns the vehicle table for this Vehicle

Parameters:

  • serverVehicleID string X-Y. Where X is the PlayerID and Y the Players VehicleID

Returns:

    vehicles_subtable

Or

    nil If the serverVehicleID is invalid

Usage:

    local vehicle = getVehicleByServerID("0-0")
getVehicleByGameID (gameVehicleID)
Returns the vehicle table for this Vehicle

Parameters:

  • gameVehicleID integer

Returns:

    vehicles_subtable

Or

    nil If the gameVehicleID is invalid

Usage:

    local vehicle = getVehicleByGameID(11171)
getPlayerByName (name)
Returns this Players table and ID

Parameters:

  • name string The Players Name

Returns:

  1. players_subtable
  2. integer playerID

Or

    nil If the name is invalid

Usage:

    local player, playerID = getPlayerByName("Neverless")
isOwn (gameVehicleID)
Checks if the given vehicle belongs to this Client

Parameters:

  • gameVehicleID integer

Returns:

    bool true if this Vehicle belongs to this Client

Or

    bool false if this Vehicle does not belong to this Client or when the Vehicle does not exist

Usage:

  • if getServerVehicleID(11171) ~= nil and isOwn(11171) then local isOwn = true end -- only true when the vehicle exists and isOwn()
  • local isOwn = isOwn(11171)
getOwnMap ()
Returns a table that contains a list of all Vehicles that are owned by this Client

Returns:

  1. table {gameVehicleID_1 = vehicles_subtable}
  2. table {gameVehicleID_N = vehicles_subtable}

See also:

Usage:

    local myVehicles = getOwnMap()
getVehicleMap ()
Returns a table of all known multiplayer vehicles

Returns:

  1. table {serverVehicleID_1 = gameVehicleID}
  2. table {serverVehicleID_N = gameVehicleID}

Usage:

    local vehicles = getVehicleMap()
getDistanceMap ()
Returns a table containing the distance from each Multiplayer Vehicle to this Clients Point of View

Returns:

    distanceMap

Usage:

    local distanceMap = getDistanceMap()
getNicknameMap ()
Returns a table containing all Multiplayer gameVehicleID's with their Ownernames

Returns:

  1. table {gameVehicleID_1 = OwnerName}
  2. table {gameVehicleID_N = OwnerName}

Usage:

    local nicknameMap = getNicknameMap()
setPlayerNickPrefix (targetName, tagSource, text)
Adds a Prefix to a given PlayerTag. eg. "1st. Neverless". You can set multiple by having alternating tagSource's

Parameters:

  • targetName string PlayerName
  • tagSource string Name of the Prefix
  • text string Text to add

Returns:

    nil

Usage:

    setPlayerNickPrefix("Neverless", "MYPREFIX", "1st.")
setPlayerNickSuffix (targetName, tagSource, text)
Adds a Suffix to a given PlayerTag. eg. "Neverless [In Mission]". You can set multiple by having alternating tagSource's

Parameters:

  • targetName string PlayerName
  • tagSource string Name of the Prefix
  • text string Text to add

Returns:

    nil

Usage:

    setPlayerNickSuffix("Neverless", "MYSUFFIX", "[In Mission]")
hideNicknames (hide)
Turns On or Off the Nametag drawing from BeamMP

Parameters:

  • hide bool

Returns:

    nil

Usage:

    hideNicknames(true)
getPlayers ()
Returns the whole Players table

Returns:

    players

Usage:

    local players = getPlayers()
getVehicles ()
Returns the whole Vehicles table

Returns:

    vehicles

Usage:

    local vehicles = getVehicles()
setVehicleRole (playerIDVehicleID, roleName[, displayName])
Sets a custom role and name to a vehicle

Parameters:

  • playerIDVehicleID string X-Y. Where X is the PlayerID and Y the Players VehicleID
  • roleName string The name of the Custom Role. Setting this to "BLANK" will make the player tag invinsible
  • displayName string sets a Custom name to this Vehicle. Give 0 to not set a custom name (optional)

Returns:

    1 If success

Or

    0 playerIDVehicleID is invalid. Vehicle or Player might not exists

Or

    -1 roleName does not exist

Usage:

    setVehicleRole("0-0", "MYROLE", "Unknown")
removeVehicleRole (playerIDVehicleID)
Removes a custom Role and Name from a Vehicle

Parameters:

  • playerIDVehicleID string X-Y. Where X is the PlayerID and Y the Players VehicleID

Returns:

    nil

Usage:

    removeVehicleRole("0-0")
createRole (roleName[, tag[, shorttag[, red[, green[, blue]]]]])
Creates a custom role to be used with setVehicleRole. Give 0 to not use a Optional param.

Parameters:

  • roleName string Name of the Role
  • tag string Sets a optional tag. Playername [Long tag] (optional)
  • shorttag string Sets a optional shorttag: Playername [Short Tag] (optional)
  • red integer 0 to 255 (optional)
  • green integer 0 to 255 (optional)
  • blue integer 0 to 255 (optional)

Returns:

    true If success

Or

    false When a color value is below 0 or when the roleName == "BLANK"

Usage:

    createRole("MYROLE", "Custom", "Ctm", 252, 107, 3)
removeRole (roleName)
Removes a custom role. All vehicles with that role will also loose it.

Parameters:

Returns:

  1. true If success
  2. false When the Role doesnt exists

Usage:

    removeRole("MYROLE")

Tables

roleToInfo
Contains Information about Backend authorized Roles

Fields:

Usage:

    local roleInfo = roleToInfo["USER"]
roleToInfo_subtable
(in table) Specifies the table in roleToInfo

Fields:

  • backcolor ColorI Contains RGBA Values wiki.beamng.com/Lua:Reference#ColorI
  • tag string Contains the Tag
  • shorttag string Contains the Short version of Tag

Usage:

  • local roleInfo = roleToInfo["USER"].tag
  • local roleInfo = roleToInfo["USER"].backcolor.r
simplified_vehicles
Contains the known simplified Vehicle versions. JBeamNames are Strings eg. "moonhawk", "unicycle"

Fields:

  • JBeamName_1 string eg. "simple_traffic_coupe"
  • JBeamName_N string

Usage:

    local simplified = simplified_vehicles["coupe"]
custom_roleToInfo
Contains the Custom Roles created with createRole

Fields:

Usage:

    local roleInfo = custom_roleToInfo["CUSTOMROLE"]
custom_vehicleRoles
Contains only the Vehicles that have set Custom roles to it with setVehicleRole

Fields:

  • serverVehicleID_1 custom_vehicleRoles_subtable Contains Role and DisplayName of that Vehicle
  • serverVehicleID_N custom_vehicleRoles_subtable ..

Usage:

    local roleInfo = custom_vehicleRoles["0-0"]
custom_vehicleRoles_subtable
(in table) Specifies the table in custom_vehicleRoles

Fields:

  • Role string Contains the RoleName for this Vehicle
  • DisplayName string Contains the custom Displayname for this Vehicle

Usage:

    local displayName = custom_roleToInfo["0-0"].DisplayName
players
Contains all known Players. PlayerID's are integers starting at 0

Fields:

Usage:

    local player = players[0]
players_subtable
(in table) Specifies the table in players

Fields:

  • name string Holds the PlayerName linked to this PlayerID
  • activeVehicleID integer Contains the serverVehicleID as eg. 0 not 0-0, that the Client is currently Viewing. Can be the players own vehicle or another players vehicle.
  • shortname string Shortend name of the Shortnames Option
  • playerID integer ID that the Server has given this Player
  • isLocal bool true if this player is this client
  • ping integer Contains the current known ping of this Player
  • nickPrefixes players_nickPrefixes Contains all Prefixes for Tag drawing
  • nickSuffixes players_nickSuffixes Contains all Suffixes for Tag drawing
  • role players_role Contains information about the backend authorized Role of this Player
  • vehicles players_vehicles Note from the Author of this Documentation: Im unsure about this tables contents

Usage:

    local name = players[0].name
players_nickPrefixes
(in table) Specifies the nickPrefixes table for players_subtable

Fields:

  • tagSource_1 string Contains the added Text
  • tagSource_N string Contains the added Text

Usage:

    local prefixes = players[0].nickPrefixes
players_nickSuffixes
(in table) Specifies the nickSuffixes table for players_subtable

Fields:

  • tagSource_1 string Contains the added Text
  • tagSource_N string Contains the added Text

Usage:

    local suffixes = players[0].nickSuffixes
players_role
(in table) Specifies the role table for players_subtable

Fields:

  • name string Name of the Role
  • backcolor ColorI RGBA color. Can be nil
  • tag string Can be nil
  • shorttag string Can be nil

Usage:

  • local roleInfo = players[0].role
  • local roleInfo = players[0].role.backcolor.r
players_vehicles
(in table) Specifies the vehicles table for players_subtable. Note from the Author of this Documentation: Im unsure about this tables contents

Fields:

  • gameVehicleID integer
  • isSpawned bool
  • IDs unknown
vehicles
Contains all known Multiplayer Vehicles. serverVehicleID is a String X-Y. Where X is the PlayerID and Y the Players VehicleID

Fields:

Usage:

    local vehicle = vehicles["0-0"]
vehicles_subtable
(in table) Specifies the table in vehicles

Fields:

  • name string Holds the OwnerName of this Vehicle
  • gameVehicleID integer The ID that the game gives this Vehicle on Spawn
  • jbeam string JBeam name of the Vehicle
  • remoteVehID integer gameVehicleID on the Client that owns this Vehicle
  • serverVehicleString integer serverVehicleID as eg. 0 not 0-0
  • ownerID integer The PlayerID of the player that owns this Vehicle
  • Holds string the OwnerName of that Vehicle (duplicate?)
  • isLocal bool True when this Vehicle is owned by this Client
  • isSpawned bool True once the Vehicle is no longer quoed and Available in the World. Is set to False when isDeleted
  • isDeleted bool True once the Vehicle has been deleted by the Client (it becomes a black blob)
  • position nil Appears to be unused
  • rotation nil Appears to be unused
  • spectators vehicles_spectators Holds PlayerID's that are spectating this Vehicle at the moment
  • spawnQueue vehicles_spawnQueue Holds the data required for when the Spawn is triggered. Is nil if this Vehicles Spawn is not qued.
  • editQueue string Holds the data required for when a Edit is triggered. serverVehicleID:{vehicleJson}. Is nil is no Edit for this Vehicle is qued

Usage:

    local gameVehicleID = vehicles["0-0"].gameVehicleID
vehicles_spectators
(in table) Specifies the spectators table in vehicles_subtable. Every player in this table is currently spectating this vehicle

Fields:

  • PlayerID_1 true
  • PlayerID_N true

Usage:

  • for PlayerID, v in pairs(vehicles["0-0"].spectators) do end
  • local spectators = vehicles["0-0"].spectators
vehicles_spawnQueue
(in table) Specifies the spawnQueue table in vehicles_subtable

Fields:

  • playerNickname string OwnerName of the Vehicle to be Spawned
  • serverVehicleID string serverVehicleID as eg. 0-0
  • data string Format = ROLE:PlayerName:serverVehicleID:{vehicleJson}

Usage:

    if vehicles["0-0"].spawnQueue then local vehicleData = vehicles["0-0"].spawnQueue.data end
vehiclesMap
Resolves gameVehicleID to serverVehicleID

Fields:

  • gameVehicleID_1 integer Contains serverVehicleID as eg. 0 not 0-0
  • gameVehicleID_N integer ..

Usage:

    local serverVehicleID = vehiclesMap[11171]
distanceMap
Contains the Distances in meters from the Clients POV to the known Multiplayer Vehicles

Fields:

  • gameVehicleID_1 float
  • gameVehicleID_N float

Usage:

    local distanceTo = distanceMap[11171]
generated by LDoc 1.5.0 Last updated 2023-05-19 21:54:55