Object::notifyStreaming: Difference between revisions

From RAGE Multiplayer Wiki
m (Added property default)
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This property, if true, will call https://wiki.rage.mp/index.php?title=EntityStreamIn for the Object.
This property, if true, will call [[EntityStreamIn|EntityStreamIn]] for the Object.  


'''Default:''' false
'''Default:''' false


==Setter==
==Setter==
* {{RageType|Boolean}}
*'''enable:''' {{RageType|Boolean}}


== Syntax ==
<pre>
object.notifyStreaming = enable;
</pre>
== Example ==
== Example ==
{{ServersideCode|
<syntaxhighlight lang="javascript">
mp.events.addCommand('obj', (player) => {
    mp.objects.new(mp.joaat("bkr_prop_coke_block_01a"), player.position);
    //or you can directly call the event for all players players here eg:
    /*
        const obj = mp.objects.new(mp.joaat("bkr_prop_coke_block_01a"), player.position);
        mp.players.call('client::object:enableStreaming', [obj.id, true])
    */
})
//enable stream in for all players when the object is created
mp.events.add('entityCreated', (entity) => {
    if (entity.type === "object") {
        mp.players.call('client::object:enableStreaming', [entity.id, true])
    }
})
</syntaxhighlight >
}}


{{ClientsideCode|
{{ClientsideCode|
<pre>
<syntaxhighlight lang="javascript">
const object = mp.objects.new('prop_cs_box_clothes', new mp.Vector3(500, 500, 500)); // Untested inside Options
mp.events.add('client::object:enableStreaming', (remoteId, enable) => {
object.notifyStreaming = true;
    const object = mp.objects.atRemoteId(remoteId);
</pre>
    if (!object) return;
    object.notifyStreaming = enable;
    mp.console.logInfo(`Changed stream-in value of object remote id ${object.remoteId} to ${enable}`);
})
</syntaxhighlight >
}}
}}


Line 19: Line 49:


[[Category:Object API]]
[[Category:Object API]]
[[Category:Client-side Property]]
[[Category:Server-side Property]]

Latest revision as of 17:06, 24 April 2024

This property, if true, will call EntityStreamIn for the Object.

Default: false

Setter

  • enable: Boolean

Syntax

object.notifyStreaming = enable;

Example

Server-Side
mp.events.addCommand('obj', (player) => {
    mp.objects.new(mp.joaat("bkr_prop_coke_block_01a"), player.position);
    //or you can directly call the event for all players players here eg:
    /*
        const obj = mp.objects.new(mp.joaat("bkr_prop_coke_block_01a"), player.position);
        mp.players.call('client::object:enableStreaming', [obj.id, true])
    */
})

//enable stream in for all players when the object is created
mp.events.add('entityCreated', (entity) => {
    if (entity.type === "object") {
        mp.players.call('client::object:enableStreaming', [entity.id, true])
    }
})


Client-Side
mp.events.add('client::object:enableStreaming', (remoteId, enable) => {
    const object = mp.objects.atRemoteId(remoteId);
    if (!object) return;
    object.notifyStreaming = enable;
    mp.console.logInfo(`Changed stream-in value of object remote id ${object.remoteId} to ${enable}`);
})

See Also