So I'm having a slight issue with a for() syntax in a file I'm making. Essentially its a stackable Consumable, and I want it to run a function x times, where x is the amount in the stack.

"
public FarmTicket(int amount)
: base(0x14F0)
{
Name = "Farm Ticket";
LootType = LootType.Cursed;
Stackable = true;
Amount = amount;
Weight = 0.1;
}

public override int count = Amount;

//Other parts of the file here

public static void CashTicket( object state )
{
Mobile m = (Mobile)state;
PlayerMobile pm = m as PlayerMobile;
for( int count )
{

pm.AddToBackpack(new Gold(10000));"

"error CS1002: ; expected [C:\Users\brutherford\Documents\UO\Scripts\Scripts.csproj]"
"error CS1525: Invalid expression term ')' [C:\Users\brutherford\Documents\UO\Scripts\Scripts.csproj]"

I'm fairly sure this is going to be one of those easy to solve issues, but I can't for the life of me get that for(int conut) to work for the life of me. Any suggestions/help would be greatly appreciated.
Post automatically merged:

So in the lsat like 3 hours now >.> All I've managed to accomplish was to get the file to compile, but not load properly. I ended up changing the for() function to an if check.

public static int c;
[Constructable]
public FarmTicket(int amount)
: base(0x14F0)
{
Name = "Farm Ticket";
LootType = LootType.Cursed;
Stackable = true;
Amount = amount;
Weight = 0.1;
c = amount;
}

//Other Stuff Here

public static void OpenTicket( object state )
{

Mobile m = (Mobile)state;
PlayerMobile pm = m as PlayerMobile;
Console.WriteLine("{0} count", c);
if (c < 0)
{
pm.AddToBackpack(new Gold(10000));
//Bunch more items removed to reduce space
}
c = c-1;
}
}

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

writer.Write(0); // version
}

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

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

But once I use the item(s), the Console.WriteLine says variable c has the same number of items as I just consumed, but now the if check isn't running at all, and I'm receiving 0 loot. Anyone know how to fix this problem either for(), or if() way? Or some other way to do what I am trying?
 
Last edited:
So after my hours, and curse words, I finally managed to get it to work. Just to update for anyone who Necro Finds this post.
If you are doing a for() statement, especially if it using a variable, you MUST call the Variable in the Public Class main


namespace Server.Items
{
public class FarmTicket : Item
{
public static int c;
[Constructable]
public FarmTicket(int amount)

Then inside the for() statement, you have to manipulate the variable to get it to use the variable properly (my problem was I kept trying to use same variable across the whole action)

public static void OpenTicket( object state )
{

Mobile m = (Mobile)state;
PlayerMobile pm = m as PlayerMobile;

for (int i = 0; i < c; i++)

I ended up just finding (I had seen that exact string elsewhere) that string of code again, and decided to test it. And it worked fine.
 
Back