SetVehicleHandling: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Here you go Qais)
Line 1: Line 1:
{{Server function}}  
{{Server function}}  
__NOTOC__  
__NOTOC__  
This function can set a vehicle's handling.<br>
This function is used to change the handling data of a vehicle.


''*'''Note:''' This function is still not implemented in the nightly, and is currently only implemented in the handling branch!''
''*'''Note:''' This function has not merged into the 1.1 nightly builds yet! It will only work if you have a custom build of the handling branch.''


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setVehicleHandling(element theVehicle, string prop int/float/bool/table value)  
bool setVehicleHandling ( element theVehicle, string property, int/float/bool/table value )  
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''theVehicle:''' The vehicle you wish to set the handling of. - This must be an element.
*'''theVehicle:''' The vehicle you wish to set the handling of.
*'''prop:''' The property you wish to set the handling of the vehicle to. - This must be a string
*'''property:''' The property you wish to set the handling of the vehicle to.
*'''value:''' The value of the property you wish to set the handling of the vehicle to. This must be an integer, float, boolean or a table.
*'''value:''' The value of the property you wish to set the handling of the vehicle to.


===Returns===
===Returns===
Returns ''true'' if the handling was set successfully, ''false'' otherwise.
Returns ''true'' if the handling was set successfully, ''false'' otherwise. See below a list of valid propertys and their required values:
{{Handling Properties}}


==Example==  
==Example==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function massChange(me, command, mass)
function massChange ( me, command, mass )
   veh = getPedOccupiedVehicle(me) -- get the ped's occupied vehicle
   veh = getPedOccupiedVehicle ( me ) -- get the ped's occupied vehicle
   if speed and veh then  -- if the mass is given and has a veh
   if speed and veh then  -- if the mass is given and has a veh
       setVehicleHandling(veh, "mass", tonumber(mass)) -- set handling
       setVehicleHandling ( veh, "mass", tonumber ( mass ) ) -- set handling
   end
   end
end
end


addCommandHandler("changemass", massChange)
addCommandHandler ( "changemass", massChange )
</syntaxhighlight>
</syntaxhighlight>


==See other vehicle functions==
==See other vehicle functions==
{{Vehicle functions}}
{{Vehicle functions}}

Revision as of 10:28, 7 May 2011

This function is used to change the handling data of a vehicle.

*Note: This function has not merged into the 1.1 nightly builds yet! It will only work if you have a custom build of the handling branch.

Syntax

bool setVehicleHandling ( element theVehicle, string property, int/float/bool/table value ) 

Required Arguments

  • theVehicle: The vehicle you wish to set the handling of.
  • property: The property you wish to set the handling of the vehicle to.
  • value: The value of the property you wish to set the handling of the vehicle to.

Returns

Returns true if the handling was set successfully, false otherwise. See below a list of valid propertys and their required values:

http://web.archive.org/web/20140223160252/http://projectcerbera.com/gta/sa/tutorials/handling

Property Value Minimum value Maximum value Notes
mass Float 1.0 100000.0
turnMass Float 0.0 1000000.0
dragCoeff Float -200.0 200.0
centerOfMass Table = { [1]=posX, [2]=posY, [3]=posZ } (floats) -10.0 10.0 Get returns a table, set needs a table.
percentSubmerged Integer 1 99999
tractionMultiplier Float -100000.0 100000.0
tractionLoss Float 0.0 100.0
tractionBias Float 0.0 1.0
numberOfGears Integer 1 5
maxVelocity Float 0.1 200000.0
engineAcceleration Float 0.0 100000.0
engineInertia Float -1000.0 1000.0 Inertia of 0 can cause a LSOD. (Unable to divide by zero)
driveType String N/A N/A Use 'rwd', 'fwd' or 'awd'.
engineType String N/A N/A Use 'petrol', 'diesel' or 'electric'.
brakeDeceleration Float 0.1 100000.0
brakeBias Float 0.0 1.0
ABS Boolean true false Has no effect.
steeringLock Float 0.0 360.0
suspensionForceLevel Float 0.0 100.0
suspensionDamping Float 0.0 100.0
suspensionHighSpeedDamping Float 0.0 600.0
suspensionUpperLimit Float -50.0 50.0 Can't be equal to suspensionLowerLimit.
suspensionLowerLimit Float -50.0 50.0 Can't be equal to suspensionUpperLimit.
suspensionFrontRearBias Float 0.0 1.0 Hardcoded maximum is 3.0, but values above 1.0 have no effect.
suspensionAntiDiveMultiplier Float 0.0 30.0
seatOffsetDistance Float -20.0 20.0
collisionDamageMultiplier Float 0.0 10.0
monetary Integer 0 230195200 Get works, set is disabled.
modelFlags Hexadecimal/Decimal N/A N/A Property uses a decimal value, generated by a hexadecimal value. Either use 0x12345678 or tonumber ( "0x12345678" ). See projectcerbera for possible values.
handlingFlags Hexadecimal/Decimal N/A N/A Property uses a decimal value, generated by a hexadecimal value. Either use 0x12345678 or tonumber ( "0x12345678" ). See projectcerbera for possible values.
headLight String N/A N/A Get works, set is disabled. Available values: 'long', 'small', 'big', 'tall'.
tailLight String N/A N/A Get works, set is disabled. Available values: 'long', 'small', 'big', 'tall'.
animGroup Integer ?? ?? Get works, set is disabled due to people not knowing this property was vehicle-based and caused crashes.

Example

function massChange ( me, command, mass )
   veh = getPedOccupiedVehicle ( me ) -- get the ped's occupied vehicle
   if speed and veh then  -- if the mass is given and has a veh
       setVehicleHandling ( veh, "mass", tonumber ( mass ) ) -- set handling
   end
end

addCommandHandler ( "changemass", massChange )

See other vehicle functions