Hi guys I have a problem with this script, how can i resolve?

ERROR:
CS0266: Line 28: Implicitly converting type 'System.Collections.Generic.IEnumerable <Server.Gumps.Gump>' into 'System.Collections.Generic.List <Server.Gumps.Gump>'. There is an explicit conversion. Probably missing a cast.


using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Network;
using Server.Gumps;
namespace Knives.TownHouses
{
public class GumpResponse
{
public static void Initialize()
{
Timer.DelayCall(TimeSpan.Zero, new TimerCallback(AfterInit));
}
private static void AfterInit()
{
PacketHandlers.Register(0xB1, 0, true, new OnPacketReceive(DisplayGumpResponse));
}
public static void DisplayGumpResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
int typeID = pvSrc.ReadInt32();
int buttonID = pvSrc.ReadInt32();





//LINE 28 ERROR! List<Gump> gumps = state.Gumps; //LINE 28 ERROR!
for (int i = 0; i < gumps.Count; ++i)
{
Gump gump = gumps;
if (gump.Serial == serial && gump.TypeID == typeID)
{
int switchCount = pvSrc.ReadInt32();
if (switchCount < 0)
{
Console.WriteLine("Client: {0}: Invalid gump response, disconnecting...", state);
state.Dispose();
return;
}
int[] switches = new int[switchCount];
for (int j = 0; j < switches.Length; ++j)
switches[j] = pvSrc.ReadInt32();
int textCount = pvSrc.ReadInt32();
if (textCount < 0)
{
Console.WriteLine("Client: {0}: Invalid gump response, disconnecting...", state);
state.Dispose();
return;
}
TextRelay[] textEntries = new TextRelay[textCount];
for (int j = 0; j < textEntries.Length; ++j)
{
int entryID = pvSrc.ReadUInt16();
int textLength = pvSrc.ReadUInt16();
if (textLength > 239)
return;
string text = pvSrc.ReadUnicodeStringSafe(textLength);
textEntries[j] = new TextRelay(entryID, text);
}
state.RemoveGump(i);
if (!CheckResponse(gump, state.Mobile, buttonID))
return;
gump.OnResponse(state, new RelayInfo(buttonID, switches, textEntries));
return;
}
}
if (typeID == 461) // Virtue gump
{
int switchCount = pvSrc.ReadInt32();
if (buttonID == 1 && switchCount > 0)
{
Mobile beheld = World.FindMobile(pvSrc.ReadInt32());
if (beheld != null)
EventSink.InvokeVirtueGumpRequest(new VirtueGumpRequestEventArgs(state.Mobile, beheld));
}
else
{
Mobile beheld = World.FindMobile(serial);
if (beheld != null)
EventSink.InvokeVirtueItemRequest(new VirtueItemRequestEventArgs(state.Mobile, beheld, buttonID));
}
}
}
private static bool CheckResponse(Gump gump, Mobile m, int id)
{
if (m == null || !m.Player)
return true;
TownHouse th = null;
ArrayList list = new ArrayList();
foreach (Item item in m.GetItemsInRange(20))
if (item is TownHouse)
list.Add(item);
foreach (TownHouse t in list)
if (t.Owner == m)
{
th = t;
break;
}
if (th == null || th.ForSaleSign == null)
return true;
if (gump is HouseGumpAOS)
{
int val = id - 1;
if (val < 0)
return true;
int type = val % 15;
int index = val / 15;
if (th.ForSaleSign.ForcePublic && type == 3 && index == 12 && th.Public)
{
m.SendMessage("This house cannot be private.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.ForcePrivate && type == 3 && index == 13 && !th.Public)
{
m.SendMessage("This house cannot be public.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.NoTrade && type == 6 && index == 1)
{
m.SendMessage("This house cannot be traded.");
m.SendGump(gump);
return false;
}
}
else if (gump is HouseGump)
{
if (th.ForSaleSign.ForcePublic && id == 17 && th.Public)
{
m.SendMessage("This house cannot be private.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.ForcePrivate && id == 17 && !th.Public)
{
m.SendMessage("This house cannot be public.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.NoTrade && id == 14)
{
m.SendMessage("This house cannot be traded.");
m.SendGump(gump);
return false;
}
}
return true;
}
}
}
 
List<Gump> gumps = state.Gumps;

right here, there you need to add the ToList call
 
thanks i try :)
[doublepost=1551875627][/doublepost]List<Gump> gumps = state.Gumps;
List<Gump> gumps = ToList <Gump> state.Gumps;
Is correct? I get
+ Custom / Town Houses v2.01 / Misc / GumpResponse.cs:
CS0103: Line 28: The name 'ToList' does not exist in the current context.
CS0118: Line 28: 'Server.Gumps.Gump' is 'type' but is used as 'variable'.

I'm noob sorry ehehe
 
Hi Tempus, I got this error;

errors:
+ Custom / Town Houses v2.01 / Misc / GumpResponse.cs:
CS0117: Line 28: 'System.Collections.Generic.IEnumerable <Server.Gumps.Gump>' does not contain a definition for 'ToList'.
 
Make sure you have the following Using statements declared at the top of the class file

Code:
Using System.Linq;
Using System.Xml.Linq;
 
Hi tempus I'm not lucky, I have added how you said

CS0234: Line 7: The type or name of the 'Linq' namespace does not exist in the 'System' namespace. Probably a reference to an assembly is missing.
CS0234: Line 8: The type or name of the 'Linq' namespace does not exist in the 'System.Xml' namespace. Probably a reference to an assembly is missing.
 
Back