Welcome to RaGEZONE - MMORPG Development Forums (sponsored by tfn.gr) Mark forums read | View Forum Leaders
RaGEZONE - MMORPG Development Forums (sponsored by tfn.gr)

Knight Releases Discuss, [Share] [PHP][KO Panel] Nation Transfer Script (SNOXDKO) at Knight Online forum; Ok reading the whole topic again refreshed my mind.. Heres how the script looks now after some edits.. Code: <?php ...




Reply
Thread Tools
[Share] [PHP][KO Panel] Nation Transfer Script (SNOXDKO)
 
 
Retired OurKO Hoster

Rank: (E)Subscriber


Reply With Quote
 
Join Date: Aug 2007
Location: In My Room
Posts: 210
07-13-2008, 07:29 PM
 
Ok reading the whole topic again refreshed my mind..

Heres how the script looks now after some edits..


Code:
<?php

include('./anti_inject.php');

parth1tr();
parth1('100%', 2, 'center');
echo 'Nation Transfer - Beta - by BlaDe @ Snoxd.net';
parth2();
parth2tr();

if (isset($_SESSION['sesuser'])) {
    if ($_GET['Confirmed'] == 1) {
        $connect = odbc_connect("$dbname", "$dbuser", "$dbpass");
        $query = "SELECT strCharID1, strCharID2, strCharID3 FROM Account_Char WHERE strAccountID ='" . $_SESSION['sesuser'] . "' ";
        $results = odbc_exec($connect, $query); 
        // Store all char names in var's.....
        while (odbc_fetch_row($results)) {
            $char1 = odbc_result($results, 1);
            $char2 = odbc_result($results, 2);
            $char3 = odbc_result($results, 3);
        } 
        // Confirm they have a character
        if ((empty($char1)) && (empty($char2)) && (empty($char3))) {
            part1('100%', 1, 1, 'center');
            echo '</br>Your not part of a Nation, how do you expect to change it?';
            echo '</br></br><a href="./index.php">Back</a></br>';
            part2();
        } else {
            // Confirm none of the chars are logged in..
            // Updated during the for loop

            $query = "SELECT count(strCharID) FROM CURRENTUSER WHERE strCharID = '" . $char1 . "' OR strCharID = '" . $char2 . "' OR strCharID = '" . $char3 . "'";
            $results = odbc_exec($connect, $query);
            while (odbc_fetch_row($results)) {
                $online = odbc_result($results, 1);
            } 
              if (strlen(trim($online != 0)) > 0) {
                part1('100%', 1, 1, 'center');
                echo '</br>All characters must be logged out of the game first!';
                echo '</br></br><a href="./index.php">Back</a></br>';
                part2();
                die();
            } 
            // Check they aren't in a clan on any of 3 characters.
            
            $query = "SELECT count(Knights) FROM USERDATA WHERE strUserID = '" . $char1 . "' OR strUserID = '" . $char2 . "' OR strUserID = '" . $char3 . "'";
            $results = odbc_exec($connect, $query);
            while (odbc_fetch_row($results)) {
                $knights = odbc_result($results, 1);
            } 
            if (trim($Knights) > 0) {
                part1('100%', 1, 1, 'center');
                echo '</br>All characters on account have to be clanless.';
                echo '</br></br><a href="./index.php">Back</a></br>';
                part2();
                die();
            } 
            $query = "SELECT COUNT(*) FROM NT_LOG WHERE DATEDIFF(Hour,[Date],GETDATE()) < 48 AND Account = '" . $_SESSION['sesuser'] . "'";
            $results = odbc_exec($connect, $query);
            while (odbc_fetch_row($results)) {
                $logcheck = odbc_result($results, 1);
            } 
            if ($logcheck > 0) {
                part1('100%', 1, 1, 'center');
                echo '</br>You may only use this feature once every 48hours.';
                echo '</br></br><a href="./index.php">Back</a></br>';
                part2();
                die();
            } else {
                // Get the nation and calculate desired nation
                $query = "SELECT strAccountID, bNation FROM ACCOUNT_CHAR WHERE strAccountID = '" . $_SESSION['sesuser'] . "'";
                $results = odbc_exec($connect, $query);
                while (odbc_fetch_row($results)) {
                    $nation = odbc_result($results, 2);
                } 
                if ($nation == 1) $desiredNation = 2;
                if ($nation == 2) $desiredNation = 1; 
                // Test 1
                $check1 = odbc_exec($connect, "SELECT COUNT(*) FROM USERDATA WHERE Nation='" . $desiredNation . "'");
                $check2 = odbc_exec($connect, "SELECT COUNT(*) FROM USERDATA");

                $tot1 = odbc_result ($check1, 1);
                $tot2 = odbc_result($check2, 1);
                if ($tot1 / $tot2 > 0.6) {
                    part1('100%', 1, 1, 'center');
                    echo '</br>Sorry your desired nation has too many users.';
                    echo '</br>The desired population must be less than 60% Population!';
                    echo '</br></br><a href="./index.php">Back</a></br>';
                    part2();
                    die();
                } 
                // Test 2
                $check3 = odbc_exec($connect, "SELECT SUM(Loyalty) AS nps FROM USERDATA WHERE Nation='" . $desiredNation . "'");
                $check4 = odbc_exec($connect, "SELECT SUM(Loyalty) AS totnps FROM USERDATA");
                $nps = odbc_result_all($check3);
                $totnps = odbc_result_all($check4);
                if ($nps / $totnps > 0.575) {
                    part1('100%', 1, 1, 'center');
                    echo '</br>Sorry your desired nation has too many National Points.';
                    echo '</br>The desired population must be less than 57% total National Points!';
                    echo '</br></br><a href="./index.php">Back</a></br>';
                    part2();
                    die();
                } else {
                    // Calculate the newrace + class of the characters..
                    foreach (array($char1, $char2, $char3) as $char) {
                        if ($char != "") {
                        $getuser = "SELECT strCharID FROM CURRENTUSER where strCharID = '" . $char . "'";
                        $getusere = odbc_exec($connect, $getuser);
                        $characterID = odbc_result($getusere, 1);

                        if (strlen(trim($characterID)) > 0) {
                        $killed = 1;
                        KillUserAndWait(trim($characterID), $connect);
                         } 
                            $query = "SELECT strUserID, Race, Class FROM USERDATA WHERE strUserID = '" . $char . "'";
                            $results = odbc_exec($connect, $query);
                            while (odbc_fetch_row($results)) {
                                $race = odbc_result($results, 2);
                                $class = odbc_result($results, 3);
                            } 

                            if ($race < 12) {
                                $hashmap = array (1 => 11, 2 => 12, 3 => 13, 4 => 13, 11 => 1);
                                $NewRace = $hashmap[$race];
                            } elseif (($race == 12) || ($race == 13) || ($race == 14)) {
                                if ($class == 201) $NewRace = 1;
                                elseif ($class == 202) $NewRace = 2;
                                elseif ($class == 203) $NewRace = 3;
                                elseif ($class == 204) $NewRace = 4;
                                elseif ($class == 205) $NewRace = 1;
                                elseif ($class == 207) $NewRace = 2;
                                elseif ($class == 209) $NewRace = 3;
                                elseif ($class == 211) $NewRace = 4;
                            } 
                            if ($class >= 199) {
                                $NewClass = $class - 100;
                            } else {
                                $NewClass = $class + 100;
                            } 
                            if (($NewRace == '') || ($NewClass == '')) {
                                part1('100%', 1, 1, 'center');
                                echo 'Error: (Char: ' . $char . ')</br> New Class:';
                                echo $NewClass;
                                echo '</br> New Race:';
                                echo $NewRace;
                                echo '</br> Old Class:';
                                echo $class;
                                echo '</br> Old Race:';
                                echo $race;
                                echo '</br></br><a href="./index.php">Back</a></br>';
                                part2();
                                die();
                            } 
                            $query = "UPDATE USERDATA SET Nation = '" . $desiredNation . "', Race = '" . $NewRace . "', Class = '" . $NewClass . "', Zone = 21, PX = 33550, PZ = 38400, PY = 0 WHERE strUserID = '" . $char . "'";
                            $results = odbc_exec($connect, $query);
                        } 
                    } 
                    $query = "INSERT INTO NT_LOG([Date], Account, Char1, Char2, Char3, NationTo) VALUES (GETDATE(), '" . $_SESSION['sesuser'] . "', '" . $char1 . "', '" . $char2 . "', '" . $char3 . "', '" . $desiredNation . "')";
                    $results = odbc_exec($connect, $query);
                    $query = "UPDATE ACCOUNT_CHAR SET bNation = '" . $desiredNation . "' WHERE strAccountID = '" . $_SESSION['sesuser'] . "'";
                    $results = odbc_exec($connect, $query);
                } 
                // Done
                part1tr();
                part1('100%', 1, 1, 'center');
                echo 'Done';
echo '</br></br><a href="./index.php">Back</a>';
                if ($killed == 1) { echo '</br>A character was disconnected during this process'; }
                part2();
                part2tr();
            } 
        } 
    } else {
        part1tr();
        part1('25%', 1, 1, 'center');
        echo 'Please confirm your transfer:</br></br></br>
        <li>You must be <b>logged out</b> of <b>all</b> characters</li>
        <li>You must be <b>Clanless</b> on <b>all</b> characters</li>
        <li>You may only use this feature <b>once</b> every 48hours</li>
        <li>The Desired Nation must be <b>Less Than</b> 60% Total Population </li>
        <li>The Desired Nation must be <b>Less Than</b> 57.5% Total National Points</li></br></br>
        <FORM method=post name=confirm action=index.php?act=NationTransfer&Confirmed=1>
            <input class="input" type="submit" value="Confirm">
            </form>';
        part2();
        part2tr();
    } 
} else {
    part1('100%', 1, 1, 'center');
    echo 'You must login first!';
    part2();
} 

?>

But I think there is a bug with 'Sorry your desired nation has too many National Points.
The desired population must be less than 57% total National Points!'

I tried it for both nations and get this message all the time..
 
 
permalink
 

 
Member

Rank: Omicron


Reply With Quote
 
Join Date: Oct 2006
Posts: 32
07-13-2008, 09:51 PM
 
if (strlen(trim($online)) > 0) {
part1('100%', 1, 1, 'center');
echo
'</br>All characters must be logged out of the game first!';
echo
'</br></br><a href="./index.php">Back</a></br>';
part2();
die();

im a complete noob with php right now but shouldnt that line be

if (strlen(trim($online)) > 1) {

????? wouldnt that fix the all characters must be logged out thing??

 
 
permalink
 

 
Retired OurKO Hoster

Rank: (E)Subscriber


Reply With Quote
 
Join Date: Aug 2007
Location: In My Room
Posts: 210
07-15-2008, 01:50 PM
 
Quote: Originally Posted by bulldog0246 View Post
if (strlen(trim($online)) > 0) {
part1('100%', 1, 1, 'center');
echo
'</br>All characters must be logged out of the game first!';
echo
'</br></br><a href="./index.php">Back</a></br>';
part2();
die();

im a complete noob with php right now but shouldnt that line be

if (strlen(trim($online)) > 1) {

????? wouldnt that fix the all characters must be logged out thing??

I got past that bit already, but im getting this for both nations..

Quote:
'Sorry your desired nation has too many National Points.
The desired population must be less than 57% total National Points!'
 
 
permalink
 

 
Average Member

Rank: Omicron


Reply With Quote
 
Join Date: Dec 2006
Posts: 64
11-10-2008, 04:47 PM
 
Quote: Originally Posted by lollipop07 View Post
I got past that bit already, but im getting this for both nations..
Apologies to bump an old topic, someone asked me about it on MSN. That isn't a bug - you can change the values if you want but I implemented those fail safes to stop imbalanced nation transfers.
 
 
permalink
 

Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT +1. The time now is 02:15 AM.
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RaGEZONE © 2001 - 2008





 
Evade Blackbelt School