Difference between revisions of "MDE Scripting: Snippets"
From Nomad DB
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | == Get the [[MDE Scripting: | + | ==Get the [[MDE Scripting: Player Entity|Player]] entity== |
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local Player = game.game:GetActivePlayer() | local Player = game.game:GetActivePlayer() | ||
Line 5: | Line 5: | ||
* [[MDE Scripting: GetActivePlayer|game.game:GetActivePlayer]] | * [[MDE Scripting: GetActivePlayer|game.game:GetActivePlayer]] | ||
+ | * [[MDE Scripting: Player Entity|Player Entity]] | ||
− | == Get the [[MDE Scripting: | + | ==Get the [[MDE Scripting: Player Entity|Player's]] current vehicle entity== |
Returns the vehicle entity the player is currently sitting in. | Returns the vehicle entity the player is currently sitting in. | ||
Line 39: | Line 40: | ||
* [[MDE Scripting: GetOwner|Player:GetOwner]] | * [[MDE Scripting: GetOwner|Player:GetOwner]] | ||
* [[MDE Scripting: GetOwnerSceneObject|Player:GetOwnerSceneObject]] | * [[MDE Scripting: GetOwnerSceneObject|Player:GetOwnerSceneObject]] | ||
+ | * [[MDE Scripting: Player Entity|Player Entity]] | ||
+ | * [[MDE Scripting: Car Entity|Car Entity]] | ||
+ | * [[MDE Scripting: Boat Entity|Boat Entity]] | ||
+ | * [[MDE Scripting: Motorcycle Entity|Motorcycle Entity]] | ||
− | ==Get the | + | ==Get the vehicle's current [[MDE Scripting: Motorcycle Entity|Motorcycle]] component== |
{| class="wikitable" | {| class="wikitable" | ||
!Tip | !Tip | ||
− | |You need to [[MDE Scripting: Snippets#Get the Player's current | + | |You need to [[MDE Scripting: Snippets#Get the Player's current vehicle entity|Get the Player's current vehicle entity]] first. |
|} | |} | ||
Line 51: | Line 56: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | *[[MDE Scripting: Snippets#Get the Player's current Vehicle entity|Get the Player's current Vehicle entity]] | + | * [[MDE Scripting: Snippets#Get the Player's current Vehicle entity|Get the Player's current Vehicle entity]] |
− | *[[MDE Scripting: GetComponent|Vehicle:GetComponent]] | + | * [[MDE Scripting: GetComponent|Vehicle:GetComponent]] |
− | *[[MDE Scripting: C_RuntimeMotorcycleComponent|C_RuntimeMotorcycleComponent]] | + | * [[MDE Scripting: C_RuntimeMotorcycleComponent|C_RuntimeMotorcycleComponent]] |
+ | * [[MDE Scripting: Player Entity|Player Entity]] | ||
+ | * [[MDE Scripting: Car Entity|Car Entity]] | ||
+ | * [[MDE Scripting: Boat Entity|Boat Entity]] | ||
+ | * [[MDE Scripting: Motorcycle Entity|Motorcycle Entity]] | ||
+ | |||
+ | |||
+ | {{Page_MDE}} | ||
+ | __FORCETOC__ | ||
Latest revision as of 23:14, 18 November 2020
Contents
Get the Player entity
local Player = game.game:GetActivePlayer()
Get the Player's current vehicle entity
Returns the vehicle entity the player is currently sitting in.
local function GetPlayerCurrentVehicle()
local Player = game.game:GetActivePlayer()
if not Player then
return nil
end
local Vehicle = Player:GetOwner()
if not Vehicle then
Vehicle = Player:GetOwnerSceneObject()
end
if not Vehicle then
return nil
end
return Vehicle
end
local Vehicle = GetPlayerCurrentVehicle() -- returns the vehicle scene object
- game.game:GetActivePlayer
- Player:GetOwner
- Player:GetOwnerSceneObject
- Player Entity
- Car Entity
- Boat Entity
- Motorcycle Entity
Get the vehicle's current Motorcycle component
Tip | You need to Get the Player's current vehicle entity first. |
---|
local Motorcycle = Vehicle:GetComponent("C_RuntimeMotorcycleComponent")