public void Claim() { if (Context.Player == null) { Log.Error("Why are you running this in the console?"); return; } var user = ReferralCore.GetUser(Context.Player.SteamUserId); user.ReferredDescriptions.ForEach( rd => { if (rd.Claimed) { return; } var c = ReferralCore.Dostuff(user, Context.Player, false, true); if (c) { rd.Claimed = true; ReferralCore.SaveUser(user); Context.Respond($"Claimed for {rd.ReferredUserName}"); } else { //lmao Context.Respond( $"Failed to Claim for {rd.ReferredUserName}, This should never happen, see a admin and report code 42"); } } ); Context.Respond("done."); }
public ReferralControls(ReferralCore plugin) : this() { Plugin = plugin; DataContext = plugin.Config; var userData = ReferralCore.UserDataFromStorage().Users; //MyTreeView.DataContext = userInfo; Box.ItemsSource = userData; }
public void Knew2(string code) { if (Context.Player == null) { Log.Error("Why are you running this in the console?"); return; } if (code != ReferralCore.Instance.Config.ServerReferralCode) { Context.Respond("code not found, are you sure you have the right one?"); return; } var user = ReferralCore.GetUser(Context.Player.SteamUserId); if (user.ReferralByUser != null) { if ((bool)user.ReferralByUser) { Context.Respond("Referral already claimed"); return; } } if (user.ReferralByCode != null) { if ((bool)user.ReferralByCode) { Context.Respond("Referral already claimed"); return; } } user.ReferralByCode = true; var check = ReferralCore.Dostuff(user, Context.Player, false, false); if (!check) { Log.Error("Failed to do stuff"); Context.Respond("Failed to do stuff"); Context.Respond($"This should never happen, see a admin and report code 42"); return; } ReferralCore.SaveUser(user); Context.Respond("Claimed"); }
public void promo(string code) { if (Context.Player == null) { Log.Error("Why are you running this in the console?"); return; } if (code != ReferralCore.Instance.Config.PromotionRewardsCode) { Context.Respond("Incorrect Promotion Code."); return; } var user = ReferralCore.GetUser(Context.Player.SteamUserId); if (user.PromoCodes.Any(userPromoCode => code == userPromoCode)) { Context.Respond("Promotion Code already used"); return; } var check = ReferralCore.Dostuff(user, Context.Player, true, false); if (!check) { Log.Error("Failed to do stuff"); Context.Respond("Failed to do stuff"); Context.Respond($"This should never happen, see a admin and report code 42"); return; } user.PromoCodes.Add(code); user.PromoCodes = user.PromoCodes; ReferralCore.SaveUser(user); Context.Respond("done."); }
public override void Init(ITorchBase torch) { base.Init(torch); Instance = this; SessionManager = Torch.Managers.GetManager <TorchSessionManager>(); SessionManager.SessionStateChanged += SessionManagerOnSessionStateChanged; SetupConfig(); string pathString = System.IO.Path.Combine(StoragePath, "ReferralData"); System.IO.Directory.CreateDirectory(pathString); UserDataPath = Path.Combine(StoragePath + @"\ReferralData", "Users.xml"); if (!File.Exists(UserDataPath)) { var serializer = new XmlSerializer(typeof(UserData)); var userData = new UserData { Users = new ObservableCollection <User>() }; using (var fileWriter = new FileStream(UserDataPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { serializer.Serialize(fileWriter, userData); } } }
public void Knew(string player) { if (Context.Player == null) { Log.Error("Why are you running this in the console?"); return; } var identity = ReferralCore.GetIdentityByNameOrIds(player); if (identity == null) { Context.Respond("player not found, are you sure you have the right steam id or name?"); return; } if (identity == Context.Player.Identity) { Context.Respond("Dont try to claim yourself"); Log.Warn($"player tried to CHEAT Referral {Context.Player.DisplayName} CODE 42"); return; } var user1 = ReferralCore.GetUser(Context.Player.SteamUserId); if (user1.ReferralByUser != null) { if ((bool)user1.ReferralByUser) { Context.Respond("Referral already claimed"); return; } } if (user1.ReferralByCode != null) { if ((bool)user1.ReferralByCode) { Context.Respond("Referral already claimed"); return; } } user1.ReferralByUser = true; var user2 = ReferralCore.GetUser(MySession.Static.Players.TryGetSteamId(identity.IdentityId)); var check = ReferralCore.Dostuff(user1, Context.Player, false, false); if (!check) { Log.Error("Failed to do stuff"); Context.Respond("Failed to do stuff"); Context.Respond($"This should never happen, see a admin and report code 42"); return; } var referredDescription = new ReferredDescription { ReferredUserName = user1.Name, ReferredUserId = user1.SteamId, Claimed = false }; user1.ReferralByUser = true; user1.ReferredBy = user2.SteamId; user2.ReferredDescriptions.Add(referredDescription); ReferralCore.SaveUser(user1); ReferralCore.SaveUser(user2); Context.Respond("Claimed"); }