ID:1824828
 
(See the best response by Ter13.)
Code:

    if(!world.GetMedal("Summer 2014 Finalist", usr.key))

if(!world.GetMedal("Summer 2014 Pewter", usr.key))
backs -= "** Summer 2014 Pewter Custom"

if(!world.GetMedal("Summer 2014 Bronze", usr.key))
backs -= "** Summer 2014 Bronze Custom"

if(!world.GetMedal("Summer 2014 Silver", usr.key))
backs -= "** Summer 2014 Silver Custom"

if(!world.GetMedal("Summer 2014 Champion", usr.key))
backs -= "** Summer 2014 Champion Custom"
backs -= "** Summer 2014 Seasonal"


Problem description:

Is there a way to use world.GetMedal to check to see if a player has a medal in-general before looking for individuals? Im adding in a series of unlocks for my game for tournament winners but it's causing certain aspects of the game to run a bit slow when it checks for each of the medals.

I'd really like to be able to check a player for a medal first and if they dont have any, dont bother with the rest of the checks. Is that possible?

The way things go right now it takes ~30 seconds to run through the checks of all ~20 medals that could give these rewards.

Is there a better way I could be doing this?

Note that above is just a section of the checks. I have 4 seasons that all have similar layouts.
Best response
You really ought to check out the reference. There's all kinds of useful information in there.

From the DM reference on the GetMedal() proc:

You can also use GetMedal() to read a list of all medals a player has earned for the hub entry, by leaving the medal argument blank. If you also leave the player argument blank, you will get a list of all medals available to the hub entry. In both cases the result can be parsed with params2list().

Don't call SetScore or Set/GetMedal repeatedly. It waits around for the calls to finish. I recommend setting up an asynchronous non-blocking proc to do the job for you. Ideally, you'd like some sort of a mechanism for responding to medal award failures too, but this should at least get you started.

client
var
list/medals
proc
AwardMedal(medal)
set waitfor = 0
if(SetMedal(medal,src))
medals[medal] = 1

HasMedal(medal)
if(medals[medal])
return TRUE
return FALSE

New()
var/list/l = params2list(GetMedal(null,src))
medals = list()
for(var/v in l)
medals[v] = TRUE
..()


Updated it a bit to use associative lists rather than the in operator. It'll be a lot faster to check a ton of medals now.