Yep, its quite possible, though its slightly complicated. First, though, if you've created the file specifically for POL, you shouldn't put the 'i' in the Rating. If you're stuck with it (imported the file from something else...) then you can work around it.
The general code that you'd want would look something like the following (warning: Untested code thrown together on the spur of the moment)
- Code: Select all
use uo;
use os;
use cfgfile;
program check_ratings (character, text) //assuming its a dot command
var rating_cfg := ReadConfigFile ("File name here");//the file you're importing needs to be a .cfg file, located in a POL-accessible package.
if (!rating_cfg)
SendSysMessage (character, "Unable to find file!");
return
endif
var keys := GetConfigIntKeys (rating_cfg) //Use GetConfigStringKeys if some of the keys are strings)
var highest_rating := 0;
var hightest_rating_key := 0;
foreach key in keys
var theelem := GetConfigElem (rating_cfg, key);
if (theelem and theelem.rating)
if (theelem.rating > highest_rating)
highest_rating := theelem.rating;
highest_rating_key := key;
endif
endif
endforeach
SendSysMessage (character, "The highest rating was " + highest_rating + " in element " + highest_rating_key);
endprogram
If the 'i' has to stay there, then replace the 'foreach' section with something like:
- Code: Select all
foreach key in keys
var theelem := GetConfigElem (rating_cfg, key);
var elemrating := theelem.rating;
elemrating["i"] := "";
elemrating := CINT (elemrating);
if (elemrating)
if (elemrating > highest_rating)
highest_rating := elemrating;
highest_rating_key := key;
endif
endif
endforeach