Commands /region list and /warp list now work

Regions now use User ID's for /region allow (can be IP or Username/password based ID)
Minor Tweaks
A reset of your database is recommended
This commit is contained in:
Twitchy 2011-07-09 20:41:31 +12:00
parent cb7033d89c
commit 243b0297b9
6 changed files with 156 additions and 28 deletions

View file

@ -137,8 +137,45 @@ namespace TShockAPI.DB
}
catch (SqliteExecutionException ex)
{
}
return Tools.GetGroup("default");
}
public string GetUserID(string username = "", string IP = "")
{
try
{
using (var com = database.CreateCommand())
{
if (username != "" && username != null)
{
com.CommandText = "SELECT * FROM Users WHERE Username=@name";
com.AddParameter("@name", username);
}
else if (IP != "" && IP != null)
{
com.CommandText = "SELECT * FROM Users WHERE IP=@ip";
com.AddParameter("@ip", IP);
}
else
return "0";
using (var reader = com.ExecuteReader())
{
if (reader.Read())
{
string ID = reader.Get<string>("ID");
return ID;
}
}
}
}
catch (SqliteExecutionException ex)
{
}
return "0";
}
}
}