Object::Object: Difference between revisions
(alpha updated) |
|||
| (10 intermediate revisions by 7 users not shown) | |||
| Line 4: | Line 4: | ||
*'''[https://cdn.rage.mp/public/odb/index.html Objects gallery]''' | *'''[https://cdn.rage.mp/public/odb/index.html Objects gallery]''' | ||
{{JSContainer| | |||
==Syntax== | ==Syntax== | ||
{{SharedCode| | |||
< | <pre> | ||
mp.objects.new(model, position, | mp.objects.new(model, position, | ||
{ | { | ||
| Line 20: | Line 16: | ||
dimension: dimension | dimension: dimension | ||
}); | }); | ||
</ | </pre> | ||
}} | |||
=Example= | ==Required Arguments== | ||
*'''model''': {{RageType|Hash}} | |||
*'''position''': {{RageType|Vector3}} | |||
*'''rotation''': {{RageType|Vector3}} | |||
*'''alpha''': {{RageType|Number}}: The object's transparency. | |||
*'''dimension''': {{RageType|Number}} | |||
==Example== | |||
<pre> | |||
mp.events.addCommand('flag', (player) => { | |||
mp.objects.new('apa_prop_flag_portugal', player.position, | |||
{ | |||
rotation: player.rotation, | |||
alpha: 255, | |||
dimension: player.dimension | |||
}); | |||
}); | |||
//Following this code, you'll create a portuguese flag (apa_prop_flag_portugal) at the players position, facing the same way the player is facing, with no transparency (255 on alpha) and at the same dimension the player is. | |||
// | </pre> | ||
</ | }} | ||
[[Category:Object API]] | |||
[[Category:Shared Function]] | |||
[[Category:TODO: Example]] | |||
Latest revision as of 12:52, 1 February 2023
Creates a new Object.
JavaScript Syntax
Syntax
Shared
mp.objects.new(model, position,
{
rotation: rotation,
alpha: alpha,
dimension: dimension
});
Required Arguments
- model: Hash
- position: Vector3
- rotation: Vector3
- alpha: Number: The object's transparency.
- dimension: Number
Example
mp.events.addCommand('flag', (player) => {
mp.objects.new('apa_prop_flag_portugal', player.position,
{
rotation: player.rotation,
alpha: 255,
dimension: player.dimension
});
});
//Following this code, you'll create a portuguese flag (apa_prop_flag_portugal) at the players position, facing the same way the player is facing, with no transparency (255 on alpha) and at the same dimension the player is.