We're archiving the forums and going read only! You'll be able to see old threads, but new topics and replies have been disabled.

Visit the Game Jolt community for new questions and conversations.


Right, so, what seems like a long time ago I started work on a C# API for dotNet developers. That project kind of fell through the roof and killed my cat. So, to get around my anger I coded a game.

Now, I'm back, however, and am working, once again, on the C# API.

The source may be downloaded from the project page here: https://gamejolttrophies.codeplex.com/.

If you've got suggestions for what you want to see featured in the API leave it here, if you broke something and want to submit a bug, please do that on Codeplex so I can sift through them easier.

More info will be availible as the project progresses. There should be a lot more by the end of the weekend.

If you are looking for documentation on how to use the API then check out the Documentation on Codeplex or read up on the documentation in the code. I've done my best to provide helpful comments.


Page 1 of 44 replies.

almost 13 years ago

I've put this up on the achievements landing page, rune. Which means you now have to finish it up! Mwuahaha...

5d09a2d3cfbf8.png
almost 13 years ago

Hey, everything but Highscores and Data Storage is done. But unfortunatly I don't get paid for this, so it kind of falls back to working on it only during free time on weekends etc. I've also been having this weird issue with threads that I'm working on fixing.

Also, I hope to have a .Net 4, 3, Silverlight, Metro and Windows Phone version availible by the time I call the project done.

Additionally roaming storage, which still needs some work, will have to be done for the final version. It would be nice if Game Jolt had a "Settings" API so that a user could store global settings for simple things like forward, backward, sideways, jump, attack, action, pause etc. That could be accessed by all games. That would pretty much do what my roaming storage does, except globally.

Anway, it should be working for .Net 4 by the end of this weekend. After that, I'll work on getting Silver Jolt finished with a Silverlight version, then move to more interesting things.

I'm sure I'll think of other ways to abuse this system while I work in order to get really weird things. Like statistics tracking for example. The API's Add function will prove useful here.

5d09a2d45ae9b.png

Edit: ... but Cros ... Torchlight 2 is coming out ... my weekend might be .... busy.

Last modified on September 20, 2012 by runewake2 @runewake2

almost 13 years ago

@runewake2 : aside from games, I work mainly with C# (computer vision applied to medicine). If you get stuck with those threads or anything else feel free to ask :)

almost 13 years ago

Well, the thing is... I use a Timer to keep your session open, the Timer runs every 30 seconds, and works as long as I'm debugging, however, when I remove my breakpoint the session eventually times out. As in, Game Jolt closes the session. No idea why that is happening, but it's annoying. If you have suggestions, let me know.

That is the only real problem I've found so far.

almost 13 years ago

If you ping every 5 seconds instead, does Game Jolt keep the session open?

almost 13 years ago

Yes, that does seem to fix the problem, though I'm not sure if the time was the issue. Oddly, when debugging I got the time in a session up to about 5 minutes. Then I removed the breakpoint and soon the session was failing. I believe the issue might be that code might not be executing in a console application while the window is deselected. But for now, it seems to be working, so I'll upload the fix, and mark the bug as fixed. Should be finishing the rest of the API this weekend, assuming no big issues get in the way. I might even get roaming storage started.

I see I already have two users, so gotta get this done to make them happy.

Hoping to branch out the project to something that supports silverlight, XNA and 3.0. Also I'll be building some DLL's to fill that barren Downloads page.

almost 13 years ago

Hmm, I was suggesting every 5 seconds to test it. I wouldn't keep it as 5 seconds in the production code. Try something like 20 seconds instead.

almost 13 years ago

I thought I replied to this. Anyway, as you can see with SilverJolt, my Silverlight test project. Sessions are now working just fine. I should also note that I have left it up to the developer to decide the period between session updates. However, I have bumped it back to 30 seconds for now, seems to be working. Alas, I did have stuff to do this weekend, though oddly not Torchlight 2 related, that prevented the Data Storage and Highscores from being finished. Maybe next weekend?

over 10 years ago

??? why are there no videos or anything? it doesnt even explain where to start!

over 10 years ago

Hello,

The site has a link to Documentation which has a high level overview of the design behind the API. The source code includes two projects, one is the API the other is a sample project which uses the Windows console to let you access your trophies. This serves as my "Tutorial" project. I've also tried to document each class and function in the source.

Personally, I'm not developing new features for this API as I've moved to Unity for my own projects and the API saw almost no use. The number of silverlight, XNA and MonoGame projects is just too small. I will still fix bugs and help with implementation and each source file includes an email address for support. Feel free to ask any implementation questions you have regarding the API and I'll do my best to help you out.

If you are working with a C# game engine like Unity, there are better libraries specifically written to take advantage of some of the engines features. I'd check if your engine is supported by one of these first. This library itself requires more work since it doesn't have any of that front end attached to it.

