GetVehicleUpgradeSlotName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server client function}}
This function returns the name of an upgrade slot name (e.g. roof, spoiler).
This function returns the name of an upgrade slot name (e.g. roof, spoiler).


Line 15: Line 16:


==Example==  
==Example==  
<section name="Server" class="server" show="true">
This example prints the name and upgrades on each slot of an entered vehicle to the chat.
This example prints the name and upgrades on each slot of an entered vehicle to the chat.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 25: Line 27:
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), scriptOnPlayerEnterVehicle )
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), scriptOnPlayerEnterVehicle )
</syntaxhighlight>
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Vehicle_functions}}
{{Vehicle_functions}}

Revision as of 14:57, 4 August 2007

This function returns the name of an upgrade slot name (e.g. roof, spoiler).

Syntax

There are two ways of using this function, the parameter can either be the slot ID (0 to 16) or an upgrade ID (1000 to 1193)

string getVehicleUpgradeSlotName ( int slot/upgrade )

Required Arguments

  • slot/upgrade: the slot ID or corresponding upgrade ID of which you want the name.

Returns

Returns a string with the slot name if a valid slot or upgrade ID was given, false otherwise.

Example

Click to collapse [-]
Server

This example prints the name and upgrades on each slot of an entered vehicle to the chat.

function scriptOnPlayerEnterVehicle ( theVehicle, seat, jacked )
  local upgrades = getVehicleUpgrades ( theVehicle )
  for upgradeKey, upgradeValue in ipairs ( upgrades ) do
    outputChatBox ( getVehicleUpgradeSlotName ( upgradeKey - 1 ) .. ": " .. upgradeValue )
  end
end
addEventHandler ( "onPlayerEnterVehicle", getRootElement(), scriptOnPlayerEnterVehicle )

See Also