ID:265009
 
Code:
world << world.GetMedal( "Arbitrary Medal", usr ) // returns 0
world << world.SetMedal( "Arbitrary Medal", usr ) // returns 0


Problem description:

• Procedure descriptions:

world.GetMedal() desc:
Checks to see if a medal has been awarded to the player in question. If the medal has been awarded, the return value is 1. If not, 0.

world.SetMedal() desc:
Awards a medal to a player. The proc will return 1 if it is successful, or 0 if the medal was already awarded.

In the code I attempt to find if a particular medal has already been awarded.

• Test results:

GetMedal returns 0 indicating the medal has NOT been awarded.

SetMedal returns 0 indicating the medal HAS been awarded.

• Further details:

I attempted to award myself with a medal in game. Looking at the hub no medal was actually awarded. In the game I ran a couple procs to check if I had actually been awarded, and ended up with a contradiction. GetMedal and SetMedal report opposite results, so what may be causing this error?
I don't really see why you have "world <<". Just try world.SetMedal("Arbitrary Medal", usr) and if that still doesn't work then you most likely don't have a hub password set for your game, and a password for the hub of the game. These both have to be the same. Also make sure you've created the medal for your hub under the 'Medals' tab when you edit you hub. The name has to the be the same as the one your awarding.

Look up hub_password in the dm reference.
In response to AbdelJN (#1)
Nope. All of these things have been set already and yet the error persists.

It should be blatantly clear why I used "world <<". This outputs to the world what is returned by the Get and Set procedures. It's a way of debugging whether or not the medal registered.

Also, I'm not sure you focused in on the main point of my post. And that is, in short:

GetMedal and SetMedal, when run concurrently and fed the same inputs, should NEVER both return 1 or both return 0 since the result is contradictory.

Help, anyone? Or should this be a bug report?
In response to Lethal Dragon (#2)
It's most likely a bug. According to the program, you don't have the medal after being awarded it, so it seems pretty obvious to me.
In response to Shaoni (#3)
Ok, so it may be a bug.

I have not used medals before and debugging this happens to be useless since I get a contradictory result.

Anyhow, could someone show me the proper way to award medals in the code? Just ONE instance that WORKS (successfully awards a medal to a player and reports back to the hub). Thanks.
In response to Lethal Dragon (#4)
HALP. Just a simple example, someone. Anyone who's used medals before, please provide me with an oversimplified example of how to upload a medal to the hub, assuming a hub password is set in both the code and on the hub itself. =_=

I did try searching "medals" over the forum but to no avail. The search system here isn't exactly a Google engine.
Make sure usr is what you expect it to be and make sure the name of the medal is correct. You might want to store the return value in a var and do some more elaborate output (ex: call isnull() to see if the return value is null and not just an empty string).

I've had problems with medals too, so I'd believe that they're just not working.
In response to Forum_account (#6)
Forum_account wrote:
Make sure usr is what you expect it to be and make sure the name of the medal is correct. You might want to store the return value in a var and do some more elaborate output (ex: call isnull() to see if the return value is null and not just an empty string).

I've had problems with medals too, so I'd believe that they're just not working.

I'm having almost the same problem. Only when I look at the games HUB I have the medals but when on my medals page I don't have them. Not sure why, must be a bug.
In response to Chwgt (#7)
Chwgt wrote:
Only when I look at the games HUB I have the medals but when on my medals page I don't have them. Not sure why, must be a bug.

You must favorite the game for them to show up on your medals page, to my knowledge.
In response to Neimo (#8)
It is a favorite and I mean it doesn't show up with any of the other medals. Favorited or not.
In response to Chwgt (#9)
Are you viewing this page? I see all of your medals.
In response to Neimo (#10)
Yes, I am viewing the right page. I'm not a complete moron. Eternia: Prologue medals just wont show up on my page.
In response to Chwgt (#11)
Chwgt wrote:
Yes, I am viewing the right page. I'm not a complete moron. Eternia: Prologue medals just wont show up on my page.

I was not implying that you were a moron at all, I just wanted to check and be sure.
In response to Neimo (#12)
Oh I know, I didn't mean it to sound that way.
In response to Chwgt (#13)
world.hub? world.hub_password?
In response to Ocean King (#14)
Yeah, and both are correct. Like I said: The games Hub registers that I have it. I just doesn't show up in my medal page.
In response to Ocean King (#14)
On that note, could you provide a couple lines of code that award a player with a medal?

This is how you can add a score:

var/paramss = list( "Score" = "500" )

world.SetScores( "SomeUser", list2params( paramss ), "SomeUser.SomeGame", "myHUBpassword" )


Now what is the syntax for a medal?
In response to Lethal Dragon (#16)
If you've set the hub/hub_pass, then you don't have to include it in the medal/scores procs to my knowledge. Not sure why people are saying to do it.
In response to Liam Howe (#17)
It takes whatever you've set your hub/hub_password to as default, but if you wanted to award a medal to a game via a server not hosted on the hub directly, this would be useful (For example, in cluster server setups)
In response to Lethal Dragon (#5)
I don't know if this is still needed but, here's an example of a medal being awarded;

world
hub="SomeUser.SomeGame"
hub_password="1234567890."

mob/Login()
.=..()
if(.)
if(!(world.GetMedal("Some Random Medal", usr.key)))
if(world.SetMedal("Some Random Medal", usr.key))
usr<<"\blue <b>You've been awarded with a new Medal (Some Random Medal)."
else usr<<"\red <b>An error happened while trying to contact the HUB!"


This example awards a Medal just by loging in to the game for the first time.
As you may see, I've set up the hub & hub_password variables, which are strongly required in order to contact the HUB, otherwise you would need to set this up in each SetMedal()/GetMedal() proc.

I hope this helps, altough am a bit late.