Jump to content

How to make the in-game shop (web browser) automatically login a player on your website


Recommended Posts

This is a little tutorial on how to connect the game to the item shop of your website.

By clicking on the coin in the game client the web browser will be opened and connected to your website.

I'll explain how to automatically login the player to the item shop :)

 

First of all open cmd_general.cpp and look for do_in_game_mall and replace the whole function with this

 


ACMD(do_in_game_mall)
{
		char buf[512+1];
		char sas[33];
		MD5_CTX ctx;

		const char secretKey[] = "my secret key"; // <<--- EDIT THIS!!!
		const char websiteUrl[] = "http://mywebsite/shop"; // <<--- EDIT THIS!!!

		snprintf(buf, sizeof(buf), "%u%s", ch->GetAID(), secretKey);

		MD5Init(&ctx);
		MD5Update(&ctx, (const unsigned char *) buf, strlen(buf));
#ifdef __FreeBSD__
		MD5End(&ctx, sas);
#else
		static const char hex[] = "0123456789abcdef";
		unsigned char digest[16];
		MD5Final(digest, &ctx);
		int i;
		for (i = 0; i < 16; ++i) {
			sas[i+i] = hex[digest[i] >> 4];
			sas[i+i+1] = hex[digest[i] & 0x0f];
		}
		sas[i+i] = '\0';
#endif

		snprintf(buf, sizeof(buf), "mall %s?aid=%u&secret=%s", websiteUrl, ch->GetAID(), sas);

		ch->ChatPacket(CHAT_TYPE_COMMAND, buf);
}

 

Edit secretKey and websiteUrl with your information. The key can be a random string.

 

What happens is the following:

  • aid = account id
  • secret = md5( account id + your secret key )

 

So your website you can check if the secret is corrent and then login the player. You can do something like this:

 

<?php

$secretKey = $_GET['secret'];
$accountId = $_GET['aid'];

$generatedSecret = md5($accountId . $secretKey);

if ($generatedSecret == $secretKey) {
    // ok, proceed with login
} else {
    // invalid secret
}

 

Edited by Cappuccino
  • Good 2
Link to post
  • Cappuccino changed the title to How to make the in-game shop (web browser) automatically login a player on your website

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.