Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Error when attempting to use UpdateWeaponSpawnChances

Here you can find all solved gameplay problems and bugs (beginning from Pre-Alpha 1.8.8).
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
User avatar
Bash Kraken
Superfighter
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:

Error when attempting to use UpdateWeaponSpawnChances

Post by Bash Kraken » 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!
0 x
heck
Hidden Content
This board requires you to be registered and logged-in to view hidden content.

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Mon May 28, 2018 10:16 am

Fixed to the release of SFD.
Doesn't look like Game.UpdateWeaponSpawnChances can be used before the fix.
0 x
Gurt

Locked