The easiest way to get started is by checking the code out via Subversion. This can be done with a tool like TortoiseSVN or any number of others. AnkhSVN is a good plugin that adds SVN support directly to Visual Studio. If version control is not your thing, you can just click the download button from the Source Code page.

Hope that helps,
Runewake2

over 10 years ago

How do i input acheivements?

over 10 years ago

Hello, there is documentation about Awarding (and Fetching Trophies) on the Documentation page here (https://gamejolttrophies.codeplex.com/wikipage?title=Trophies&referringTitle=Documentation). If that isn't enough information I can throw together a quick code sample for you.

Last modified on May 28, 2015 by runewake2 @runewake2

about 10 years ago

Hi Runewake,

i've done some reading up on the API and i would love to implement it in my game. The problem is however, that i have never accessed any API at all (i am fairly new at programming). I would love to go and discover whether i can make this happen, but could you please let me know in advance if what i want is at all possible?

My game is a download for windows. When people download and play it from their PC, can i access the API and grant users trophies? I can imagine this is not possible since the game does not know the user id when it is downloaded and being runned local.

So basically, my question is: is it at all possible to use the API in a downloadable game?

My game is created in C# / monogame.

Happy to hear from you.

about 10 years ago

Game Jolt's API uses the idea of a Username and private Token (different than your password). You access the API by logging in using these. It is perfectly fine to add Game Jolt trophies etc to an offline game.

To get started this is what you will need to do.

First, you will need a way for a user to login with their Game Jolt username and token.

Once you have their username and token you'll need to use these with the provided C# API to contact Game Jolt. Your users will need to be online for this to work.

Now that you've validated your users connection with Game Jolt you'll need to unlock the trophy by calling the appropriate methods in my library.

To make it clear, my library works by simply providing a layer between web communication and your game allowing you to talk to the Game Jolt server without having to construct the messages yourself.

Note also that you will need the Game Jolt API Key's in order to use the API. These are specific to each game.

about 10 years ago

Thanks a lot, i will look into it and see if i can make it work!

about 9 years ago

Amazing! This should really be on NuGet.

about 9 years ago
In response to %{ user }@rareshn

Glad it is helpful. I may have some news about this library in a few weeks, stay tuned. :D

over 8 years ago

Hello! I'm trying to test your system and everything seems to work otherwise, but when I get to the "Please enter an Achievement ID that you want to unlock or nothing to stop" part and enter my test achievements ID, it takes it, but when I go to my game's page on Game Jolt, I have not achieved the trophy. What am I doing wrong? Thanks.

over 8 years ago
In response to %{ user }@lclMetal

Can you see the http response from achieving the trophy? If so, what does it say?

over 8 years ago
In response to %{ user }@YLivay

No I can't. This is all I see when debugging JoltSharp (I replaced my IDs and keys with xs, don't want to show the actual values):

"Lets set things up, shall we?
Please enter your Game Jolt Game ID (this is found on your Game Dashboard under Manage Achievements)
xxxxxxxx
Please enter your Games Private Key (this is found on your Game Dashboard under Manage Achievements)
xxxxxxxx
Please enter your Game Jolt username
xxxxxxxx
Please enter your Game Jolt token
xxxxxxxx
Testing API as xxxxxxxx
Please enter an Achievement ID that you want to unlock or nothing to stop
xxxxxx
Please enter an Achievement ID that you want to unlock or nothing to stop

Press any key to continue . . ."

And afterwards when I check my game's page, I've not received the trophy. :/

over 8 years ago
In response to %{ user }@lclMetal

It's hard to see what the issue without seeing the actual http response. I'll have to take a look at the extension but I'm spread very thin atm with other issues ;-;

I ran some automated tests on the game api and it seems to be working. Any help from C# dabblers will be greatly appreciated in the meantime.

over 8 years ago
In response to %{ user }@YLivay

I don't know what I'm supposed to do in order to see the http response..? I'm quite new to C# and Visual Studio. Thanks for your efforts anyway! :)

over 8 years ago
In response to %{ user }@lclMetal

Yo. Try putting a break point on the line where you get the recieve and store the response. As far as I can tell this is in the BeginFetchResult method in the TrophyClient class. Line 189 as shown below.

string data = new StreamReader(request.EndGetResponse(result).GetResponseStream()).ReadToEnd();

Send another test request and it wait for the code to pause on that line. Step over it and then hover over data to see the Http response. I know nothing about this library but from what I can tell that's where you need to look.

