@@ -187,9 +187,19 @@ export class OxPlayer extends ClassInterface {
187187
188188 const currentActiveGroup = this . get ( 'activeGroup' ) ;
189189
190- if ( currentActiveGroup ) GlobalState [ `${ currentActiveGroup } :activeCount` ] -= 1 ;
190+ if ( currentActiveGroup ) {
191+ GlobalState [ `${ currentActiveGroup } :activeCount` ] -= 1 ;
191192
192- if ( groupName ) GlobalState [ `${ groupName } :activeCount` ] += 1 ;
193+ const group = GetGroup ( currentActiveGroup ) ;
194+ group . activePlayers . delete ( + this . source ) ;
195+ }
196+
197+ if ( groupName ) {
198+ GlobalState [ `${ groupName } :activeCount` ] += 1 ;
199+
200+ const group = GetGroup ( groupName ) ;
201+ group . activePlayers . add ( + this . source ) ;
202+ }
193203
194204 SetActiveGroup ( this . charId , temp ? undefined : groupName ) ;
195205 this . set ( 'activeGroup' , groupName , true ) ;
@@ -437,7 +447,10 @@ export class OxPlayer extends ClassInterface {
437447 delete this . #groups[ group . name ] ;
438448 GlobalState [ `${ group . name } :count` ] -= 1 ;
439449
440- if ( canRemoveActiveCount && group . name === this . get ( 'activeGroup' ) ) GlobalState [ `${ group . name } :activeCount` ] -= 1 ;
450+ if ( canRemoveActiveCount && group . name === this . get ( 'activeGroup' ) ) {
451+ GlobalState [ `${ group . name } :activeCount` ] -= 1 ;
452+ group . activePlayers . delete ( + this . source ) ;
453+ }
441454 }
442455
443456 /** Saves the active character to the database. */
@@ -582,8 +595,14 @@ export class OxPlayer extends ClassInterface {
582595 this . set ( 'phoneNumber' , phoneNumber , true ) ;
583596 this . set ( 'activeGroup' , groups . find ( ( group ) => group . isActive ) ?. name , true ) ;
584597
585- if ( this . get ( 'activeGroup' ) ) GlobalState [ `${ this . get ( 'activeGroup' ) } :activeCount` ] += 1 ;
586- DEV: console . info ( `Restored OxPlayer<${ this . userId } > previous active group: ${ this . get ( 'activeGroup' ) } ` ) ;
598+ const activeGroup = this . get ( 'activeGroup' ) ;
599+ if ( activeGroup ) {
600+ GlobalState [ `${ this . get ( 'activeGroup' ) } :${ activeGroup } ` ] += 1 ;
601+
602+ const group = GetGroup ( activeGroup )
603+ group . activePlayers . add ( + this . source ) ;
604+ }
605+ DEV: console . info ( `Restored OxPlayer<${ this . userId } > previous active group: ${ activeGroup } ` ) ;
587606
588607 OxPlayer . keys . charId [ character . charId ] = this ;
589608
0 commit comments