AirshipNetworkBehaviour
import { AirshipNetworkBehaviour, TargetRpc } from "@Easy/Core/Shared/Network";
export default class ServerWelcomeComponent extends AirshipNetworkBehaviour {
// This is a client-only "Start" event
public OnClientStart() {
print("Hello, Client!");
}
// This is a server-only "Start" event
public OnServerStart() {
print("Hello, Server!");
Airship.Players.ObservePlayers((player) => {
// Personalized server introduction :-)
this.SendServerIntroduction(player, `Hello, World! - to you - ${player.username}!`);
});
}
// TargetRpc will only send to the specified player
// this method will also only invoke on the client it's sent to
@TargetRpc()
public SendServerIntroduction(player: Player, message: string) {
Game.BroadcastMessage(`[SERVER] ${message}`);
}
}Last updated