GetVehicleUpgradeSlotName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
Line 21: Line 21:
==Example==  
==Example==  
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">
addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
function onPlayerEnterVehicle ( vehicle, seat, jacked )
function onPlayerEnterVehicle ( vehicle, seat, jacked )
Line 28: Line 29:
   end
   end
end
end
</syntaxhighlight>


==See Also==
==See Also==
{{Vehicle_Functions}}
{{Vehicle_Functions}}

Revision as of 04:44, 17 September 2006

This function returns the name of an upgrade slot name (eg: roof, spoiler).

Syntax

There are two ways of using this function, the parameter can either be the slot id (0->16) or the upgrade id (1000->1193)

string getVehicleUpgradeSlotName ( slot )             
string getVehicleUpgradeSlotName ( upgrade )             

Required Arguments

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

Returns

Returns the slot name if a valid slot or upgrade id was given, false otherwise.

Example

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

addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
function onPlayerEnterVehicle ( vehicle, seat, jacked )
  upgrades = getVehicleUpgrades ( vehicle )
  for upgradeKey, upgradeValue in upgrades do
    outputChatBox ( getVehicleUpgradeSlotName ( upgradeKey - 1 ) .. ": " .. upgradeValue )
  end
end

See Also

Template:Vehicle Functions