public static void OnPlayerEatFoodAllergy(FoodItem food, User user) { if (REYmodSettings.Obj.Config.Foodallergiesenabled && user.IsAllergicTo(food)) { ChatUtils.SendMessage(user, "You are allergic to " + food.FriendlyName + "!"); //user.Stomach.UseCalories(food.Calories * 2); user.Stomach.Contents.Remove(user.Stomach.Contents.First(x => x.Food == food)); FoodItem rottenfood = new RottenFoodItem(); int amountofrotten = (int)(food.Calories / rottenfood.Calories); for (int i = 0; i < amountofrotten; i++) { StomachEntry rottenstomachEntry = new StomachEntry { Food = rottenfood, TimeEaten = WorldTime.Seconds }; user.Stomach.Contents.Add(rottenstomachEntry); } //if (WorldTime.Seconds > TimeUtil.DaysToSeconds(1)) // todo: find a better solution for the update (actually.... maybe that one works too on the first day, needs testing (and removal of that if statement) //{ StomachEntry dummystomachEntry = new StomachEntry { Food = rottenfood, TimeEaten = double.MinValue }; // This is a workaround to update the nutritionvalue... user.Stomach.Contents.Add(dummystomachEntry); // for some reason that Update method is private... user.Stomach.CheckForBowelMovementAndExcreteFeces(user.Player); // unfortunately it wont work on the first day //} } }
/// <summary> /// Unclaims all property of a given user /// </summary> /// <param name="target"></param> /// <param name="feedbackuser"></param> public static void UnclaimUser(User target, User feedbackuser) { // int emptystacks = 0; IEnumerable <Deed> allDeeds = PropertyManager.GetAllDeeds(); IEnumerable <Deed> targetDeeds = allDeeds.Where(x => x.OwnerUser == target); bool forceunclaim = false; string force = ""; foreach (Deed auth in targetDeeds) { Result res = PropertyManager.TryRemoveDeed(auth); if (!res.Success && feedbackuser != null) { ChatUtils.SendMessage(feedbackuser, res.Message); } if (!res.Success) { forceunclaim = true; } } if (forceunclaim) { PropertyManager.PropertyForUser(target).ForEach(x => PropertyManager.ForceUnclaim(x.Position)); force = ". Had to use Forceunclaim-Workaround!"; } if (feedbackuser != null) { feedbackuser.Player.OpenInfoPanel("Unclaim Player", "Unclaimed all property of " + target.Name + force); } }
public static void RemoveRubble(User user) { if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only { ChatUtils.SendMessage(user, "Not Authorized to use this command!"); return; } IEnumerable <RubbleObject <StoneItem> > stonerubble = NetObjectManager.GetObjectsOfType <RubbleObject <StoneItem> >(); IEnumerable <RubbleObject <IronOreItem> > ironrubble = NetObjectManager.GetObjectsOfType <RubbleObject <IronOreItem> >(); IEnumerable <RubbleObject <CopperOreItem> > copperrubble = NetObjectManager.GetObjectsOfType <RubbleObject <CopperOreItem> >(); IEnumerable <RubbleObject <GoldOreItem> > goldrubble = NetObjectManager.GetObjectsOfType <RubbleObject <GoldOreItem> >(); IEnumerable <RubbleObject <CoalItem> > coalrubble = NetObjectManager.GetObjectsOfType <RubbleObject <CoalItem> >(); /* Maybe this is a better solution, it would be nice to dynamically find all types of RubbleObject<>, right now i have to declare every single one separately here, i left out diamonds for example * IEnumerable<RubbleObject> rubbleObjects = NetObjectManager.GetObjectsOfType<RubbleObject>(); * rubbleObjects.Where(x => { return (x is RubbleObject<StoneItem>); }); */ //stonerubble.ForEach<RubbleObject>(x => NetObjectManager.Remove(x)); string buttontext = ""; IEnumerable <RubbleObject> rubbles; string panelcontent = "Rubble Overview: <br>"; rubbles = stonerubble; panelcontent += "<br>StoneRubble\t" + rubbles.Count().ToString().PadLeft(6) + "\t\t"; buttontext = (rubbles.Count() != 0) ? "<color=red>Remove</color>" : "<color=green>CLEAR</color>"; panelcontent += new Button(player => { DestroyRubbleType <RubbleObject <StoneItem> >(user, "Stone"); RemoveRubble(user); }, content: buttontext, singleuse: true).UILink(); rubbles = ironrubble; panelcontent += "<br>IronRubble \t" + rubbles.Count().ToString().PadLeft(6) + "\t\t"; buttontext = (rubbles.Count() != 0) ? "<color=red>Remove</color>" : "<color=green>CLEAR</color>"; panelcontent += new Button(player => { DestroyRubbleType <RubbleObject <IronOreItem> >(user, "Iron"); RemoveRubble(user); }, content: buttontext, singleuse: true).UILink(); rubbles = copperrubble; panelcontent += "<br>CopperRubble\t" + rubbles.Count().ToString().PadLeft(6) + "\t\t"; buttontext = (rubbles.Count() != 0) ? "<color=red>Remove</color>" : "<color=green>CLEAR</color>"; panelcontent += new Button(player => { DestroyRubbleType <RubbleObject <CopperOreItem> >(user, "Copper"); RemoveRubble(user); }, content: buttontext, singleuse: true).UILink(); rubbles = goldrubble; panelcontent += "<br>GoldRubble\t" + rubbles.Count().ToString().PadLeft(6) + "\t\t"; buttontext = (rubbles.Count() != 0) ? "<color=red>Remove</color>" : "<color=green>CLEAR</color>"; panelcontent += new Button(player => { DestroyRubbleType <RubbleObject <GoldOreItem> >(user, "Gold"); RemoveRubble(user); }, content: buttontext, singleuse: true).UILink(); rubbles = coalrubble; panelcontent += "<br>CoalRubble\t" + rubbles.Count().ToString().PadLeft(6) + "\t\t"; buttontext = (rubbles.Count() != 0) ? "<color=red>Remove</color>" : "<color=green>CLEAR</color>"; panelcontent += new Button(player => { DestroyRubbleType <RubbleObject <CoalItem> >(user, "Coal"); RemoveRubble(user); }, content: buttontext, singleuse: true).UILink(); user.Player.OpenInfoPanel("Rubble Remover", panelcontent); }
public static void claimvote(User user) { int emptystacks = 0; switch (VoteUtils.CheckVote(user)) { case -2: ChatUtils.SendMessage(user, "Received an unexpected response from Ecoservers. Please try again later."); return; case -1: ChatUtils.SendMessage(user, "There was an error when contacting Ecoservers.io. Please try again later."); return; case 0: ChatUtils.SendMessage(user, "You have not voted yet. Please vote on Ecoservers.io first."); return; case 1: // pass break; case 2: ChatUtils.SendMessage(user, "You already claimed your reward."); return; default: ChatUtils.SendMessage(user, "Something went wrong... Try again, if it's still the same error, pls report it. (Checkcase default)"); return; } foreach (ItemStack stack in user.Inventory.Stacks) { if (stack.Empty) { emptystacks++; //ChatUtils.SendMessage(user, "<color=green> Found empty Stack"); } //else ChatUtils.SendMessage(user, "Stack: " + stack.Item.NameAndNum(stack.Quantity)); } if (emptystacks <= 2) { ChatUtils.SendMessage(user, "Not enough space in inventory. Please make sure to have more free space."); return; } switch (VoteUtils.SetVote(user)) { case -2: ChatUtils.SendMessage(user, "Received an unexpected response from Ecoservers. Please try again later."); return; case -1: ChatUtils.SendMessage(user, "There was an error when contacting Ecoservers.io. Please try again later."); return; case 0: ChatUtils.SendMessage(user, "Something went wrong... Try again, if it's still the same error, pls report it. (Claimcase 0)"); return; case 1: break; default: ChatUtils.SendMessage(user, "Something went wrong... Try again, if it's still the same error, pls report it. (Claimcase default)"); return; } ChatUtils.SendMessage(user, "Thanks for Voting! Here is your reward :D"); // maybe that should be moved somewhere else for better configurability user.Inventory.AddItems(typeof(CoinItem), 10); }