source: binary-improvements/7dtd-server-fixes/src/AllocsLogFunctions.cs@ 158

Last change on this file since 158 was 156, checked in by alloc, 10 years ago

fixes

File size: 1.5 KB
RevLine 
[144]1using AllocsFixes.PersistentData;
[83]2using System;
3using System.Collections.Generic;
4using UnityEngine;
5
[130]6namespace AllocsFixes
[83]7{
[130]8 public class AllocsLogFunctions
[83]9 {
[130]10 public static void RequestToSpawnPlayer (GameManager manager, int _clientId, string _name, string _playerClassname, string _skinTexture, int _chunkViewDim)
11 {
12 try {
13 ClientInfo ci = CommonMappingFunctions.GetClientInfoFromClientID (_clientId);
14 int entityId = CommonMappingFunctions.GetEntityID (ci);
15 EntityPlayer ep = CommonMappingFunctions.GetEntityPlayer (ci);
[144]16 string steamId = CommonMappingFunctions.GetSteamID (ci);
[103]17
[130]18 string ip = ci.networkPlayer.ipAddress;
19 string name = string.Empty;
[103]20
[130]21 if (ep != null)
22 name = ep.EntityName;
[103]23
[130]24 Log.Out ("Player connected, clientid=" + _clientId +
25 ", entityid=" + entityId +
26 ", name=" + name +
[144]27 ", steamid=" + steamId +
[130]28 ", ip=" + ip
29 );
[144]30
31 PersistentContainer.Instance.Players[steamId].SetOnline(ci);
[146]32 PersistentData.PersistentContainer.Instance.Save ();
[130]33 } catch (Exception e) {
[144]34 Log.Out ("Error in AllocsLogFunctions.RequestToSpawnPlayer: " + e);
[130]35 }
[83]36 }
[144]37
38 public static void PlayerDisconnected (GameManager manager, int _clientId) {
39 try {
[156]40 Player p = PersistentContainer.Instance.Players.GetPlayerByClientId(_clientId);
41 if (p != null) {
42 p.SetOffline();
43 }
[146]44 PersistentData.PersistentContainer.Instance.Save ();
[144]45 } catch (Exception e) {
46 Log.Out ("Error in AllocsLogFunctions.PlayerDisconnected: " + e);
47 }
48 }
[83]49 }
50}
Note: See TracBrowser for help on using the repository browser.