Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Top 10 guild website script

Joined
May 23, 2008
Messages
1,071
Reaction score
574
Hello all, I am here to release a partially tested script, so any bugs, glitches, questions, or suggestions, please feel free to post.

This script requires the following
A table in GameDB named GuildRanking
This table must have the following columns:
GuildId (Data Type: int)
ReputationTotal (Data Type: bigint)
GuildName (Data Type: varchar(50))

Also, add a new column to the GuildMember table:
Reputation (Data Type: bigint)


Here is the script, save it as guildranking.php:
Code:
<?PHP
//--Credits to Untamed AKA Timebomb & Cabal Frontier--\\
$sql_server = "localhost"; //<-- MSSQL server address/ip
$sql_user = "USER"; //<-- MSSQL username
$sql_pass = "PASS"; //<-- MSSQL password
$sql_data = "gamedb"; //<-- MSSQL database
$conn=mssql_connect($sql_server,$sql_user,$sql_pass);
$xadb = mssql_select_db($sql_data,$conn);

$guild1 = mssql_query("select [GuildNo],[GuildName] from [dbo].[Guild]");
do {
while ($guild = mssql_fetch_array($guild1)){
$guildstuff = $guild['GuildNo'];
$guildname = $guild['GuildName'];
$charidx = mssql_query("Select CharacterIndex from dbo.GuildMember where GuildNo = '$guildstuff'");
do {
while ($charidxx = mssql_fetch_array($charidx)) {
$charhonor = mssql_query("Select Reputation from dbo.cabal_character_table where CharacterIdx = '$charidxx[CharacterIndex]'");
$charhonorx = mssql_fetch_row($charhonor);
$getrep = $charhonorx[0];
mssql_query("UPDATE dbo.GuildMember set Reputation = '$getrep' where CharacterIndex = '$charidxx[CharacterIndex]'");
}
} while(mssql_next_result($charidx));
$dorepstuff = mssql_query("SELECT top 10 Reputation from dbo.GuildMember where GuildNo = '$guildstuff' order by reputation desc");
$reputation = 0;
do {
while ($dorepmain = mssql_fetch_array($dorepstuff)){
$reputation = $reputation + $dorepmain['Reputation'];
}
} while(mssql_next_result($dorepstuff));
$test1 = mssql_query("select * from dbo.GuildRanking where GuildId = '$guildstuff'");
$test2 = mssql_num_rows($test1);
if ($test2 < 1) {
mssql_query("INSERT INTO dbo.GuildRanking(ReputationTotal,GuildName,GuildId) VALUES ('$reputation','$guildname','$guildstuff')");
} elseif ($test2 == 1) {
mssql_query("UPDATE dbo.GuildRanking SET ReputationTotal = '$reputation' where GuildId = '$guildstuff'");
mssql_query("UPDATE dbo.GuildRanking SET GuildName = '$guildname' where GuildId = '$guildstuff'");
}

}
} while (mssql_next_result($guild1));
echo '<center><b>Top 10 Guilds:</b><p>';
$selectguild = mssql_query("select top 10 * from dbo.GuildRanking where GuildName <> 'STAFF'  order by ReputationTotal DESC");
$i = 1;
do {
while ($getguild = mssql_fetch_array($selectguild)){
echo '#'.$i.')  <i>'.$getguild[GuildName].'</i><br>';
$i = $i + 1;
}
} while (mssql_next_result($selectguild));

mssql_free_result($guild1);
mssql_free_result($charhonor);
mssql_free_result($selectguild);
mssql_free_result($dorepstuff);
mssql_close($conn);
?>

I have somewhat tested guilds ingame to make sure the table edit didn't screw anything up. It hasn't appeared to, which is good. I have also tested the script a bit, so it should work.
Near the end of the script, change 'STAFF' to your GM guild name, to keep it off the rankings.

How does this calculate rankings?
It first calculates all the members in a guild.
Then, it finds the top 10 players in that guild. How does it calculate that? It's pretty simple... the top player is the one that has the most reputation, or honor, in the guild.
It adds all 10 of those player's honor together, and that is their Reputation score. It compares that to all other guilds, and then makes a ranking off it.

Please note that this isn't the most highly optimized script ;)
 
Last edited:
Newbie Spellweaver
Joined
Oct 8, 2009
Messages
30
Reaction score
0
Warning: mssql_free_result(): supplied argument is not a valid MS SQL-result resourc
 
Junior Spellweaver
Joined
Jan 10, 2009
Messages
172
Reaction score
25
Top 10 Guilds:


Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'dbo.GuildRanking'. (severity 16) in C:\AppServ\www\Cabal\guilds.php on line 52

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\Cabal\guilds.php on line 52

Warning: mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\Cabal\guilds.php on line 55

Warning: mssql_next_result(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\Cabal\guilds.php on line 59

Warning: mssql_free_result(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\Cabal\guilds.php on line 62

Warning: mssql_free_result(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\Cabal\guilds.php on line 63

Warning: mssql_free_result(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\Cabal\guilds.php on line 64
 
Elite Diviner
Joined
Feb 12, 2008
Messages
439
Reaction score
175
This script requires the following
A table in GameDB named GuildRanking
This table must have the following columns:
GuildId (Data Type: int)
ReputationTotal (Data Type: bigint)
GuildName (Data Type: varchar(50))

Also, add a new column to the GuildMember table:
Reputation (Data Type: bigint)

very difficult to read?

MSSQL QUERY:

Code:
use GameDB;
 
CREATE TABLE [dbo].[GuildRanking](  
	[GuildId] [int] NULL,
	[ReputationTotal] [bigint] NULL,
	[GuildName] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL )


ALTER TABLE [dbo].[GuildMember]
ADD [Reputation] [bigint] NULL
 
Last edited:
Junior Spellweaver
Joined
Jan 10, 2009
Messages
172
Reaction score
25
other error pls help-me

my webpage :

i click in the guild name to view the members ....

and open this page :



and this error

The requested URL /cabal/guilds.php was not found on this server.

pls give-me the guilds.php to loading the guild status ? pls help-me
 
Elite Diviner
Joined
Feb 12, 2008
Messages
439
Reaction score
175
other error pls help-me

my webpage :

i click in the guild name to view the members ....

and open this page :



and this error

The requested URL /cabal/guilds.php was not found on this server.

pls give-me the guilds.php to loading the guild status ? pls help-me

localhost? lol man, post image of error.
 
Last edited:
Junior Spellweaver
Joined
Jan 10, 2009
Messages
172
Reaction score
25
i saved the script with the name " guildsranking " and change to guilds.php and now is the error .

TimeBomb - Top 10 guild website script - RaGEZONE Forums
 
Back
Top