Also looks like you can get the error message through an event called OnAchievementError You could try attaching an event handler to that and then print the message from the Event sender. Below is a small example. (I haven't tested it).

		
			private TrophyClient tc;

// Constructor
public TestAPI()
{
    tc = new TrophyClient();
    // Add a new delegate to event with reference to your handler.
    tc.OnAchievementComplete += new EventHandler(OnTrophyError);
}

// Your event handler
// Print the result of the error in here.
private void OnTrophyError(object sender, EventArgs e)
{
    string message = sender;
    Console.WriteLine("Achievement Error: {0}", message);
}
		
	

Hope this helps!

Last modified on February 20, 2017 by Dr. Bowen @ttbowen

over 8 years ago
In response to %{ user }@ttbowen

I was able to solve the problem. For some reason it was because I was not running Visual Studio as an admin. I started it with admin rights and it worked right away. Any idea why it does that? Anyway, thanks a lot for your time and helpful answers!

EDIT: Hmm, now it doesn't seem to work anymore even with admin rights on.. :/

Last modified on February 20, 2017 by lclMetal @lclMetal

over 8 years ago
In response to %{ user }@lclMetal

Did you try what I said above? Can you show us the HTTP response? Any exceptions being thrown at all?

Last modified on February 21, 2017 by Dr. Bowen @ttbowen

over 8 years ago
In response to %{ user }@ttbowen

I tried to do that but I didn't quite succeed. In fact, it seems that the code never goes to BeginFetchResult at all. Here's where it takes me if I follow it by debugging from line 42 in Program.cs.

Starting from Line 42 (Program.cs): tc.AchieveTrophy(input);
-> goes to AchieveTrophy() in TrophyClient.cs
-> goes to BeginAchievedResult() in TrophyClient.cs
-> goes to Signiture() in Settings.cs
-> goes back to BeginAchievedResult()
-> goes to StartConnection() in NetworkAccess.cs
-> goes back to BeginAchievedResult()
-> goes back to AchieveTrophy()
-> goes back to the do while loop in Program.cs for testing for new trophies to achieve, from there I can only either enter back to that same cycle or to exit.

I don't know where I should put the code you suggested me to try. :/

Thank you so much for trying to help me.

over 8 years ago
In response to %{ user }@lclMetal

Ahh yeah I put the wrong method name. It's actually EndAchievedResult my bad. The breakpoint still goes on this line:
string data = new StreamReader(request.EndGetResponse(result).GetResponseStream()).ReadToEnd(); as this is where the response is read.

As for the example, you can put in program.cs. (I take it you're using the JoltSharp example). Below is the code.

		
			    class Program
    {
        static TrophyClient tc;
        static UserClient uc;
        static SessionClient sc;

    static void TrophyErrorHandler(object sender, EventArgs e)
    {
        string message = sender;
    Console.WriteLine("Achievement Error: {0}", message);
    }

        static void Main(string[] args)
        {

            Console.WriteLine("Lets set things up, shall we?");
            Console.WriteLine("Please enter your Game Jolt Game ID (this is found on your Game Dashboard under Manage Achievements)");
            Settings.GameID = Console.ReadLine();
            Console.WriteLine("Please enter your Games Private Key (this is found on your Game Dashboard under Manage Achievements)");
            Settings.GameKey = Console.ReadLine();
            Console.WriteLine("Please enter your Game Jolt username");
            Settings.Username = Console.ReadLine();
            Console.WriteLine("Please enter your Game Jolt token");
            Settings.Token = Console.ReadLine();

            Console.WriteLine("Testing API as " + Settings.Username);

            tc = new TrophyClient();
            uc = new UserClient();
            sc = new SessionClient();
            sc.AutomaticallyPing = true;
            // Add the event handler
            tc.OnAchievementError += new EventHandler(onTrophyError);

            string input;
            do
            {
                Console.WriteLine("Please enter an Achievement ID that you want to unlock or nothing to stop");
                input = Console.ReadLine();
                if (!input.Trim().Equals(""))
                    tc.AchieveTrophy(input);
            } while ( !input.Trim().Equals(""));

            Console.Read();
        }

    }
		
	
over 8 years ago
In response to %{ user }@ttbowen

Thanks for replying again! I did what you suggested but the problem is that the execution never goes to the line where I put the breakpoint. The program never even enters EndAchievedResult. From the only line I see it somehow could go there (line 176 in TrophyClient.cs) it just goes to the end of BeginAchievedResult and then returns to the method that called it etc.

Thanks for your patience and efforts, I appreciate it really much!

over 7 years ago

That's too bad. Codeplex is shutting down (and shutted down already, you can only see archives). @runewake2 must remake his C# API in GitHub.


Wait. Am I too late? Over 5 years ago? Oh damn, that's pretty long! Sorry about that! I just wanted to notify you.

over 7 years ago

Well, I downloaded this archive, but my browser went into virus alarm. I doubt these files were harmful (they are nothing more but source codes), but maybe it had to do something with codeplex. Never the less I've been able to get a zip file with the API from it and it appears to be virus clean.

Here is the sourcecode of the C# API, however this is only the source code without documentation, whatsoever. I am not well-versed in C#, so if somebody can use these, be my guest ;)