Register for your free account! | Forgot your password?

You last visited: Today at 15:35

  • Please register to post and access all features, it's quick, easy and FREE!

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.

Reply
 
Old 06/22/2011, 03:44   #16
 
elite*gold: 0
Join Date: Mar 2009
Posts: 67
Received Thanks: 4
Quote:
Originally Posted by abrasive View Post
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(' ','&nbsp;',$row['ChatTime']); ?></td>
						<?php if($row['Family'] >= 2){ ?><td>&nbsp;</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>&nbsp;</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
how to register the character set definition for chat?
akademik is offline  
Old 06/22/2011, 16:21   #17
 
remnikalija's Avatar
 
elite*gold: 0
Join Date: Apr 2010
Posts: 340
Received Thanks: 52
its not working to me it does not show nothing
remnikalija is offline  
Old 06/22/2011, 16:58   #18
 
elite*gold: 0
Join Date: Mar 2009
Posts: 67
Received Thanks: 4
I have everything working, but the code does not specify the encoding, which is strongly ill
akademik is offline  
Old 07/31/2011, 04:14   #19
 
jhoonyboy's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 21
Received Thanks: 5
ps_chat

hello, my chat does not show anything, and this in my log ps_chat all null values ​​in the ps_chatlog Would anyone have running?
or how can I run this
jhoonyboy is offline  
Old 02/25/2012, 03:41   #20
 
elite*gold: 0
Join Date: Dec 2011
Posts: 2
Received Thanks: 0
can i have that map links
your-mine is offline  
Old 03/21/2012, 11:33   #21
 
Phantomangel042's Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 92
Received Thanks: 52
Anyone happen to have a version of this amazing script converted to ODBC? Cause that would be AWESOME. Or want to teach me how to convert it?

Thanks in advance!
Phantomangel042 is offline  
Old 03/24/2012, 00:18   #22
 
[ADMIN]Cryptic's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 140
Received Thanks: 147
this sounds very useful... I cant run mssql scripts though. Anyone got a OBDC version of abrasive's script?

again good stuff!
[ADMIN]Cryptic is offline  
Old 03/24/2012, 00:29   #23
 
treica's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 525
Received Thanks: 805
Of course you can run mssql scripts just install an xampp 1.7.1 or 1.7.3 and will work fine...got the same problem but i have find by my self how to fix :P
treica is offline  
Old 03/24/2012, 00:41   #24
 
[ADMIN]Cryptic's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 140
Received Thanks: 147
xampp is for apache im running IIS and my version of PHP doesnt run mssql scripts and I tried all I can to make it work lol.

anyway for the ODBC version this is what I got so far.

PHP 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
$server '127.0.0.1';
$dbuser 'Shaiya';
$dbpass 'somethingyoullneverknow';

//connection with database
$conn = @odbc_connect("Driver={SQL Server};Server=$server;"$dbuser$dbpass) or die("Database Connection Error!");;

//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 odbc_exec($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 odbc_fetch_array($result)){ ?>
                    <tr class="<?php echo ($i == 0) ? 'stripeA' 'stripeB'?>">
                        <td><?php echo str_replace(' ','&nbsp;',$row['ChatTime']); ?></td>
                        <?php if($row['Family'] >= 2){ ?><td>&nbsp;</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>&nbsp;</td><?php ?>
                    </tr>
                    <?php $i++; ?>
                <?php ?>            
            </table>
        </center>
    </body>
</html>
result is it shows up now but theres no chat in it at all. whats the solution to this? I gess theres something I forgot to change.
[ADMIN]Cryptic is offline  
Old 03/24/2012, 05:22   #25
 
abrasive's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 262
Received Thanks: 809
Quote:
Originally Posted by [ADMIN]Cryptic View Post
xampp is for apache im running IIS and my version of PHP doesnt run mssql scripts and I tried all I can to make it work lol.

anyway for the ODBC version this is what I got so far.
--snip--
result is it shows up now but theres no chat in it at all. whats the solution to this? I gess theres something I forgot to change.
It sounds like you had errors set not to display or you would have seen the notices. You had the connection called $conn where you created it, but then it was called $link later when you went to use it.

Also your odbc_exec call had the arguments swapped. You were trying to use the $sql string as the connection, and the connection variable as the SQL string.

On a side note, I find the code tag much easier to read that the random rainbow php tag on this forum

Here is a fixed ODBC version with a few tweaks, such as different background color per faction, and one table column for chat instead of two:

Code:
<?php
//AUTOREFRESH, $timer = 20, UNITS ARE IN SECONDS
$timer = 20;
$timezone = 'EST';
date_default_timezone_set($timezone);

//CHANGE IT WITH YOUR IP, USER AND PASSWORD, MAKE SURE TO LEAVE THE QUOTES OR IT WONT WORK!!!
$server = '127.0.0.1';
$dbuser = 'username';
$dbpass = 'password';

//connection with database
$conn = @odbc_connect("Driver={SQL Server};Server=$server;", $dbuser, $dbpass) or die("Database Connection Error!");;
if(!$conn){
	exit("Connection failed:".odbc_errormsg());
}
//SELECT THE LAST 50 LINES IN THE CHAT LOG TABLE
$sql = "SELECT TOP 50
			cl.CharID,
			cl.ChatType,
			cl.TargetName,
			cl.ChatData,
			CONVERT(varchar,cl.ChatTime,120) AS 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 = odbc_exec($conn,$sql);
//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:#dddddd;background:#000000;font-family:arial;font-size:12px;}
			.italic{font-style:italic;}
			.currentDate{color:#aaaaaa; font-size:15px;}
			table.chatData{font-size:12px;}
			table.chatData th{background:#333333;border-right:1px solid #000000;}
			table.chatData td{border-right:1px solid #000000;}
			table.chatData tr.aol{background:#222222;}
			table.chatData tr.uof{background:#000033;}
			table.chatData tr.aol{background:#222222;}
			table.chatData tr.uof{background:#000033;}
			.normal{color:#dddddd;}
			.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 style="width:120px;">Date</th><th>Side</th><th>Type</th><th>Chat</th></tr>
				<?php $i = 0; ?>
				<?php while($row = odbc_fetch_array($result)){ ?>
					<tr class="<?php echo ($row['Family'] <= 1) ? 'aol': 'uof'; ?>">
						<td><?php echo str_replace(' ','&nbsp;',$row['ChatTime']); ?></td>
						<td><?php echo ($row['Family'] <= 1) ? 'AoL': 'UoF'; ?></td>
						<td><?php echo $chat_types[$row['ChatType']]; ?></td>
						<td class="<?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>
					</tr>
					<?php $i++; ?>
				<?php } ?>			
			</table>
		</center>
	</body>
</html>

Kudos for putting some effort into it instead of just asking for an ODBC version!
abrasive is offline  
Thanks
6 Users
Old 03/24/2012, 17:20   #26
 
[ADMIN]Cryptic's Avatar
 
elite*gold: 0
Join Date: Sep 2011
Posts: 140
Received Thanks: 147
thanks Abresive!

But I get another weird problem now... it takes forever to load and update it. It keeps saying connecting for like 3-5 minutes before it loads, none of my other scripts are like this. Maybe this is normal?


edit: I figured that problem out. it was cos my chatlog was several gigs big and it took forever to run the query hehe.
I got another problem now. it shows the chat but it dont seem to want to refresh and show new chat it gets stuck on the same one even if I hit the refresh button.

edit2: I figured this part out too. its order by date, it needs to be ordered by row instead and it will up chat in the right order since the date dont show when exacly its being said only on what day.

this mean the query for will look like this:

PHP Code:
$sql "SELECT TOP 50
            cl.CharID,
            cl.ChatType,
            cl.TargetName,
            cl.ChatData,
            CONVERT(varchar,cl.ChatTime,120) AS 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.row DESC"

[ADMIN]Cryptic is offline  
Old 03/25/2012, 12:18   #27
 
abrasive's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 262
Received Thanks: 809
Quote:
Originally Posted by [ADMIN]Cryptic View Post
I got another problem now. it shows the chat but it dont seem to want to refresh and show new chat it gets stuck on the same one even if I hit the refresh button.

edit2: I figured this part out too. its order by date, it needs to be ordered by row instead and it will up chat in the right order since the date dont show when exacly its being said only on what day.

this mean the query for will look like this:

PHP Code:
$sql "SELECT TOP 50
            cl.CharID,
            cl.ChatType,
            cl.TargetName,
            cl.ChatData,
            CONVERT(varchar,cl.ChatTime,120) AS 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.row DESC"

This means your chat log is not logging correctly. Technically this script will work like that, but what happens if you want to request chat log data for a specific time during a specific day? You will not be able to unless the logging method is fixed.
abrasive is offline  
Reply


Similar Threads 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 15:35.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.