Error when attempting to use UpdateWeaponSpawnChances
Posted: Mon May 28, 2018 4:06 am
I'm currently attempting to learn how to use this function, and although my code compiles, it fails when testing ingame.
Here is the code:
public void OnStartup(){
Dictionary<short,int> weaponChances = new Dictionary<short,int>();
weaponChances.Add(17,0);
Game.UpdateWeaponSpawnChances(weaponChances);
}
And here is the error I get when testing it:
Script Error
Error in method 'OnStartup()' in map script. See the exception for more details:
--- Exception ---
Enum underlying type and the object must be same type or object must be a String. Type passed in was 'System.Int16'; the enum underlying type was 'System.Int32'.
System.ArgumentException: Enum underlying type and the object must be same type or object must be a String. Type passed in was 'System.Int16'; the enum underlying type was 'System.Int32'.
at System.RuntimeType.IsEnumDefined(Object value)
at System.Enum.IsDefined(Type enumType, Object value)
at SFD.WeaponSpawnManager.FromDictionary(Dictionary`2 values)
at SFD.GameWorldScriptBridge.UpdateWeaponSpawnChances(Dictionary`2 values)
at SFD.GameWorldScriptBridge.UpdateWeaponSpawnChances(Dictionary`2 values)
at SFDScript.GameScript.OnStartup()
Help would be greatly appreciated!
Here is the code:
public void OnStartup(){
Dictionary<short,int> weaponChances = new Dictionary<short,int>();
weaponChances.Add(17,0);
Game.UpdateWeaponSpawnChances(weaponChances);
}
And here is the error I get when testing it:
Script Error
Error in method 'OnStartup()' in map script. See the exception for more details:
--- Exception ---
Enum underlying type and the object must be same type or object must be a String. Type passed in was 'System.Int16'; the enum underlying type was 'System.Int32'.
System.ArgumentException: Enum underlying type and the object must be same type or object must be a String. Type passed in was 'System.Int16'; the enum underlying type was 'System.Int32'.
at System.RuntimeType.IsEnumDefined(Object value)
at System.Enum.IsDefined(Type enumType, Object value)
at SFD.WeaponSpawnManager.FromDictionary(Dictionary`2 values)
at SFD.GameWorldScriptBridge.UpdateWeaponSpawnChances(Dictionary`2 values)
at SFD.GameWorldScriptBridge.UpdateWeaponSpawnChances(Dictionary`2 values)
at SFDScript.GameScript.OnStartup()
Help would be greatly appreciated!