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!
This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk
Forum rules
Forum rules
Error when attempting to use UpdateWeaponSpawnChances
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
- Bash Kraken
- Superfighter

- Posts: 75
- Joined: Tue Mar 22, 2016 12:49 pm
- Title: Action Hero Extraordinaire
- SFD Alias: Bash Kraken
- Started SFD: December 2012
- Location: Post-Apocalyptic East Coast - U.S.
- Gender:
