Permalink
Browse files

Added option to disable SQL

  • Loading branch information...
SDPlugins committed Jun 11, 2017
1 parent 1699524 commit 912d77e0e9ec982ed8c83e1335b466e200a2fe10
View
@@ -50,7 +50,8 @@ public void Execute (IRocketPlayer caller, string [] command)
else
Trails.trails.Add ((ulong)setPlayer.CSteamID, new List<ushort> () { trail.id });
Trails.Instance.database.addToSQL (setPlayer, Trails.trails [(ulong)setPlayer.CSteamID]);
if (Trails.Instance.Configuration.Instance.useSQL)
Trails.Instance.database.addToSQL (setPlayer, Trails.trails [(ulong)setPlayer.CSteamID]);
UnturnedChat.Say (setPlayer, Trails.Instance.Translate ("set_trail_by_admin", trail.name, player.DisplayName), Color.green);
UnturnedChat.Say (player, Trails.Instance.Translate ("set_trail_admin", setPlayer.DisplayName, trail.name), Color.green);
}
@@ -69,7 +70,8 @@ public void Execute (IRocketPlayer caller, string [] command)
else
Trails.trails.Add ((ulong)player.CSteamID, new List<ushort> () { trail.id });
Trails.Instance.database.addToSQL (player, Trails.trails [(ulong)player.CSteamID]);
if (Trails.Instance.Configuration.Instance.useSQL)
Trails.Instance.database.addToSQL (player, Trails.trails [(ulong)player.CSteamID]);
UnturnedChat.Say (player, Trails.Instance.Translate ("set_trail", trail.name), Color.green);
}
else
@@ -85,7 +87,8 @@ public void Execute (IRocketPlayer caller, string [] command)
if (Trails.trails.ContainsKey ((ulong)player.CSteamID))
Trails.trails.Remove ((ulong)player.CSteamID);
Trails.Instance.database.removeAll (player);
if (Trails.Instance.Configuration.Instance.useSQL)
Trails.Instance.database.removeAll (player);
UnturnedChat.Say (player, Trails.Instance.Translate ("removed_all_trails"), Color.green);
}
else
@@ -94,10 +97,13 @@ public void Execute (IRocketPlayer caller, string [] command)
if (Trails.trails [(ulong)player.CSteamID].Contains (trail.id))
Trails.trails.Remove (trail.id);
if (Trails.trails [(ulong)player.CSteamID].Count > 0)
Trails.Instance.database.addToSQL (player, Trails.trails [(ulong)player.CSteamID]);
else
Trails.Instance.database.removeAll (player);
if (Trails.Instance.Configuration.Instance.useSQL)
{
if (Trails.trails [(ulong)player.CSteamID].Count > 0)
Trails.Instance.database.addToSQL (player, Trails.trails [(ulong)player.CSteamID]);
else
Trails.Instance.database.removeAll (player);
}
UnturnedChat.Say (player, Trails.Instance.Translate ("removed_trail"), Color.green);
}
}
@@ -134,7 +140,8 @@ public void Execute (IRocketPlayer caller, string [] command)
if (Trails.trails.ContainsKey ((ulong)player.CSteamID))
Trails.trails.Remove ((ulong)player.CSteamID);
Trails.Instance.database.removeAll (player);
if (Trails.Instance.Configuration.Instance.useSQL)
Trails.Instance.database.removeAll (player);
UnturnedChat.Say (player, Trails.Instance.Translate ("removed_all_trails"), Color.green);
}
}
View
@@ -52,18 +52,21 @@ public override TranslationList DefaultTranslations
protected override void Load ()
{
Instance = this;
database = new Database ();
Configuration.Save ();
if (Configuration.Instance.useSQL)
database = new Database ();
trails = new Dictionary<ulong, List <ushort>> ();
UnturnedPlayerEvents.OnPlayerUpdatePosition += PlayerMoved;
U.Events.OnPlayerConnected += playerConnected;
U.Events.OnPlayerDisconnected += playedDisconnected;
Configuration.Save ();
}
private void playerConnected (UnturnedPlayer player)
{
if (!Configuration.Instance.useSQL)
return;
var loadedTrails = database.getTrails (player);
if (loadedTrails != null)
{
View
@@ -22,6 +22,9 @@ public class TrailsConfiguration : IRocketPluginConfiguration
[XmlElement ("DatabasePort")]
public int port;
[XmlElement ("useSQL")]
public bool useSQL = true;
[XmlArray ("Trails")]
[XmlArrayItem ("Trail")]
public List<customTrail> customTrails = new List<customTrail> ();
@@ -35,6 +38,8 @@ public void LoadDefaults ()
tablename = "trails";
port = 3306;
useSQL = true;
customTrails = new List<customTrail> ()
{
new customTrail ()
View
BIN +0 Bytes (100%) bin/Release/Trails.dll
Binary file not shown.
View
BIN +0 Bytes (100%) bin/Release/Trails.pdb
Binary file not shown.
View
BIN +0 Bytes (100%) obj/Release/Trails.dll
Binary file not shown.
View
BIN +0 Bytes (100%) obj/Release/Trails.pdb
Binary file not shown.

0 comments on commit 912d77e

Please sign in to comment.