GetVehicleName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 21: Line 21:
     if id == 519 or id == 577 then -- if theVehicle is either Shamal or AT-400
     if id == 519 or id == 577 then -- if theVehicle is either Shamal or AT-400
         local vehicleName = getVehicleName ( theVehicle ) -- get the name of theVehicle
         local vehicleName = getVehicleName ( theVehicle ) -- get the name of theVehicle
         outputChatBox ( "Someone stole a " .. vehicleName .. "!" ) -- announce that someone stole the plane
         outputChatBox ( "Someone has stolen a " .. vehicleName .. "!" ) -- announce that someone has stolen the plane
     end
     end
end
end

Revision as of 15:03, 25 October 2009

This function returns a string containing the name of the vehicle

Syntax

string getVehicleName ( vehicle theVehicle )             

Required Arguments

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

Returns

Returns a string containing the requested vehicle's name, 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.

function planeEnter ( theVehicle, seat, jacked ) -- when someone enters a vehicle
    local id = getVehicleID ( theVehicle ) -- get the model ID of the vehicle
    if id == 519 or id == 577 then -- if theVehicle is either Shamal or AT-400
        local vehicleName = getVehicleName ( theVehicle ) -- get the name of theVehicle
        outputChatBox ( "Someone has stolen a " .. vehicleName .. "!" ) -- announce that someone has stolen the plane
    end
end
-- add the event handler to the event
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), planeEnter )

See Also