free chat system?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
free chat system?
need a free chat script for my game, a simple one I can embed in my game.
I can find one with searching but just wanted to see if anyone has a recommendation.
I can find one with searching but just wanted to see if anyone has a recommendation.
-
ConceptDestiny
- Posts: 261
- Joined: Wed Apr 28, 2010 8:35 am
Re: free chat system?
Here's one I hacked together. Not sure if it will be of any use to you:
html
shouts.php
db structure:
id INT(11) auto_increment,
date_posted VARCHAR(50),
message VARCHAR(200),
name VARCHAR(30),
location VARCHAR(45)
html
Code: Select all
<script src="http://cdn.jquerytools.org/1.2.5/tiny/jquery.tools.min.js"></script>
<script src="http://cdn.jquerytools.org/1.2.5/form/jquery.tools.min.js"></script>
<script src="http://cdn.jquerytools.org/1.2.5/all/jquery.tools.min.js"></script>
<script src="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js"></script>
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#shoutbox').load('shouts.php');
setInterval(function(){
$('#shoutbox').load('shouts.php');
}, 10000);
});
</script>
<form method="post" action="" autocomplete="off"><center>
<input type='text' id="shoutbox_input" name="shout"></textarea><br>
<input type="submit" id='shoutbox_button' name="submit" value="Shout !" /><br>
<div id="shoutbox"></div>
</form>
Code: Select all
//connect to database
$error = "Problem connecting";
mysql_connect('localhost','database','password') or die($error);
mysql_select_db('database') or die($error);
// BEGIN BADWORDS FILTER
function filterwords($text){
$filterWords = array('fuck','shit','fck','piss','shittier','shitty','fuck you','fucker','fucking','faggot','cunt','arsehole','asshole','asshat','assclown','cock','bitch','bastard','bollocks','blowjob','bullshit','douche','dumbfuck','nigger','shithead','suckass','skullfuck','twat','tit','wanker','wank','whore');
$filterCount = sizeof($filterWords);
for($i=0; $i<$filterCount; $i++){
$text = preg_replace('/\b'.$filterWords[$i].'\b/ie',"str_repeat('*',strlen('$0'))",$text);
}
return $text;
}
// END BADWORDS FILTER
$q = mysql_query("SELECT * from shouts ORDER BY id DESC LIMIT 12");
$shouts = (array());
while ($r = mysql_fetch_assoc($q)){
$shouts[] = array(
'user_id' => $r['user_id'],
'message' => ($r['message']),
'name' => $r['name']);
}
foreach ($shouts as $s){
$name = $s['name'];
$query = "SELECT admin FROM user WHERE username='$name'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
$admin = $row['admin'];
$me = $row['username'];
if ($s['name'] == $session_username)
{$name = "<font color='green'><b>".$name."</b></font>";}
if ($admin == '1'){
$admin = '<font color=\'yellow\'>';
$adminend = '</font>';
}
else{
$admin = '';
$adminend = '';
}
echo ("<a href='viewprofile.php?username=".$s['name'] ."' target='_blank'><u><b>".$admin."".$s['name'] ."".$adminend."</b></u></a>: ".filterwords(stripslashes($s['message']))."<br>");
}
id INT(11) auto_increment,
date_posted VARCHAR(50),
message VARCHAR(200),
name VARCHAR(30),
location VARCHAR(45)
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: free chat system?
thanks! not going to use JQuery though. My game is heavy on code as it is. The less includes I have the better. Not really wanting to load a bunch of JQuery.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: free chat system?
If you link to the Google jQuery repository, a huge number of people already have it cached, so there is a good possibility it will add nothing at all to you download time. Plus, remember that a Javascript include is really only downloaded once, and then kept in the cache the entire browsing time. So what is an extra 31kb download on the front page if it will save you possibly tens or hundreds of hours of coding time? 
The indelible lord of tl;dr
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: free chat system?
just not a fan of jquery and I plan on being able to mod it to make it work and raw JS would be better suited right now.
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: free chat system?
Awww, the way you were talking a few months ago I thought we had converted you lol.
The indelible lord of tl;dr
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: free chat system?
hehe never got time. One day 
Re: free chat system?
There's a free chat system in your head. You've just gotta find it and write it down. :>
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: free chat system?
LOL Your signature fits right in with that: "Innovating when we probably shouldn't"
Why spend all that time designing, writing and debugging something when there are working solutions out there now?
The indelible lord of tl;dr
Re: free chat system?
Because reinventing such a tiny wheel as a simple chat system can be fun, and provide a more perfect solution for your needs than any general solution you might find. For small tasks, specialization can be a plus.Jackolantern wrote:LOL Your signature fits right in with that: "Innovating when we probably shouldn't"Why spend all that time designing, writing and debugging something when there are working solutions out there now?
He asked for chat system recommendations. I just recommended his. Don't hate on me. :<
