RecipeBag

CLASnipe

Member
Jul 15, 2019
11
2
Im trying to make a bag that drops a random recipe but everything ive tried I still get an error

im using Servuo


C#:
Errors:
 + Custom/RecipeBag.cs:
    CS0019: Line 15: Operator '>=' cannot be applied to operands of type 'Item' and 'int'
    CS0127: Line 174: Since 'RecipeSatchel.RecipeSatchel()' returns void, a return keyword must not be followed by an object expression
Scripts: One or more scripts failed to compile or no script files were found.
 - Press return to exit, or R to try again.
Post automatically merged:

Im trying to make a bag that drops a random recipe but everything ive tried I still get an error

im using Servuo


C#:
Errors:
+ Custom/RecipeBag.cs:
    CS0019: Line 15: Operator '>=' cannot be applied to operands of type 'Item' and 'int'
    CS0127: Line 174: Since 'RecipeSatchel.RecipeSatchel()' returns void, a return keyword must not be followed by an object expression
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
I figure it out
 

Attachments

Last edited:
  • Like
Reactions: Exale

Grimoric

Well-Known Member
Mar 21, 2015
189
48
44
Ehhh Headake. :D

First off, do you use an IDE and or just edit the scripts. If you don't have an IDE then try this:

The next thing is the use of recipe. You declare it as an object. Think of it as a car with doors. it has one steering wheel and four tires. and in the next step, you trying to compare it with 1. In this situation, the compiler goes 1 what? (CS0019: Line 15: Operator '>=' cannot be applied to operands of type 'Item' and 'int')

The next issue is the case statement or the switch. This is how a switch is built:

After the switch, you have a return (get out of here) statement that should only be at the end of a function to return a value.
CS0127: Line 174: Since 'RecipeSatchel.RecipeSatchel()' returns void, a return keyword must not be followed by an object expression

Try this tutorial to get the basic in the C# language:

This is how I would have solved it
( Attached: RecipeSatchel.cs )

-Grim
 

Attachments

Last edited:
  • Like
Reactions: Exale

CLASnipe

Member
Jul 15, 2019
11
2
yea I figured it out but did it a completely different way (note : numbers I got where based off the numbers in the recipe book so they are out of order)

C#:
using System;
using Reward = Server.Engines.Quests.BaseReward;

