Vehicle::setDoorOpen: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
m (Added example, updated page)
Line 1: Line 1:
doorIndex:<br>0 = Front Left Door<br>1 = Front Right Door<br>2 = Back Left Door<br>3 = Back Right Door<br>4 = Hood<br>5 = Trunk<br>6 = Back<br>7 = Back2
{{ClientsideJsFunction}}
Opens 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.setDoorOpen(doorIndex, loose, openInstantly);</syntaxhighlight>
<pre>vehicle.setDoorOpen(doorIndex, loose, openInstantly);</pre>
=== Required Arguments ===
 
*'''doorIndex:''' int
===Required Arguments===
*'''loose:''' Boolean
*'''doorIndex:''' {{RageType|Int}}
*'''openInstantly:''' Boolean
*'''loose:''' {{RageType|Boolean}}
*'''openInstantly:''' {{RageType|Boolean}}
 
===Return value===
===Return value===
*'''Undefined'''
*'''Undefined'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
When in a vehicle, pressing the N key will open/close the hood
// todo
{{ClientsideCode|
</syntaxhighlight>
<pre>
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);
        }
    }
});
</pre>
}}
 
==See also==
==See also==
{{Vehicle_function_c}}
{{Vehicle_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Revision as of 00:15, 29 January 2019

Client-Side
Function

 JavaScript



Opens 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.setDoorOpen(doorIndex, loose, openInstantly);

Required Arguments

  • doorIndex: Int
  • loose: Boolean
  • openInstantly: 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