EntityStreamIn: Difference between revisions

From RAGE Multiplayer Wiki
(added example)
 
m (category)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Example==
This event is triggered when a car or player enters the stream zone
That's example will just call server side event, from client, if player screen size not a 1280x1024.
{{ClientsideCsJsEvent}}
{{CSharpContainer|
<syntaxhighlight lang="c#">
public delegate void OnEntityStreamInDelegate(Entity entity);
</syntaxhighlight>
{{Parameters}}
* '''entity''' - the streamed in entity, expects '''RAGE.Elements.Entity'''


<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
{{Example}}
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
The example below sends a message to client when an entity comes within stream range, showing the entity model, position and remoteId.
<syntaxhighlight lang="javascript" highlight="5">
<syntaxhighlight lang="c#">
Events.OnEntityStreamIn += OnEntityStreamIn;
</syntaxhighlight>
<syntaxhighlight lang="c#">
public void OnEntityStreamIn(RAGE.Elements.Entity entity)
{
    RAGE.Chat.Output($"{entity.Model} streamed in at {entity.Position} with serverside id:{entity.RemoteId}");
}
</syntaxhighlight>
}}


{{JSContainer|
{{Example}}
<pre>
// Other player streams in
// Other player streams in
mp.events.add('entityStreamIn', (entity) => {
mp.events.add('entityStreamIn', (entity) => {
    const isInvincible = entity.getVariable('isInvincible');
    entity.setInvincible(!!isInvincible);
});
</pre>
}}


    // Init
    let player = mp.players.local;
    if (entity.type == "player") {
        // Init
        let other_player = entity;


        // Actions
[[Category:Entity API]]
 
[[Category:Client-side Event]]
    }
});
 
</syntaxhighlight>
</div>

Latest revision as of 11:06, 30 April 2019

This event is triggered when a car or player enters the stream zone

Client-Side Event

 C#  JavaScript


C# Syntax

public delegate void OnEntityStreamInDelegate(Entity entity);

Parameters

  • entity - the streamed in entity, expects RAGE.Elements.Entity

Example

The example below sends a message to client when an entity comes within stream range, showing the entity model, position and remoteId.

Events.OnEntityStreamIn += OnEntityStreamIn;
public void OnEntityStreamIn(RAGE.Elements.Entity entity)
{
    RAGE.Chat.Output($"{entity.Model} streamed in at {entity.Position} with serverside id:{entity.RemoteId}");
}


JavaScript Syntax

Example

// Other player streams in
mp.events.add('entityStreamIn', (entity) => {
    const isInvincible = entity.getVariable('isInvincible');
    entity.setInvincible(!!isInvincible);
});