Vehicle::setDoorShut: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
 
Line 1: Line 1:
__TOC__
{{ClientsideJsFunction}}
 
Shuts the door of the vehicle.
 
doorIndex:
* 0 = Front Left Door
* 1 = Front Right Door
* 2 = Back Left Door
* 3 = Back Right Door
* 4 = Hood
* 5 = Trunk
* 6 = Back
* 7 = Back2


==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">vehicle.setDoorShut(doorIndex, closeInstantly);</syntaxhighlight>
<pre>vehicle.setDoorShut(doorIndex, closeInstantly);</pre>


=== Required Arguments ===
=== Required Arguments ===
*'''doorIndex:''' <font color='red'>'''int'''</font>
*'''doorIndex:''' {{RageType|Int}}
*'''closeInstantly:''' <font color='green'>'''Boolean'''</font>
*'''closeInstantly:''' {{RageType|Boolean}}
 
=== '''Doors'''===
*0 = Front Left Door
*1 = Front Right Door
*2 = Back Left Door
*3 = Back Right Door
*4 = Hood
*5 = Trunk
*6 = Trunk2


===Return value===
===Return value===
Line 21: Line 24:


==Example==
==Example==
 
When in a vehicle, pressing the N key will open/close the hood
<syntaxhighlight lang="javascript" highlight='3'>
{{ClientsideCode|
let vehicle = mp.players.local.vehicle;
<pre>
 
mp.keys.bind(0x4E, true, function() {  // N Key
if (vehicle.isDoorFullyOpen(1)) { // If the Front left door is fully open
    if(mp.players.local.vehicle){
vehicle.setDoorShut(1, false); // Close it gently.
        if (mp.players.local.vehicle.hood){
}
            mp.players.local.vehicle.hood = false;
</syntaxhighlight>
            mp.players.local.vehicle.setDoorShut(4, true);
        } else {
            mp.players.local.vehicle.hood = true;
            mp.players.local.vehicle.setDoorOpen(4, false, true);
        }
    }
});
</pre>
}}


==See also==
==See also==
{{Vehicle_function_c}}
{{Vehicle_definition_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]

Latest revision as of 00:24, 29 January 2019

Client-Side
Function

 JavaScript



Shuts the door of the vehicle.

doorIndex:

  • 0 = Front Left Door
  • 1 = Front Right Door
  • 2 = Back Left Door
  • 3 = Back Right Door
  • 4 = Hood
  • 5 = Trunk
  • 6 = Back
  • 7 = Back2

Syntax

vehicle.setDoorShut(doorIndex, closeInstantly);

Required Arguments

  • doorIndex: Int
  • closeInstantly: Boolean

Return value

  • Undefined

Example

When in a vehicle, pressing the N key will open/close the hood

Client-Side
mp.keys.bind(0x4E, true, function() {   // N Key
    if(mp.players.local.vehicle){
        if (mp.players.local.vehicle.hood){
            mp.players.local.vehicle.hood = false;
            mp.players.local.vehicle.setDoorShut(4, true);
        } else {
            mp.players.local.vehicle.hood = true;
            mp.players.local.vehicle.setDoorOpen(4, false, true);
        }
    }
});

See also