public SessionHandler( ILogger <SessionHandler> logger, IOptions <GameOptions> gameOptions, IOptions <DevelopmentOptions> devOptions, AccountService accountService, CharacterService characterService) { _accountService = accountService; _characterService = characterService; _logger = logger; _devOptions = devOptions.Value; AltAsync.OnPlayerConnect += (player, reason) => OnPlayerConnect(player as ServerPlayer, reason); AltAsync.OnPlayerDisconnect += (player, reason) => OnPlayerDisconnect(player as ServerPlayer, reason); Alt.OnPlayerDead += (player, killer, weapon) => OnPlayerDead(player as ServerPlayer, killer, weapon); AltAsync.OnClient <ServerPlayer, string>("Login:Authenticate", OnLoginAuthenticateAsync); AltAsync.OnClient <ServerPlayer, int>("Session:RequestCharacterSpawn", OnRequestCharacterSpawnAsync); AltAsync.OnClient <ServerPlayer, string>("Session:CreateNewCharacter", OnCreateNewCharacterAsync); Alt.OnClient <ServerPlayer, Vector3>("RequestTeleport", OnRequestTeleport); SpawnPoint = new Vector3( gameOptions.Value.SpawnPointX, gameOptions.Value.SpawnPointY, gameOptions.Value.SpawnPointZ); }
public VoiceManager() { var configFile = Path.Combine(Alt.Server.RootDirectory, "resources", Alt.Server.Resource.Name, "config.json"); if (File.Exists(configFile)) { try { Configuration = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText(configFile)); Alt.Log("[SaltyChat] Loaded configuration from config.json"); Alt.Log($"[SaltyChat] Server Identifier: {Configuration.ServerIdentifier}"); } catch (Exception ex) { Alt.Log("[SaltyChat] Failed loading configuration from config.json: " + ex); Environment.FailFast("Failed loading configuration from config.json", ex); } } Instance = this; AltAsync.OnClient <IPlayer, string>("SaltyChat:CheckVersion", OnClientCheckVersion); AltAsync.OnClient <IPlayer, bool>("SaltyChat:IsUsingMegaphone", OnClientIsUsingMegaphone); AltAsync.OnClient <IPlayer, string, bool>("SaltyChat:PlayerIsSending", OnClientPlayerIsSending); AltAsync.OnClient <IPlayer, float>("SaltyChat:SetRange", OnClientSetRange); AltAsync.OnClient <IPlayer, bool>("SaltyChat:ToggleRadioSpeaker", OnClientToggleRadioSpeaker); AltAsync.OnPlayerDisconnect += OnServerPlayerDisconnect; AltAsync.OnServer <IPlayer, bool>("SaltyChat:SetPlayerAlive", OnServerSetPlayerAlive); AltAsync.OnServer <IPlayer>("SaltyChat:EnablePlayer", OnServerEnablePlayer); AltAsync.OnServer <string>("SaltyChat:UpdateRadioTowers", OnServerUpdateRadioTowers); AltAsync.OnServer <IPlayer, string, bool>("SaltyChat:JoinRadioChannel", OnServerJoinRadioChannel); AltAsync.OnServer <IPlayer, string>("SaltyChat:LeaveRadioChannel", OnServerLeaveRadioChannel); AltAsync.OnServer <IPlayer>("SaltyChat:LeaveAllRadioChannel", OnServerLeaveAllRadioChannel); AltAsync.OnServer <IPlayer, IPlayer>("SaltyChat:StartCall", OnServerStartCall); AltAsync.OnServer <IPlayer, IPlayer>("SaltyChat:EndCall", OnServerEndCall); }