GetVehicleMaxPassengers: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Fixed the article (Issue #2906))
 
(4 intermediate revisions by 3 users not shown)
Line 2: Line 2:
__NOTOC__
__NOTOC__
This function returns the maximum number of passengers that a specified vehicle can hold. Only passenger seats are counted, the driver seat is excluded.
This function returns the maximum number of passengers that a specified vehicle can hold. Only passenger seats are counted, the driver seat is excluded.
{{Important Note | Only passenger seats are counted, the driver seat is excluded.}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">int getVehicleMaxPassengers ( vehicle theVehicle )</syntaxhighlight>
<syntaxhighlight lang="lua">int getVehicleMaxPassengers ( vehicle theVehicle / int modelID )</syntaxhighlight>
 
{{OOP||[[vehicle]]:getMaxPassengers|maxPassengers}}
===Required Arguments===
===Required Arguments===
*'''theVehicle:''' A handle to the [[vehicle]] that you wish to know the maximum capacity of.
*'''theVehicle:''' the [[vehicle]] that you wish to know the maximum capacity of.
OR
*'''modelID:''' the model id that you wish to know the maximum capacity of.


===Returns===
===Returns===
Returns an [[int]] indicating the maximum number of passengers that can enter a vehicle.
Returns an [[int]] indicating the maximum number of passengers that can enter a vehicle. Returns '''false''' if vehicle (or its ID) is a trailer
<!--
{{Issues|
{{Issue|2906|getVehicleOccupants returns false if vehicle is a trailer}}
}}
-->


==Example==
==Example==
Line 19: Line 28:


==See Also==
==See Also==
<!--
{{Vehicle functions}}
{{Vehicle functions}}
-->

Latest revision as of 17:11, 6 March 2023

This function returns the maximum number of passengers that a specified vehicle can hold. Only passenger seats are counted, the driver seat is excluded.


[[{{{image}}}|link=|]] Important Note: Only passenger seats are counted, the driver seat is excluded.

Syntax

int getVehicleMaxPassengers ( vehicle theVehicle / int modelID )

OOP Syntax Help! I don't understand this!

Method: vehicle:getMaxPassengers(...)
Variable: .maxPassengers


Required Arguments

  • theVehicle: the vehicle that you wish to know the maximum capacity of.

OR

  • modelID: the model id that you wish to know the maximum capacity of.

Returns

Returns an int indicating the maximum number of passengers that can enter a vehicle. Returns false if vehicle (or its ID) is a trailer

Example

This example creates a vehicle then gets the number of passenger seats and outputs it in the chat box.

newcar = createVehicle ( 520, 1024, 1024, 1024 ) -- create a vehicle
numseats = getVehicleMaxPassengers ( newcar ) -- get the passenger seat count
outputChatBox ( "This vehicle supports " .. numseats .. " passengers." ) -- show it in the chat

See Also