|
You last visited: Today at 16:33
Advertisement
[RELEASE] both side chats
Discussion on [RELEASE] both side chats within the Shaiya PServer Guides & Releases forum part of the Shaiya Private Server category.
11/28/2010, 08:12
|
#1
|
elite*gold: 0
Join Date: May 2009
Posts: 32
Received Thanks: 39
|
[RELEASE] both side chats
This PHP script show both the chats, lights and darks, it also show every type of chats: PMs, trade, normal etc etc with the proper colours.
You can coustomize the refrash rate and the number of chat lines to show.
Select the whole code and save it into a whatevernameyouwant.php file
PS. ofc your ChatLog table on your server must work properly, or it wont show a thing.
PHP Code:
[code] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>Game Chats::</title> <style type="text/css"> </style>
<META NAME="Generator" CONTENT="Battle for Dwater"> <META NAME="Author" CONTENT="Battle for Dwater team"> </HEAD>
<BODY bgcolor=black >
<?php
//SECURE THE CONNECTION function sql_quote( $value ) { if( get_magic_quotes_gpc() ) { $value = stripslashes( $value ); } //check if this function exists if( function_exists( "mysql_real_escape_string" ) ) { $value = mysql_real_escape_string( $value ); } //for PHP version < 4.3.0 use addslashes else { $value = addslashes( $value ); } return $value; }
//AUTOREFRESH, $timer = 20 IS REFERED IN SECONDS $timer = 20; $gid = 1; $url = $_SERVER['PHP_SELF'].'?id='.$gid; Echo '<META HTTP-EQUIV="Refresh" CONTENT="'.$timer.'; URL='.$url.'" />';
//CHANGE IT WHIT YOUR IP, USER AND PASSWORD, MAKE SURE TO LEAVE THE " " !!! OR IT WONT WORK $IP="YOUR SERVER IP"; $USER="YOUR USER"; $PASS="YOUR PASSWORD";
// Connect to the server if (!$link = @mssql_connect("$IP","$USER","$PASS")) { print "Failed to connect to MSSQL server<br>"; };
// select PS_ChatLog if (!@mssql_select_db("PS_ChatLog",$link)) { print "Failed to select database<br>"; };
// select PS_GameData if (!@mssql_select_db("PS_GameData",$link)) { print "Failed to select database<br>"; };
date_default_timezone_set('EST');
echo "<center>";
echo "<br /><font size=5 face=arial color=white><b><i>Game Chat<br /></font>";echo"<i><font size=3 face=arial color=aaaaaa>";echo date('l jS \of F Y h:i:s A');echo" EST<br /></font></i>"; Echo " <small><font face=arial color=white>Self Refresh - $timer Secs</font></small><br/><br/></i></b>"; //Echo " <small><font face=arial size=2 color=white>Dont get what they say? <a href='http://www.wordreference.com'>wordreference.com</a> is your answer</font></small><br/><br/>";
echo " <table border=0 style='table-layout:fixed' cellpadding=3 cellspacing=0><col width=100> <tr> <tr> <td WIDTH=120 BGCOLOR=#222222><b><font size=2 face=arial color=white><b>Date</td> <td WIDTH=500 BGCOLOR=#111111><font size=2 face=arial color=white><b>Light</td> <td WIDTH=500 BGCOLOR=#222222><font size=2 face=arial color=white><b>Dark</td> </tr> <tr> </table>"; echo "<br />";
//SELECT THE LAST 50 LINES IN THE CHAT LOG TABLE $result = mssql_query("SELECT TOP 50 CharID, ChatType, TargetName, ChatData, ChatTime, MapID FROM [PS_ChatLog].[dbo].[ChatLog] ORDER BY ChatTime DESC", $link);
//ADDING THE PROPER COLOR AND TAG TO THE CHATS while($row = mssql_fetch_array($result)){ if($row[1]==1){ $chatcolor="<font size=1 face=arial color=white>";} else{ if($row[1]==2){ $chatcolor="<font size=1 face=arial color=ff374f>[Whisper]";} else{ if($row[1]==3){ $chatcolor="<font size=1 face=arial color=pink>[Guild]";} else{ if($row[1]==4){ $chatcolor="<font size=1 face=arial color=7affa0>[Party]";} else{ if($row[1]==5){ $chatcolor="<font size=1 face=arial color=fff669>[Trade]";} else{ if($row[1]==6){ $chatcolor="<font size=1 face=arial color=red>[Yelling]";} else{ if($row[1]==7){ $chatcolor="<font size=1 face=arial color=7800ff>[Area]";} } } } } } }
$date = "<font size=1 face=arial color=white>$row[4] ";
//ADDING NAMES AND DIVIDE LIGHTS FROM DARKS $light = mssql_query("SELECT CharID, CharName, Family FROM [PS_GameData].[dbo].[Chars] WHERE CharID = '$row[0]' AND Family <= 1", $link); $dark = mssql_query("SELECT CharID, CharName, Family FROM [PS_GameData].[dbo].[Chars] WHERE CharID = '$row[0]' AND Family >= 2", $link);
//ADDING THE NAME OF A PMer if($row[2] <> NULL){ $target="PM to $row[2]: ";} else{ $target="";}
//PRINTING LIGHTS AND DARKS CHATS echo" <table border=0 cellpadding=2 cellspacing=1> <tr> <tr>"; echo"<td WIDTH=120 BGCOLOR=#222222>"; echo "$date</td>"; echo"<td WIDTH=500 BGCOLOR=#111111>"; while ($row2 = mssql_fetch_array($light)){ echo "$chatcolor".$row2[1]." (map ".$row[5]."): ".$target."".$row[3]."</td>"; }
echo"<td WIDTH=500 BGCOLOR=#222222>"; while ($row3 = mssql_fetch_array($dark)){ echo "$chatcolor".$row3[1]." (map ".$row[5]."): ".$target."".$row[3]."</td>"; }
echo" </tr> <tr> </table>"; }
echo "</center>";
@mssql_free_result($result); @mssql_free_result($light); @mssql_free_result($dark);
mssql_close($link);
?> </BODY> </HTML>[/code]
EDIT: added [Area] chats
EDIT2: added [Yelling] chats
|
|
|
11/28/2010, 12:06
|
#2
|
elite*gold: 0
Join Date: Feb 2009
Posts: 31
Received Thanks: 22
|
thanks...
Good script
|
|
|
11/29/2010, 00:35
|
#3
|
elite*gold: 100
Join Date: Mar 2009
Posts: 552
Received Thanks: 1,003
|
im having an issue with it, after it gets to a certain point, it wont give me anymore chats, anyway to make it give me the recent chats only?
|
|
|
11/29/2010, 01:06
|
#4
|
elite*gold: 0
Join Date: May 2009
Posts: 32
Received Thanks: 39
|
it stop? wierd, im useing it on firefox and for now more than 24h and it never stop.
BTW it's already set to show the last 50 recents chat lines
|
|
|
11/29/2010, 01:10
|
#5
|
elite*gold: 0
Join Date: Feb 2009
Posts: 192
Received Thanks: 151
|
is there a way for GMs to see both trade chats... but in-game?
|
|
|
11/29/2010, 01:23
|
#6
|
elite*gold: 0
Join Date: May 2009
Posts: 32
Received Thanks: 39
|
Quote:
Originally Posted by GM.Triest
is there a way for GMs to see both trade chats... but in-game?
|
so far the answer is no
|
|
|
11/29/2010, 04:36
|
#7
|
elite*gold: 100
Join Date: Mar 2009
Posts: 552
Received Thanks: 1,003
|
Some of you might have to go to ur table right click, design and change the chattime to varchar(20) like myself, it was set to varchar(10) not recording the times
|
|
|
11/29/2010, 05:34
|
#8
|
elite*gold: 0
Join Date: May 2009
Posts: 32
Received Thanks: 39
|
Quote:
Originally Posted by AriezOMG
Some of you might have to go to ur table right click, design and change the chattime to varchar(20) like myself, it was set to varchar(10) not recording the times
|
ChatTime should be set to datetime
|
|
|
11/29/2010, 08:26
|
#9
|
elite*gold: 100
Join Date: Mar 2009
Posts: 552
Received Thanks: 1,003
|
datetime, when i try to change it to that it does not work...
|
|
|
11/29/2010, 23:59
|
#10
|
elite*gold: 0
Join Date: Oct 2009
Posts: 262
Received Thanks: 809
|
I optimized the script some, here is what I changed:
1. The script was running 101 queries to gather data for 50 rows of chat text. I changed it to run 1 query instead to get all of the same data.
2. I removed the $gid, I wasn't sure what that was for. I also removed some other things that were not used.
3. I removed most of deprecated html tags and replaced them with css. I also lower cased all the tags as that is the standard way they are written. The page should validate now with the w3c validator.
4. I separated the processing and display logic. It nows processes everything first, and then displays everything afterwards. This makes it easier to maintain and more reusable in the future.
5. I simplified some of the logic, such as the nested if statements.
6. I changed the meta refresh tag to javascript as that method of refreshing the page is deprecated.
7. I changed from using $row[3] to $row['CharName'] so that the code is more readable and easier to maintain. This also allows you to change the order of fields in the select statement without breaking the page. I assumed that mssql_fetch_array is returning data in a manner that supports this.
8. Overall the script should be much smaller now.
Code:
<?php
//AUTOREFRESH, $timer = 20, UNITS ARE IN SECONDS
$timer = 20;
$timezone = 'EST';
date_default_timezone_set($timezone);
//CHANGE IT WHITH YOUR IP, USER AND PASSWORD, MAKE SURE TO LEAVE THE " " !!! OR IT WONT WORK
$IP="YOUR SERVER IP";
$USER="YOUR USER";
$PASS="YOUR PASSWORD";
// Connect to the database
if(!$link = @mssql_connect($IP,$USER,$PASS)){
echo 'Failed to connect to MSSQL server!'; die();
};
//SELECT THE LAST 50 LINES IN THE CHAT LOG TABLE
$sql = "SELECT TOP 50
cl.CharID,
cl.ChatType,
cl.TargetName,
cl.ChatData,
cl.ChatTime,
cl.MapID,
c.CharName,
c.Family
FROM [PS_ChatLog].[dbo].[ChatLog] AS cl
INNER JOIN [PS_GameData].[dbo].[Chars] AS c ON c.CharID = cl.CharID
ORDER BY cl.ChatTime DESC";
$result = mssql_query($sql,$link);
//Map ChatType integer to a meaningful string
$chat_types = array(1=>'normal',2=>'whisper',3=>'guild',4=>'party',5=>'trade',6=>'yelling',7=>'area');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Game Chats::</title>
<meta name="Generator" content="Battle for Dwater">
<meta name="Author" content="Battle for Dwater team">
<style type="text/css">
#body{color:#ffffff;background:#000000;font-family:arial;font-size:12px;}
.italic{font-style:italic;}
.currentDate{color:#aaaaaa; font-size:15px;}
table.chatData th{background:#333333;border-right:1px solid #000000;}
table.chatData td{border-right:1px solid #000000;}
table.chatData tr.stripeA{background:#111111;}
table.chatData tr.stripeB{background:#222222;}
.normal{color:white;}
.whisper{color:#ff374f;}
.guild{color:pink;}
.party{color:#7affa0;}
.trade{color:fff669;}
.yelling{color:red;}
.area{color:#7800ff;}
</style>
<script type="text/javascript">var refresh = setInterval(function(){ window.location.reload();},<?php echo $timer*1000; ?>);</script>
</head>
<body id="body">
<center style="margin:20px;">
<h1 class="italic">Game Chat</h1>
<div class="italic currentDate"><?php echo date('l jS \of F Y h:i:s A'); ?> <?php echo $timezone; ?></div>
<div>Self Refresh - <?php echo $timer; ?> Secs</div>
<table class="chatData" border="0" style="table-layout:fixed" cellpadding="3" cellspacing="0">
<tr><th width="120">Date</th><th width="50%">Light</th><th width="50%">Dark</th></tr>
<?php $i = 0; ?>
<?php while($row = mssql_fetch_array($result)){ ?>
<tr class="<?php echo ($i % 2 == 0) ? 'stripeA' : 'stripeB'; ?>">
<td><?php echo str_replace(' ',' ',$row['ChatTime']); ?></td>
<?php if($row['Family'] >= 2){ ?><td> </td><?php } ?>
<td class="<?php echo $chat_types[$row['ChatType']]; ?>">
<?php echo $chat_types[$row['ChatType']]; ?> <?php echo $row['CharName']; ?> (map <?php echo $row['MapID']; ?>): <?php echo !empty($row['TargetName']) ? 'PM to '.$row['TargetName'].':' : ''; ?> <?php echo htmlentities($row['ChatData']); ?>
</td>
<?php if($row['Family'] <= 1){ ?><td> </td><?php } ?>
</tr>
<?php $i++; ?>
<?php } ?>
</table>
</center>
</body>
</html>
I didn't have a webserver running PHP that was connected to a Shaiya database, so I wasn't able to test this with real data, so it may require some tweaking to run correctly in a real environment.
Hopefully this helps
|
|
|
11/30/2010, 00:31
|
#11
|
elite*gold: 0
Join Date: Oct 2009
Posts: 449
Received Thanks: 644
|
Quote:
Originally Posted by AriezOMG
datetime, when i try to change it to that it does not work...
|
You need to convert the date when changing data types. I tried to do the same, but couldn't understand what it is asking me to do so I removed ChatTime field and created a new one with data type I wanted. Might not be a good idea if you want to know the dates.
|
|
|
11/30/2010, 13:44
|
#12
|
elite*gold: 0
Join Date: May 2009
Posts: 32
Received Thanks: 39
|
Quote:
Originally Posted by abrasive
I optimized the script some, here is what I changed:
1. The script was running 101 queries to gather data for 50 rows of chat text. I changed it to run 1 query instead to get all of the same data.
2. I removed the $gid, I wasn't sure what that was for. I also removed some other things that were not used.
3. I removed most of deprecated html tags and replaced them with css. I also lower cased all the tags as that is the standard way they are written. The page should validate now with the w3c validator.
4. I separated the processing and display logic. It nows processes everything first, and then displays everything afterwards. This makes it easier to maintain and more reusable in the future.
5. I simplified some of the logic, such as the nested if statements.
6. I changed the meta refresh tag to javascript as that method of refreshing the page is deprecated.
7. I changed from using $row[3] to $row['CharName'] so that the code is more readable and easier to maintain. This also allows you to change the order of fields in the select statement without breaking the page. I assumed that mssql_fetch_array is returning data in a manner that supports this.
8. Overall the script should be much smaller now.
Code:
<?php
//AUTOREFRESH, $timer = 20, UNITS ARE IN SECONDS
$timer = 20;
$timezone = 'EST';
date_default_timezone_set($timezone);
//CHANGE IT WHITH YOUR IP, USER AND PASSWORD, MAKE SURE TO LEAVE THE " " !!! OR IT WONT WORK
$IP="YOUR SERVER IP";
$USER="YOUR USER";
$PASS="YOUR PASSWORD";
//SELECT THE LAST 50 LINES IN THE CHAT LOG TABLE
$sql = "SELECT TOP 50
cl.CharID,
cl.ChatType,
cl.TargetName,
cl.ChatData,
cl.ChatTime,
cl.MapID,
c.CharName,
c.Family
FROM [PS_ChatLog].[dbo].[ChatLog] AS cl
INNER JOIN [PS_GameData].[dbo].[Chars] AS c ON c.CharID = cl.CharID
ORDER BY cl.ChatTime DESC";
$result = mssql_query($sql,$link);
//Map ChatType integer to a meaningful string
$chat_types = array(1=>'normal',2=>'whisper',3=>'guild',4=>'party',5=>'trade',6=>'yelling',7=>'area');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Game Chats::</title>
<meta name="Generator" content="Battle for Dwater">
<meta name="Author" content="Battle for Dwater team">
<style type="text/css">
#body{color:#ffffff;background:#000000;font-family:arial;font-size:12px;}
.italic{font-style:italic;}
.currentDate{color:#aaaaaa; font-size:15px;}
table.chatData th{background:#333333;border-right:1px solid #000000;}
table.chatData td{border-right:1px solid #000000;}
table.chatData tr.stripeA{background:#111111;}
table.chatData tr.stripeB{background:#222222;}
.normal{color:white;}
.whisper{color:#ff374f;}
.guild{color:pink;}
.party{color:#7affa0;}
.trade{color:fff669;}
.yelling{color:red;}
.area{color:#7800ff;}
</style>
<script type="text/javascript">var refresh = setInterval(function(){ window.location.reload();},<?php echo $timer*1000; ?>);</script>
</head>
<body id="body">
<center style="margin:20px;">
<h1 class="italic">Game Chat</h1>
<div class="italic currentDate"><?php echo date('l jS \of F Y h:i:s A'); ?> <?php echo $timezone; ?></div>
<div>Self Refresh - <?php echo $timer; ?> Secs</div>
<table class="chatData" border="0" style="table-layout:fixed" cellpadding="3" cellspacing="0">
<tr><th width="120">Date</th><th width="50%">Light</th><th width="50%">Dark</th></tr>
<?php $i = 0; ?>
<?php while($row = mssql_fetch_array($result)){ ?>
<tr class="<?php echo ($i % 2 == 0) ? 'stripeA' : 'stripeB'; ?>">
<td><?php echo str_replace(' ',' ',$row['ChatTime']); ?></td>
<?php if($row['Family'] >= 2){ ?><td> </td><?php } ?>
<td class="<?php echo $chat_types[$row['ChatType']]; ?>">
<?php echo $chat_types[$row['ChatType']]; ?> <?php echo $row['CharName']; ?> (map <?php echo $row['MapID']; ?>): <?php echo !empty($row['TargetName']) ? 'PM to '.$row['TargetName'].':' : ''; ?> <?php echo htmlentities($row['ChatData']); ?>
</td>
<?php if($row['Family'] <= 1){ ?><td> </td><?php } ?>
</tr>
<?php $i++; ?>
<?php } ?>
</table>
</center>
</body>
</html>
I didn't have a webserver running PHP that was connected to a Shaiya database, so I wasn't able to test this with real data, so it may require some tweaking to run correctly in a real environment.
Hopefully this helps
|
thats what i call team working Thanks man
|
|
|
02/07/2011, 00:46
|
#13
|
elite*gold: 0
Join Date: Aug 2010
Posts: 103
Received Thanks: 26
|
Not work for me. I have this messages:
Warning: mssql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\sh\viewchatlog.php on line 25
Warning: mssql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\sh\viewchatlog.php on line 61
25 -
PHP Code:
$result = mssql_query($sql,$link);
61 -
PHP Code:
<?php while($row = mssql_fetch_array($result)){ ?>
How to fix it.
Thx All
|
|
|
02/07/2011, 01:39
|
#14
|
elite*gold: 0
Join Date: Oct 2009
Posts: 262
Received Thanks: 809
|
Somehow I missed the mssql_connect() call, I edited my post and added it back in.
|
|
|
03/26/2011, 21:35
|
#15
|
elite*gold: 0
Join Date: Jun 2009
Posts: 11
Received Thanks: 0
|
is it possible to define [trade] [area] yelling etc etc on abrasive version?
somehow its not showing the color chat types for me. all text show white no matter what mode i type ingame
|
|
|
|
|
Similar Threads
|
Flyff Fehlermeldung side by side konfiguration ungültig. wa skan ich tun?
06/06/2011 - Flyff - 10 Replies
Ich wollte mir letzte tage mal das onlne spiel flyff downlaoden doch dann wo ich das spiel installieren wollte stand da "side by side konfiguration ungültig".
was kann ich tun??
Bitte helfen.
Bitee in den nächsten Tagen antwortn, wäe sehr nett. :D
|
[Re-Release+Pic Tut] Server Side Mouse Fly
05/16/2008 - MapleStory - 0 Replies
All credits go to Ferris and Sponge of CEF except for this picture tutorial.
With this hack you will be able to fly around maple story with your mouse at whim.
I have included everything you will need to execute this very simple hack in the bottom of this thread
There has been some confusion in the fast weeks that this hack no longer works for gms version .54 but indeed it does and in my original post i was mistaken.
So without further ado the server side mouse fly picture...
|
Character name restrictions are client side, not server side
04/24/2008 - Conquer Online 2 - 1 Replies
"Sorry non-alpha numberic....."
That error message you get when you type in special characters in your character name, is client sided. It does no server check. Im not a coder or anything, so I'm not sure how to fix that.
But since it is client sided, it would be a lot easier to repair this problem.
|
All times are GMT +2. The time now is 16:33.
|
|