Author Topic: Smilies/Emoticons  (Read 919 times)

Offline Pug307

  • Level 21
  • *
  • Posts: 244
  • Reputation: +6/-1
    • View Profile
Smilies/Emoticons
« on: November 10, 2006, 01:10:32 PM »
I was just wondering if I added my message board for the pimp game here, could somebody add smileys to it for me? I have no idea how to go on about this and have spend a few hours searching google to get nowhere.

It's probably not hard for someone that knows what there doing but I have no idea. I have read up you can use Arrays but im pretty dense when it comes to this.

Thanks



Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Smilies/Emoticons
« Reply #1 on: November 10, 2006, 01:59:16 PM »
Uhh... are you using a forum software like SMF?
There should be an admin panel that comes with it where you can edit/add smilies.

Otherwise, if you are using a custom coded forum, I think the simplest way would be to use str_ireplace().
It will search the string (the user's message) and replace it with whatever you want (smilies).

Example:
Code: [Select]
<?php
$message 
"Wahaha! This is just a message :)...";
$message str_ireplace(":)""<img src=\"smiley.gif\">"$message);
echo 
$message;
?>

This will add a smiley face to the message :)

Offline Pug307

  • Level 21
  • *
  • Posts: 244
  • Reputation: +6/-1
    • View Profile
Re: Smilies/Emoticons
« Reply #2 on: November 10, 2006, 05:34:54 PM »
No it's not a forum like SMF, it's one thats coded for the game. I only want the everyday smilies (wink, smile, sad, cry, etc)

I can post the whole code to the board as I don't know where abouts to add the code for the smilies. Sorry if this don't make much sense, I really don't know the correct terms for this  ^_^



Offline Cripple

  • Level 17
  • *
  • Posts: 170
  • Reputation: +10/-4
    • View Profile
Re: Smilies/Emoticons
« Reply #3 on: November 11, 2006, 12:30:27 AM »
i'm playin around with a script atm too pug - basically a bastardised version of pimpwarz.
i just edited "funcs.php" & added a few smileys there.
code looks like this:
Code: [Select]
    $var = str_replace( " :)", " <img src=\"img/smileys/smile.gif\" align=absmiddle border=\"0\" />", $var );
    $var = str_replace( " :P", " <img src=\"img/smileys/tongue.gif\" align=absmiddle border=\"0\" />", $var );
    $var = str_replace( " :(", " <img src=\"img/smileys/sad.gif\" align=absmiddle border=\"0\" />", $var );
    $var = str_replace( " :D", " <img src=\"img/smileys/happy.gif\" align=absmiddle align=absmiddle border=\"0\" />", $var );
    $var = str_replace( " ;)", " <img src=\"img/smileys/wink.gif\" align=absmiddle border=\"0\" />", $var );
    $var = str_replace( " >:(", " <img src=\"img/smileys/mad.gif\" align=absmiddle border=\"0\" />", $var );
    return $var;

Offline decepti0n

  • Level 4
  • *
  • Posts: 14
  • Reputation: +0/-0
    • View Profile
Re: Smilies/Emoticons
« Reply #4 on: November 11, 2006, 03:07:28 PM »
The one i use looks like this:
Code: [Select]
function smiley2img($text) {
$emoticons = array();
$emoticons[] = array('0:)', ' <img src="images/smilies/angel.png" title="Angel" align="middle" border="0"> ');
$emoticons[] = array('O:)', ' <img src="images/smilies/angel.png" title="Angel" align="middle" border="0"> ');
foreach ($emoticons as $emoticon) {
$text = str_replace($emoticon[0], $emoticon[1], $text);
}
return $text;
}

With a lot more of course :p

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal