RZA-PT | KilroyPT
- Joined
- Aug 27, 2007
- Messages
- 936
- Reaction score
- 85
A fore-word. This is not to detract from HappyHardcores listing of codes, which for the most part is still pretty accurate for what the codes mean.
This guide will help you diagnose any issues you may have with your clan system.
The one code you'll come across which this won't help with is Error(65) when creating a clan.
This code is thrown when you successfully create a clan but there is no clan image. (This is why i made my clan files automatically create the image upon creating the clan).
Prerequisite: You do need to understand and be able to troubleshoot the code in the clan files. (or at least read them...)
So you can understand what you're looking at, the database structure is important to know.
You have 4 tables in the ClanDB database:
What do these tables do?
The number gets incremented by the clan creation script.
There is also a column called "Permi" this is set to "2" for the clan subchief.
and finally.
When ever you do anything with the clan it passes the SNo value through. So when diagnosing the files, it is imperative that you leave your character in game so the CT entry exists.
Now for the diagnosing.
I'm using PHP files (because ASP can eat a bag of di#ks) and IIS (because why run apache on windows when IIS can do everything...)
IIS stores the logs in 'C:\inetpub\logs\LogFiles\W3SVC#' (where # is for the instance of the webserver, the default/first is w3svc1).
A typical entry for the log is like this:
The breakdown is like this:
<Date/time of the request> <Local IP/hostname> <Method> <Request URI> <Query String (URL encoded)> <port> - <remote IP> <application name> - <response code>
For those that do not understand url / http requests;
So what we want from this is the request uri (page requested) and the query string.
So, that's great, how do we use this to diagnose it?
What we want to do is log the character in and talk to clan master to fire off a few requests (note that every time you get near a character it fires off a "isclanmember" check for each characters around you).
Pull the log entry. and stitch it back together (put the ? back in). To use our query above:
Lets paste this into the browser on our server, using localhost as the hostname
now my clan files are working so i get the expected result:
However, if your clan files are spitting errors. you'll get error codes:
lets say I forget to put the query string on my check.
"http://localhost/ServerMain/isClanMember.php" (i leave out everything after the request URI)
The webpage returns: "Code=100"
So what do I do?
I open the script and look for that code:
What does this mean? well. in this case, it doesnt have the char name, gserver nor the userid. (so basically, how the hell is this script supposed to check if a char is a clan member if you haven't specified the charname????????) also, just to confuse you, my scripts will return code=100 if they cannot connect to the database too. *evil laughs*
"So how do I use this in a more pertinent way given the game will "almost" never not have the query string"
Lets use clanWonRelease.php (for when clan master is kicking people from the clan)
We see several code responses.
The obvious one is Code=1 (success!)
"Code=4" ? well thats less than helpful.
lets look at the code around it:
Where clwon1 is the character you wish to kick, its checking if its the clan leader. if it is, stop the script and return the error code. (you can't kick the clan leader)
A lot of the code has been written to be as clear as possible.
but if you spend enough time staring at it whilst sucking your thumb it will make sense.
(It checks if the char is actually in a clan, if not, returns code=01, if the char is in a clan but its not the clan sent in the request, code=02.
When i can be assed to get photos and attach them i'll tidy this up. but hopefully this helps people self diagnose the issues a bit more before they badger me or others for help.
This guide will help you diagnose any issues you may have with your clan system.
The one code you'll come across which this won't help with is Error(65) when creating a clan.
This code is thrown when you successfully create a clan but there is no clan image. (This is why i made my clan files automatically create the image upon creating the clan).
Prerequisite: You do need to understand and be able to troubleshoot the code in the clan files. (or at least read them...)
So you can understand what you're looking at, the database structure is important to know.
You have 4 tables in the ClanDB database:
- LI
- CL
- UL
- CT
What do these tables do?
- LI
The number gets incremented by the clan creation script.
- CL
- UL
There is also a column called "Permi" this is set to "2" for the clan subchief.
and finally.
- CT
When ever you do anything with the clan it passes the SNo value through. So when diagnosing the files, it is imperative that you leave your character in game so the CT entry exists.
Now for the diagnosing.
I'm using PHP files (because ASP can eat a bag of di#ks) and IIS (because why run apache on windows when IIS can do everything...)
IIS stores the logs in 'C:\inetpub\logs\LogFiles\W3SVC#' (where # is for the instance of the webserver, the default/first is w3svc1).
A typical entry for the log is like this:
Code:
2019-09-25 13:41:41 192.168.100.200 GET /ServerMain/isClanMember.php userid=%61%73%68%69%6b%61%62%69&gserver=RZA-PT&chname=%54%65%73%74%43%68%61%72&ticket=467 80 - 192.168.100.140 AppName - 200 0 0 0
The breakdown is like this:
<Date/time of the request> <Local IP/hostname> <Method> <Request URI> <Query String (URL encoded)> <port> - <remote IP> <application name> - <response code>
For those that do not understand url / http requests;
- response code is your 200 (ok), 401 (unauthorised), 404 (not found), 500 (internal server error) , 300/301/302 (redirect)
- Method is how its requested (POST, GET, DELETE, PUT etc)
- hostname is the site (fqdn or ip, I.e. rzapt.com)
- Request URI is the page/script requested
- Query string is everything in the get request for parameters (everything after the "?"), this contains all the variables.
So what we want from this is the request uri (page requested) and the query string.
So, that's great, how do we use this to diagnose it?
What we want to do is log the character in and talk to clan master to fire off a few requests (note that every time you get near a character it fires off a "isclanmember" check for each characters around you).
Pull the log entry. and stitch it back together (put the ? back in). To use our query above:
Code:
/ServerMain/isClanMember.php?
Code:
userid=%61%73%68%69%6b%61%62%69&gserver=RZA-PT&chname=%54%65%73%74%43%68%61%72&ticket=467
Lets paste this into the browser on our server, using localhost as the hostname
Code:
http://localhost[SIZE=4][SIZE=2]/ServerMain/isClanMember.php?[/SIZE][/SIZE]userid=%61%73%68%69%6b%61%62%69&gserver=RZA-PT&chname=%54%65%73%74%43%68%61%72&ticket=467
now my clan files are working so i get the expected result:
Code:
[COLOR=#000000]Code=0 CMoney=500000 CNFlag=0[/COLOR]
However, if your clan files are spitting errors. you'll get error codes:
lets say I forget to put the query string on my check.
"http://localhost/ServerMain/isClanMember.php" (i leave out everything after the request URI)
The webpage returns: "Code=100"
So what do I do?
I open the script and look for that code:
Code:
if($userid == "" || $gserver == "" || $chname == "")
{
print "Code=100".$CR;
$dbconn = null;
die;
}
What does this mean? well. in this case, it doesnt have the char name, gserver nor the userid. (so basically, how the hell is this script supposed to check if a char is a clan member if you haven't specified the charname????????) also, just to confuse you, my scripts will return code=100 if they cannot connect to the database too. *evil laughs*
"So how do I use this in a more pertinent way given the game will "almost" never not have the query string"
Lets use clanWonRelease.php (for when clan master is kicking people from the clan)
Code:
/* Stop script if one or more of the variables are not set. */
if ($userid == "" || $gserver == "" || (empty($clwon1) || $clwon1 == "") || $chname == "" || $ticket == "" || $clName == "")
{
print("Code=100$CR");
$dbconn = null;
die();
}
if (is_array($clwon1))
{
foreach ($clwon1 as $clwon)
{
clankick($clwon);
}
}
else
{
clankick($clwon1);
}
$dbconn = null;
/** Kick method, will stop on errors for any of the members being kicked. **/
function clankick($clwon1)
{
global $dbconn, $userid, $gserver, $chname, $ticket, $clName, $CR;
$query = "SELECT ClanName
FROM ClanDB.dbo.UL
WHERE ChName='$clwon1'";
$stmt = $dbconn->prepare($query);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if (!empty($result))
{
$clName2 = $result['ClanName'];
if ($clName2 == "")
{
$query = "DELETE
FROM ClanDB.dbo.UL
WHERE ChName='$clwon1'";
$stmt = $dbconn->prepare($query);
$stmt->execute();
$dbconn = null;
die("Code=01$CR");
}
if ($clName2 != $clName)
{
$dbconn = null;
die("Code=02$CR");
}
}
else
{
$dbconn = null;
die("Code=0$CR");
}
$query = "SELECT ClanZang,MemCnt
FROM ClanDB.dbo.CL
WHERE ClanName='$clName'";
$stmt = $dbconn->prepare($query);
$stmt->execute();
$results = $stmt->fetch(PDO::FETCH_ASSOC);
$ClanLeader = $results['ClanZang'];
$ClanMembers = $results['MemCnt'];
$ClanMembers = $ClanMembers - 1;
if ($clwon1 == $ClanLeader)
{
$dbconn = null;
die("Code=4$CR");
}
$query = "UPDATE ClanDB.dbo.CL
SET MemCnt='$ClanMembers'
WHERE ClanName='$clName';
DELETE
FROM ClanDB.dbo.UL
WHERE ChName='$clwon1';";
$stmt = $dbconn->prepare($query);
$stmt->execute();
print("Code=1$CR");
}
We see several code responses.
The obvious one is Code=1 (success!)
"Code=4" ? well thats less than helpful.
lets look at the code around it:
Code:
if ($clwon1 == $ClanLeader)
{
$dbconn = null;
die("Code=4$CR");
}
Where clwon1 is the character you wish to kick, its checking if its the clan leader. if it is, stop the script and return the error code. (you can't kick the clan leader)
A lot of the code has been written to be as clear as possible.
but if you spend enough time staring at it whilst sucking your thumb it will make sense.
(It checks if the char is actually in a clan, if not, returns code=01, if the char is in a clan but its not the clan sent in the request, code=02.
When i can be assed to get photos and attach them i'll tidy this up. but hopefully this helps people self diagnose the issues a bit more before they badger me or others for help.
Last edited: