Jump to content
cachaFloja

[GUIDE]KOP-Launcher

Recommended Posts

Hi,

 

I made a kind of guide to configure Patrick13's launcher, I don't know if there are new people but I'm going to post it :p

 

IMPORTANT

I don't know how this works so this is just one way to make it work but it is not the best way.

 

 

API: Download

Launcher:


1-Configure API

Spoiler

 

I- Download API, go to the web folder of your server, create a folder called API and paste the files, like this:

 

spacer.png

 

II- Edit config.php with your info


<?php
$db = [
    'host' => 'HOSTDB',
    'username' => 'USERDB',
    'password' => 'PASSDB',
    'accountserver' => 'AccountServer',
    'gamedb' => 'GameDB',
    'portGate' => '1971'
];
?>

III- Edit update.xml


<ListUpdate>
        <Update>
            <FileURL></FileURL>
            <FileMirror></FileMirror>
      <Version>1.0.0.0</Version>
        </Update>
</ListUpdate>

The first version of the client is 1.0.0.0 then to start downloading you must start from 1.0.0.1 onwards, just add a download like this:

Spoiler



<ListUpdate>
         <Update>
            <FileURL></FileURL>
            <FileMirror></FileMirror>
            <Version>1.0.0.0</Version>
        </Update>

        <Update>
            <FileURL>http://urltomyfile.com/downloads/patch1001.zip</FileURL>
            <FileMirror>http://mirror.urltomyfile.com/downloads/patch1001.zip</FileMirror>
            <Version>1.0.0.1</Version>
        </Update>
</ListUpdate>

 


 

 

2.-Create TABLE for version

Spoiler

 

I.- Open SQL Server Management and connect to your databases

Go to Databases>GameDB>Right click>New Query copy and paste


CREATE TABLE Launcher (idPatch INT NOT NULL PRIMARY KEY IDENTITY, versionPatch VARCHAR(10) NOT NULL)

Press F5, refresh Databases o re-connect to load your new table.

Go to Databases>GameDB>Tables>Launcher>Right click>Edit  and add a new patch.

 

spacer.png

 

Press Enter and F5

Now you can go to your URL and test, example: http://mySuperSVR.com/api/statistics.php

Should load something like this:

spacer.png

 

 

3.-Configure PKO-Launcher

Spoiler

 

I.- Download PKO-Launcher, open Visual Studio (i use 2019 community)

Open Properties>Resource.resx

 

spacer.png

 

You must add StatusUrl 

4.png

 

II.-Find GetIPByServer in Globals.cs

Change NAMEISLAND and IPHERE


public static string GetIpByServer ( string server )
        {
            string ip;

            var morganRegions = new List<string> { "" };
            
            switch ( server )
            {
                case string external when external.ToLowerInvariant (  ).Contains ( "NAMEISLAND" ):
                    ip = Task.Run(async () => await GetBestServer(morganRegions, "")).Result;
                    break;
                default:
                    ip = "IPHERE";
                    break;
            }

            return ip;
        }

III.-Find PopulateRegion in Utils.cs

Put the same region


public static bool PopulateRegion ( Guna2ComboBox control )
        {
            try
            {
                if ( control == null ) return false;

                control.Items.Add ( "NAMEISLAND" );
                control.SelectedItem = "Select Region";

                return true;
            }
            catch
            {
                return false;
            }
        }

IV.-Find UpdateServerStatistics in kopMainF.cs
Replace with this:

Spoiler



