GetVehicleName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(12 intermediate revisions by 9 users not shown)
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__
 
{{Server client function}}
__NOTOC__
This function returns a string containing the name of the vehicle
This fake function is for use with blah & blah and does blahblahblabhalbhl
{{Needs_Checking|string getVehicleName ( element vehicle ) ?|[[User:Erorr404|Erorr404]]}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getVehicleName ( string vehicle )             
string getVehicleName ( vehicle theVehicle )             
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[vehicle]]:getName|name}}
===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''theVehicle:''' the [[vehicle]] you want to get the name of.
 
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns a string containing the requested vehicle's name, or ''false'' if the vehicle passed to the function is invalid.


==Example==  
==Example==  
This example does...
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.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function planeEnter ( theVehicle, seat, jacked ) -- when someone enters a vehicle
blabhalbalhb --abababa
    local id = getElementModel ( theVehicle ) -- get the model ID of the vehicle
--This line does this...
    if id == 519 or id == 577 then -- if theVehicle is either Shamal or AT-400
mooo
        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", root, planeEnter )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Vehicle_functions}}
[[ru:getVehicleName]]

Latest revision as of 08:23, 4 November 2020

This function returns a string containing the name of the vehicle

Syntax

string getVehicleName ( vehicle theVehicle )             

OOP Syntax Help! I don't understand this!

Method: vehicle:getName(...)
Variable: .name


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 = getElementModel ( 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", root, planeEnter )

See Also