GetVehicleID: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:
{{server client function}}
{{server client function}}
{{Deprecated}}
{{Deprecated}}
Please use [[getElementModel]]
This function retrieves the ID of a vehicle as an integer value.
This function retrieves the ID of a vehicle as an integer value.



Revision as of 21:29, 20 April 2011

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions, but there should be a more generic way to perform what it does.


Please use getElementModel

This function retrieves the ID of a vehicle as an integer value.

Syntax

int getVehicleID ( vehicle theVehicle )             

Required Arguments

  • theVehicle: The vehicle you want to get the ID of.

Returns

Returns an integer containing the requested vehicle's ID, or false if the vehicle passed to the function is invalid.

Example

function planeEnter ( theVehicle, seat, jacked ) --when someone enters a vehicle
  id = getVehicleID ( theVehicle ) -- get the ID of the vehicle
  if id == 519 or id == 577 then --if theVehicle is one of these two planes
     vehiclename = getVehicleName ( theVehicle ) -- define the vehicle name 
     outputChatBox ( "Someone stole a " .. vehiclename .. "!" ) -- announce that someone stole the plane
  end
end
-- add the event to the event handler
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), planeEnter )

See Also

GTASA IDs (vehicles, weapons, weathers, characters, colors): http://info.vces.net/ (Special thanks to Brophy and Ratt for making these lists)