private async Task UpdateServerStatistics()
        {
            bool online = false;
            try
            {
                await Task.Run ( () =>
                {
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                    ServicePointManager.DefaultConnectionLimit = 20;

                    using (var wc = new WebClient ( ))
                    {
                        wc.Proxy = null;

                        var json = wc.DownloadString(Resources.StatisticsURL.ToString()); ;
                        var jsonS = wc.DownloadString (Resources.StatusUrl.ToString());
                        JArray data = JArray.Parse (json);
                        online = bool.Parse(jsonS);                 

                        foreach (JObject item in data)
                        {
                            SetControlThreadSafe(label7, arg => { label7.Text = item.GetValue("accounts").ToString(); }, null);         //total account
                            SetControlThreadSafe(label9, arg => { label9.Text = item.GetValue("characters").ToString(); }, null);       //total character
                            SetControlThreadSafe(label6, arg => { label6.Text = item.GetValue("online").ToString(); }, null);           //current online
                            SetControlThreadSafe(label15, arg => { label15.Text = item.GetValue("max_online").ToString(); }, null);     // <.< idk

                            _gameVersion = item.GetValue("version").ToString();
                        }

                        string hashes = "9BkAxPDlBSDhb13b73HFKFOl915sD";
                        var contents = hashes.Split ( new[] {Resources.StatHashSumDelimiter}, StringSplitOptions.None );

                        foreach (var hash in contents)
                            if ( !string.IsNullOrEmpty ( hash ) )
                                Globals.GenuineResourceHashes.Add ( hash );

                        if (online != false)
                            SetControlThreadSafe ( label11, arg => { label11.Text = "Online"; }, null );                                 //server status
                        else

                            SetControlThreadSafe ( label11, arg =>
                            {
                                label11.ForeColor = Color.DarkRed;
                                label11.Text = "Offline";
                            }, null );
                    }
                } );
            }
            catch
            {
                // ignored
            }
        }

 


 

Done!!

 

spacer.png

 

*Use ZIP for patchs

 

 

 NOTE:

Spoiler

In Statistics.php we have this query:


$sql = $dbConn->prepare('SELECT (SELECT COUNT(*) FROM character WHERE delflag=0)  as characters, (SELECT COUNT(*) FROM character WHERE mem_addr>0) AS online, (SELECT COUNT(*) FROM account) AS accounts, (SELECT COUNT(DISTINCT last_ip) FROM account) as users, (SELECT MAX(login_num) FROM stat_log) as max_online, (SELECT MAX(versionPatch) FROM Launcher) as version');

the only change is this in the end


(SELECT MAX(versionPatch) FROM Launcher) as version')

In ServerStatus.php we have this to check connection


$fp = @fsockopen('tcp://' . $db['host'], $db['portGate'], $errno, $errstr, 3);

 

 

 

Credits

patrick13    Launcher
Icruz           API

Google Translate

 

PD: StatHashSumDelimeter must finish thisyou can add a new column in the table of Launcher with this parameter. 

  • Thanks 3

Share this post


Link to post
Share on other sites

@cachaFloja

Any idea why im having issue when trying to start the game through launcher? It wont open the game it keeps showing a window “trying to get updates” or something, everytime i click start game button

Share this post


Link to post
Share on other sites
2 hours ago, Rinor said:

@cachaFloja

Any idea why im having issue when trying to start the game through launcher? It wont open the game it keeps showing a window “trying to get updates” or something, everytime i click start game button

@patrick13 any ideas?


Share this post


Link to post
Share on other sites
11 minutes ago, V3ct0r said:

@patrick13 any ideas?

I can’t remember sorry, I’ve not worked on this project in a while, I can quickly read through the source code later to see what could be causing the issue.

  • Thanks 1

Share this post


Link to post
Share on other sites
23 hours ago, Rinor said:

@cachaFloja

Any idea why im having issue when trying to start the game through launcher? It wont open the game it keeps showing a window “trying to get updates” or something, everytime i click start game button

You can't start the game because of this statement:

if ( !string.IsNullOrEmpty ( _gameVersion ) )

If game version is null or empty, then it will show the following message:

Utils.ShowMessageA ( "Retrieving update information, please try again in a few seconds." );

To fix that, you either need to override this condition or add an API through which the latest game version can be retrieved (as per the tutorial above I believe). That is as can be seen in the method below: 

UpdateServerStatistics()

Which connects to the API using the following URL:

var json = wc.DownloadString ( Resources.StatisticsURL );

And retrieves the game version here:

 _gameVersion = data.version;

 

Hope that was helpful and good luck!

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Hello @Mario and @dragontechi,

 

make sure that you are using the latest revision of the source code. Because the code in the screenshot is different from the one in the project repository on GitHub.

  • Like 1

Share this post


Link to post
Share on other sites

As V3ct0r has already mentioned, it seems you are using an outdated version of the updater, so updating it might help. I also strongly encourage you to switch to this patcher instead, as it's more reliable:

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...