free chat system?

C++, C#, Java, PHP, ect...
Post Reply
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

free chat system?

Post 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.
ConceptDestiny
Posts: 261
Joined: Wed Apr 28, 2010 8:35 am

Re: free chat system?

Post 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)
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: free chat system?

Post 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.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: free chat system?

Post 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? ;)
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: free chat system?

Post 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.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: free chat system?

Post by Jackolantern »

Awww, the way you were talking a few months ago I thought we had converted you lol.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: free chat system?

Post by hallsofvallhalla »

hehe never got time. One day ;)
Seisatsu
Posts: 34
Joined: Mon Aug 17, 2009 3:40 pm

Re: free chat system?

Post by Seisatsu »

There's a free chat system in your head. You've just gotta find it and write it down. :>
Image
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: free chat system?

Post 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?
The indelible lord of tl;dr
Seisatsu
Posts: 34
Joined: Mon Aug 17, 2009 3:40 pm

Re: free chat system?

Post 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. :<
Image
Post Reply

Return to “Coding”