blob: d0820dd6a5ca8ea858b352c590a066cfb63294dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
global function MenuCallbacks_Init
void function MenuCallbacks_Init()
{
AddClientCommandCallback( "LeaveMatch", ClientCommandCallback_LeaveMatch )
}
bool function ClientCommandCallback_LeaveMatch( entity player, array<string> args )
{
thread WritePersistenceAndLeave( player )
return true
}
void function WritePersistenceAndLeave( entity player )
{
// write player persistence before we leave, since leaving player might load local lobby before server writes persistence, so they won't get newest
// not super essential, but a nice qol thing
NSEarlyWritePlayerPersistenceForLeave( player )
while ( NSIsWritingPlayerPersistence() )
WaitFrame()
// this is a custom concommand which can be called on clients, it causes them to leave and doesn't have issues if they're host
ClientCommand( player, "ns_leave_to_lobby" )
}
|