namespace Server.Items
{
    public class RecipeSatchel : Backpack
    {
        [Constructable]
        public RecipeSatchel()
            : base()
        {
           
                switch (Utility.Random(152))
                {
                    default:
                        case 0: DropItem ( new RecipeScroll(501)); break;
                        case 1: DropItem ( new RecipeScroll(502)); break;
                        case 2: DropItem ( new RecipeScroll(503)); break;
                        case 3: DropItem ( new RecipeScroll(504)); break;
                        case 4: DropItem ( new RecipeScroll(505)); break;
                        case 5: DropItem ( new RecipeScroll(599)); break;
                        case 6: DropItem ( new RecipeScroll(250)); break;
                        case 7: DropItem ( new RecipeScroll(251)); break;
                        case 8: DropItem ( new RecipeScroll(252)); break;
                        case 9: DropItem ( new RecipeScroll(253)); break;
                        case 10: DropItem ( new RecipeScroll(254)); break;
                        case 11: DropItem ( new RecipeScroll(350)); break;
                        case 12: DropItem ( new RecipeScroll(351)); break;
                        case 13: DropItem ( new RecipeScroll(354)); break;
                        case 14: DropItem ( new RecipeScroll(150)); break;
                        case 15: DropItem ( new RecipeScroll(352)); break;
                        case 16: DropItem ( new RecipeScroll(353)); break;
                        case 17: DropItem ( new RecipeScroll(151)); break;
                        case 18: DropItem ( new RecipeScroll(152)); break;
                        case 19: DropItem ( new RecipeScroll(551)); break;
                        case 20: DropItem ( new RecipeScroll(550)); break;
                        case 21: DropItem ( new RecipeScroll(552)); break;
                        case 22: DropItem ( new RecipeScroll(452)); break;
                        case 23: DropItem ( new RecipeScroll(450)); break;
                        case 24: DropItem ( new RecipeScroll(451)); break;
                        case 25: DropItem ( new RecipeScroll(453)); break;
                        case 26: DropItem ( new RecipeScroll(116)); break;
                        case 27: DropItem ( new RecipeScroll(106)); break;
                        case 28: DropItem ( new RecipeScroll(108)); break;
                        case 29: DropItem ( new RecipeScroll(109)); break;
                        case 30: DropItem ( new RecipeScroll(100)); break;
                        case 31: DropItem ( new RecipeScroll(102)); break;
                        case 32: DropItem ( new RecipeScroll(111)); break;
                        case 33: DropItem ( new RecipeScroll(118)); break;
                        case 34: DropItem ( new RecipeScroll(200)); break;
                        case 35: DropItem ( new RecipeScroll(201)); break;
                        case 36: DropItem ( new RecipeScroll(202)); break;
                        case 37: DropItem ( new RecipeScroll(203)); break;
                        case 38: DropItem ( new RecipeScroll(204)); break;
                        case 39: DropItem ( new RecipeScroll(205)); break;
                        case 40: DropItem ( new RecipeScroll(206)); break;
                        case 41: DropItem ( new RecipeScroll(207)); break;
                        case 42: DropItem ( new RecipeScroll(300)); break;
                        case 43: DropItem ( new RecipeScroll(301)); break;
                        case 44: DropItem ( new RecipeScroll(302)); break;
                        case 45: DropItem ( new RecipeScroll(303)); break;
                        case 46: DropItem ( new RecipeScroll(304)); break;
                        case 47: DropItem ( new RecipeScroll(305)); break;
                        case 48: DropItem ( new RecipeScroll(306)); break;
                        case 49: DropItem ( new RecipeScroll(307)); break;
                        case 50: DropItem ( new RecipeScroll(308)); break;
                        case 51: DropItem ( new RecipeScroll(309)); break;
                        case 52: DropItem ( new RecipeScroll(310)); break;
                        case 53: DropItem ( new RecipeScroll(311)); break;
                        case 54: DropItem ( new RecipeScroll(312)); break;
                        case 55: DropItem ( new RecipeScroll(313)); break;
                        case 56: DropItem ( new RecipeScroll(314)); break;
                        case 57: DropItem ( new RecipeScroll(315)); break;
                        case 58: DropItem ( new RecipeScroll(332)); break;
                        case 59: DropItem ( new RecipeScroll(333)); break;
                        case 60: DropItem ( new RecipeScroll(334)); break;
                        case 61: DropItem ( new RecipeScroll(335)); break;
                        case 62: DropItem ( new RecipeScroll(316)); break;
                        case 63: DropItem ( new RecipeScroll(317)); break;
                        case 64: DropItem ( new RecipeScroll(318)); break;
                        case 65: DropItem ( new RecipeScroll(319)); break;
                        case 66: DropItem ( new RecipeScroll(320)); break;
                        case 67: DropItem ( new RecipeScroll(321)); break;
                        case 68: DropItem ( new RecipeScroll(322)); break;
                        case 69: DropItem ( new RecipeScroll(323)); break;
                        case 70: DropItem ( new RecipeScroll(324)); break;
                        case 71: DropItem ( new RecipeScroll(325)); break;
                        case 72: DropItem ( new RecipeScroll(326)); break;
                        case 73: DropItem ( new RecipeScroll(327)); break;
                        case 74: DropItem ( new RecipeScroll(328)); break;
                        case 75: DropItem ( new RecipeScroll(329)); break;
                        case 76: DropItem ( new RecipeScroll(330)); break;
                        case 77: DropItem ( new RecipeScroll(331)); break;
                        case 78: DropItem ( new RecipeScroll(112)); break;
                        case 79: DropItem ( new RecipeScroll(113)); break;
                        case 80: DropItem ( new RecipeScroll(114)); break;
                        case 81: DropItem ( new RecipeScroll(115)); break;
                        case 82: DropItem ( new RecipeScroll(400)); break;
                        case 83: DropItem ( new RecipeScroll(402)); break;
                        case 84: DropItem ( new RecipeScroll(401)); break;
                        case 85: DropItem ( new RecipeScroll(117)); break;
                        case 86: DropItem ( new RecipeScroll(107)); break;
                        case 87: DropItem ( new RecipeScroll(120)); break;
                        case 88: DropItem ( new RecipeScroll(110)); break;
                        case 89: DropItem ( new RecipeScroll(101)); break;
                        case 90: DropItem ( new RecipeScroll(103)); break;
                        case 91: DropItem ( new RecipeScroll(105)); break;
                        case 92: DropItem ( new RecipeScroll(119)); break;
                        case 93: DropItem ( new RecipeScroll(104)); break;
                        case 94: DropItem ( new RecipeScroll(336)); break;
                        case 95: DropItem ( new RecipeScroll(500)); break;
                        case 96: DropItem ( new RecipeScroll(604)); break;
                        case 97: DropItem ( new RecipeScroll(603)); break;
                        case 98: DropItem ( new RecipeScroll(702)); break;
                        case 99: DropItem ( new RecipeScroll(701)); break;
                        case 100: DropItem ( new RecipeScroll(560)); break;
                        case 101: DropItem ( new RecipeScroll(561)); break;
                        case 102: DropItem ( new RecipeScroll(562)); break;
                        case 103: DropItem ( new RecipeScroll(563)); break;
                        case 104: DropItem ( new RecipeScroll(564)); break;
                        case 105: DropItem ( new RecipeScroll(565)); break;
                        case 106: DropItem ( new RecipeScroll(566)); break;
                        case 107: DropItem ( new RecipeScroll(570)); break;
                        case 108: DropItem ( new RecipeScroll(575)); break;
                        case 109: DropItem ( new RecipeScroll(573)); break;
                        case 110: DropItem ( new RecipeScroll(574)); break;
                        case 111: DropItem ( new RecipeScroll(576)); break;
                        case 112: DropItem ( new RecipeScroll(577)); break;
                        case 113: DropItem ( new RecipeScroll(572)); break;
                        case 114: DropItem ( new RecipeScroll(571)); break;
                        case 115: DropItem ( new RecipeScroll(581)); break;
                        case 116: DropItem ( new RecipeScroll(584)); break;
                        case 117: DropItem ( new RecipeScroll(583)); break;
                        case 118: DropItem ( new RecipeScroll(582)); break;
                        case 119: DropItem ( new RecipeScroll(580)); break;
                        case 120: DropItem ( new RecipeScroll(600)); break;
                        case 121: DropItem ( new RecipeScroll(601)); break;
                        case 122: DropItem ( new RecipeScroll(602)); break;
                        case 123: DropItem ( new RecipeScroll(800)); break;
                        case 124: DropItem ( new RecipeScroll(900)); break;
                        case 125: DropItem ( new RecipeScroll(901)); break;
                        case 126: DropItem ( new RecipeScroll(902)); break;
                        case 127: DropItem ( new RecipeScroll(903)); break;
                        case 128: DropItem ( new RecipeScroll(904)); break;
                        case 129: DropItem ( new RecipeScroll(905)); break;
                        case 130: DropItem ( new RecipeScroll(1000)); break;
                        case 131: DropItem ( new RecipeScroll(455)); break;
                        case 132: DropItem ( new RecipeScroll(461)); break;
                        case 133: DropItem ( new RecipeScroll(462)); break;
                        case 134: DropItem ( new RecipeScroll(460)); break;
                        case 135: DropItem ( new RecipeScroll(459)); break;
                        case 136: DropItem ( new RecipeScroll(170)); break;
                        case 137: DropItem ( new RecipeScroll(457)); break;
                        case 138: DropItem ( new RecipeScroll(458)); break;
                        case 139: DropItem ( new RecipeScroll(355)); break;
                        case 140: DropItem ( new RecipeScroll(356)); break;
                        case 141: DropItem ( new RecipeScroll(585)); break;
                        case 142: DropItem ( new RecipeScroll(456)); break;
                        case 143: DropItem ( new RecipeScroll(464)); break;
                        case 144: DropItem ( new RecipeScroll(465)); break;
                        case 145: DropItem ( new RecipeScroll(605)); break;
                        case 146: DropItem ( new RecipeScroll(606)); break;
                        case 147: DropItem ( new RecipeScroll(607)); break;
                        case 148: DropItem ( new RecipeScroll(586)); break;
                        case 149: DropItem ( new RecipeScroll(587)); break;
                        case 150: DropItem ( new RecipeScroll(588)); break;
                        case 151: DropItem ( new RecipeScroll(463)); break;              
                }      
        }

        public RecipeSatchel(Serial serial)
            : base(serial)
        {
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
        }
    }
}
 

Attachments