GetVehicleID

From Multi Theft Auto: Wiki
Revision as of 23:01, 28 March 2007 by Jbeta (talk | contribs)
Jump to navigation Jump to search

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

This example checks whether a player enters an AT-400 or a Shamal. If they do, it announces it to the chat specifying what vehicle was stolen.

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

See Also

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