forked from RedBigz/Citruslib-FixedUp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuestBook.cs
More file actions
62 lines (51 loc) · 1.89 KB
/
Copy pathGuestBook.cs
File metadata and controls
62 lines (51 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Collections.Generic;
using System.IO;
using Epic.OnlineServices;
using Landfall.Network;
using UnityEngine;
namespace WobbleBridge
{
//logs every unique player who connects to the server, useful for moderation.
static class GuestBook
{
static Dictionary<Utf8String, string> guestBook = new Dictionary<Utf8String, string>();
internal static void SignGuestBook(TABGPlayerServer player)
{
string data = string.Format("{0}, Playfab={1},Steam={2}",player.PlayerName,player.PlayFabID,player.SteamID);
if (guestBook.ContainsKey(player.EpicUserName))
{
guestBook[player.EpicUserName] = data;
}
else
{
guestBook.Add(player.EpicUserName, data);
}
List<string> lines = new List<string>();
foreach(KeyValuePair<Utf8String,string> kvp in guestBook)
{
lines.Add(kvp.Key+":"+kvp.Value);
}
DirectoryInfo directoryInfo = new DirectoryInfo(Application.dataPath);
string text = Path.Combine(directoryInfo.Parent.FullName, "Guestbook.txt");
File.WriteAllLines(text, lines.ToArray());
}
internal static void LoadGuestBook()
{
DirectoryInfo directoryInfo = new DirectoryInfo(Application.dataPath);
string text = Path.Combine(directoryInfo.Parent.FullName, "Guestbook.txt");
guestBook = new Dictionary<Utf8String, string>();
if (!File.Exists(text))
{
File.WriteAllText(text, "");
}
string[] lines = File.ReadAllLines(text);
foreach(string s in lines)
{
if (s.Contains(":"))
{
guestBook.Add(s.Split(':')[0], s.Split(':')[1]);
}
}
}
}
}