Skip to content

Commit

Permalink
Multi-Tag support
Browse files Browse the repository at this point in the history
updated config usage to support config reload command
  • Loading branch information
RedSpeeds committed May 21, 2018
1 parent bb5ef80 commit 5fd03a1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
################################################################################

/.vs/SCPSLDonortag/v15
/SCPSLDonortag/bin/Debug
/SCPSLDonortag/obj/Debug
15 changes: 7 additions & 8 deletions SCPSLDonortag/JoinHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ public void OnPlayerJoin(Player player)
{


List<String> steamIDs = plugin.getSteamIDs();
if (player == null || player.SteamId == null)
{
plugin.Error("ID or player is null");
}
if (steamIDs.Contains(player.SteamId))
{
String tag = plugin.getTag();
String color = plugin.getColor();
player.SetRole(color, tag);
}

String tag = plugin.getTag(player.SteamId);
String color = plugin.getColor(player.SteamId);
if (tag == null||color==null)
{
return;
}
player.SetRole(color, tag);
}
}
}
44 changes: 25 additions & 19 deletions SCPSLDonortag/SCPSLDonortag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,48 @@ namespace SCPSLDonortag
id = "com.thecreepercow.donortag",
version = "0.1",
SmodMajor =2,
SmodMinor =0,
SmodRevision =13)]
SmodMinor =1,
SmodRevision =0)]

class SCPSLDonortag : Plugin
{
private List<String> donorList;
private String color;
private String tag;
public override void OnDisable()
{
}

public override void OnEnable()
{
donorList = new List<string>(GetConfigList("Donors_SteamID"));
color = GetConfigString("Donor_Color");
tag = GetConfigString("Donor_Tag");
}
public String getColor()
{
return color;

}
public List<String> getSteamIDs()

public String getTag(String SteamID)
{
return donorList;
Dictionary<String, String> SteamIDS = ConfigManager.Manager.Config.GetDictValue("Donor_SteamIDs");
if (!SteamIDS.ContainsKey(SteamID))
{
return null;
}
String tagID = SteamIDS[SteamID];
Dictionary<String, String> tags = ConfigManager.Manager.Config.GetDictValue("Donor_Tags");
String tag = tags[tagID].Split('|')[0];
return tag;
}
public String getTag()
public String getColor(String SteamID)
{
return tag;
Dictionary<String, String> SteamIDS = ConfigManager.Manager.Config.GetDictValue("Donor_SteamIDs");
if (!SteamIDS.ContainsKey(SteamID))
{
return null;
}
String tagID = SteamIDS[SteamID];
Dictionary<String, String> tags = ConfigManager.Manager.Config.GetDictValue("Donor_Tags");
String color = tags[tagID].Split('|')[1].ToLower();
return color;
}
public override void Register()
{
String[] defaultvalid = new string[0];
this.AddEventHandler(typeof(IEventPlayerJoin), new JoinHandler(this), Priority.High);
this.AddConfig(new Smod2.Config.ConfigSetting("Donors_SteamID", "", Smod2.Config.SettingType.LIST,true,"SteamIDS of your donors"));
this.AddConfig(new Smod2.Config.ConfigSetting("Donor_Tag", "Donator", Smod2.Config.SettingType.STRING, true, "The Donor tag text"));
this.AddConfig(new Smod2.Config.ConfigSetting("Donor_Color", "green", Smod2.Config.SettingType.STRING, true, "The Donor tag color"));
}
}
}

0 comments on commit 5fd03a1

Please sign in to comment.