mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-15 21:21:49 +00:00
Merge branch 'master' of https://github.com/Lucky4Luuk/beammp_rust_server
This commit is contained in:
+10
-3
@@ -507,6 +507,10 @@ impl Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info!("Disconnecting client {}...", id);
|
info!("Disconnecting client {}...", id);
|
||||||
|
self.broadcast(Packet::Notification(NotificationPacket::player_left( // broadcast left message
|
||||||
|
self.clients[i].info.as_ref().unwrap().username.clone()
|
||||||
|
)), 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);
|
||||||
} else {
|
} else {
|
||||||
@@ -790,9 +794,8 @@ impl Server {
|
|||||||
} else {
|
} else {
|
||||||
let packet_identifier = packet.data[0] as char;
|
let packet_identifier = packet.data[0] as char;
|
||||||
match packet_identifier {
|
match packet_identifier {
|
||||||
'H' => {
|
'H' => { // Player Full sync with server
|
||||||
// Full sync with server
|
self.clients[client_idx] // tell the new player their playername
|
||||||
self.clients[client_idx]
|
|
||||||
.queue_packet(Packet::Raw(RawPacket::from_str(&format!(
|
.queue_packet(Packet::Raw(RawPacket::from_str(&format!(
|
||||||
"Sn{}",
|
"Sn{}",
|
||||||
self.clients[client_idx]
|
self.clients[client_idx]
|
||||||
@@ -804,6 +807,10 @@ impl Server {
|
|||||||
))))
|
))))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
self.broadcast(Packet::Notification(NotificationPacket::player_welcome( // welcome the player
|
||||||
|
self.clients[client_idx].info.as_ref().unwrap().username.clone()
|
||||||
|
)), 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 {
|
||||||
let pid = client.id as usize;
|
let pid = client.id as usize;
|
||||||
|
|||||||
@@ -54,6 +54,12 @@ 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 player_welcome<S: Into<String>>(msg: S) -> Self {
|
||||||
|
Self(format!("JWelcome {}!", msg.into()))
|
||||||
|
}
|
||||||
|
pub fn player_left<S: Into<String>>(msg: S) -> Self {
|
||||||
|
Self(format!("L{} left the server!", msg.into()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Protocol:
|
/// Protocol:
|
||||||
|
|||||||
Reference in New Issue
Block a user