Code:private List<string> BuildProps = new List<string>(); BuildProps.Add("door.double.hinged.metal"); BuildProps.Add("door.double.hinged.toptier"); BuildProps.Add("door.double.hinged.wood"); BuildProps.Add("dropbox"); BuildProps.Add("mailbox"); BuildProps.Add("box.repair.bench"); BuildProps.Add("cupboard.tool"); BuildProps.Add("furnace.large"); BuildProps.Add("furnace"); BuildProps.Add("planter.large"); BuildProps.Add("box.wooden.large");Code:Error while compiling: ControlProp.cs(32,18): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
Function doesn't return true even if its true.
Discussion in 'Rust Development' started by cookiecool, Feb 10, 2018.
-
It looks like you're creating a list outside a method (hence the "private") and I assume trying to add to it right after creating it. You'll have to either move the list into a method (and remove the private) or just add to it from inside of one. For example, add to the list using the hook Init(), like so:
Code:private List<string> BuildProps = new List<string>(); //this is outside void Init() { BuildProps.Add("door.double.hinged.metal"); BuildProps.Add("door.double.hinged.toptier"); BuildProps.Add("door.double.hinged.wood"); BuildProps.Add("dropbox"); BuildProps.Add("mailbox"); BuildProps.Add("box.repair.bench"); BuildProps.Add("cupboard.tool"); BuildProps.Add("furnace.large"); BuildProps.Add("furnace"); BuildProps.Add("planter.large"); BuildProps.Add("box.wooden.large"); }
Here's an example of how to create a list with values already in it, if that's what you need or want to do: How to initialize a C# string list (List<string>) with many string values -
[DOUBLEPOST=1518247516][/DOUBLEPOST]
Code:bool ContainsString(BaseEntity propi) { bool BB; BB = false; for (int i = 0; i < BuildProps.Count; i++) { if (propi.ShortPrefabName == BuildProps[i]) { BB = true; return BB; } } return BB; }
-
Code:
return BuildProps.Contains(propi.ShortPrefabName);