mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-10-26 14:00:22 +00:00
to broadcast
This commit is contained in:
1 parent
7eaa382f6c
commit
478bf48a5a
2 files changed
+6
-12
No files matched your search
+4
-10
@@ -507,12 +507,9 @@ impl Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info!("Disconnecting client {}...", id);
|
info!("Disconnecting client {}...", id);
|
||||||
for client in &self.clients {
|
self.broadcast(Packet::Notification(NotificationPacket::player_left( // broadcast left message
|
||||||
if client.id == i as u8 {continue}
|
|
||||||
client.queue_packet(Packet::Notification(NotificationPacket::left(
|
|
||||||
self.clients[i].info.as_ref().unwrap().username.clone()
|
self.clients[i].info.as_ref().unwrap().username.clone()
|
||||||
))).await;
|
)), Some(i as u8)).await;
|
||||||
}
|
|
||||||
|
|
||||||
if i == self.clients.len() - 1 {
|
if i == self.clients.len() - 1 {
|
||||||
self.clients.remove(i);
|
self.clients.remove(i);
|
||||||
@@ -810,12 +807,9 @@ impl Server {
|
|||||||
))))
|
))))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
for client in &self.clients { // welcome the player
|
self.broadcast(Packet::Notification(NotificationPacket::player_welcome( // welcome the player
|
||||||
if client.id == client_idx as u8 {continue}
|
|
||||||
client.queue_packet(Packet::Notification(NotificationPacket::welcome(
|
|
||||||
self.clients[client_idx].info.as_ref().unwrap().username.clone()
|
self.clients[client_idx].info.as_ref().unwrap().username.clone()
|
||||||
))).await;
|
)), Some(client_idx as u8)).await;
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Sync all existing cars on server (this code is broken)
|
// TODO: Sync all existing cars on server (this code is broken)
|
||||||
for client in &self.clients {
|
for client in &self.clients {
|
||||||
|
|||||||
@@ -54,10 +54,10 @@ impl NotificationPacket {
|
|||||||
pub fn new<S: Into<String>>(msg: S) -> Self {
|
pub fn new<S: Into<String>>(msg: S) -> Self {
|
||||||
Self(format!("J{}", msg.into()))
|
Self(format!("J{}", msg.into()))
|
||||||
}
|
}
|
||||||
pub fn welcome<S: Into<String>>(msg: S) -> Self {
|
pub fn player_welcome<S: Into<String>>(msg: S) -> Self {
|
||||||
Self(format!("JWelcome {}!", msg.into()))
|
Self(format!("JWelcome {}!", msg.into()))
|
||||||
}
|
}
|
||||||
pub fn left<S: Into<String>>(msg: S) -> Self {
|
pub fn player_left<S: Into<String>>(msg: S) -> Self {
|
||||||
Self(format!("L{} left the server!", msg.into()))
|
Self(format!("L{} left the server!", msg.into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user