I want to find out the total gold value of all weapons in a cell and I'm using GetNextRef to do it but it crashes almost everytime after a few seconds.
This is the script, it's just a simple MessageBox that displays the results for each ref
Begin GameMode if sScanRefs == 0 set rWeapon to GetFirstRef 33 ;=== scan weapons set sScanRefs to 1 endif if sScanRefs == 1 set fGoldValue to GetFullGoldValue rWeapon ;=== get full gold value of weapon set fTotalGoldValue to fTotalGoldValue + fGoldValue ;=== add weapon value to total value set rWeapon to GetNextRef set sScanRefs to 2 endif if sStartTimer == 0 set fScanTimer to 2 set sStartTimer to 1 endif if fScanTimer <= 0 MessageBox "GoldValue is %g" "fTotalGoldValue" ;=== display total gold value set sStartTimer to 0 set sScanRefs to 1 ;=== Loop back else set fScanTimer to fScanTimer - GetSecondsPassed endifEnd
I know this code is working because the MessageBox updates accordingly for the first few seconds that it's running, but then eventually it will crash before it finishes looking at all the references in the cell.
Any ideas?