Page 1 of 1

free chat system?

Posted: Sun Jul 03, 2011 5:32 pm
by hallsofvallhalla
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.

Re: free chat system?

Posted: Sun Jul 03, 2011 8:49 pm
by ConceptDestiny
Here's one I hacked together. Not sure if it will be of any use to you:

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> 
shouts.php

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>");
  }
db structure:

id INT(11) auto_increment,
date_posted VARCHAR(50),
message VARCHAR(200),
name VARCHAR(30),
location VARCHAR(45)

Re: free chat system?

Posted: Sun Jul 03, 2011 9:25 pm
by hallsofvallhalla
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.

Re: free chat system?

Posted: Sun Jul 03, 2011 11:49 pm
by Jackolantern
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? ;)

Re: free chat system?

Posted: Mon Jul 04, 2011 12:44 am
by hallsofvallhalla
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.

Re: free chat system?

Posted: Mon Jul 04, 2011 1:43 am
by Jackolantern
Awww, the way you were talking a few months ago I thought we had converted you lol.

Re: free chat system?

Posted: Mon Jul 04, 2011 2:15 am
by hallsofvallhalla
hehe never got time. One day ;)

Re: free chat system?

Posted: Thu Jul 07, 2011 9:46 pm
by Seisatsu
There's a free chat system in your head. You've just gotta find it and write it down. :>

Re: free chat system?

Posted: Thu Jul 07, 2011 9:55 pm
by Jackolantern
LOL Your signature fits right in with that: "Innovating when we probably shouldn't" :lol: Why spend all that time designing, writing and debugging something when there are working solutions out there now?

Re: free chat system?

Posted: Fri Jul 08, 2011 4:01 am
by Seisatsu
Jackolantern wrote:LOL Your signature fits right in with that: "Innovating when we probably shouldn't" :lol: Why spend all that time designing, writing and debugging something when there are working solutions out there now?
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.

He asked for chat system recommendations. I just recommended his. Don't hate on me. :<