DragonPrime - LoGD Resource Community

Modules, Themes and other customizations for your game => Completed Modules for version 1.x.x => Topic started by: Aeolus on February 06, 2013, 06:58:39 AM



Title: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on February 06, 2013, 06:58:39 AM
Name: Sectioned Chats
Author: Aeolus, with additional code by Xpert
Version: 1.0
Category: Commentary
Compatible: Tested and used on 1.1.2 (should work on any 1.x.x)

Description:
A chat which breaks chats into sections (Village: Roleplay and OOC, Grotto: Business and General). Links appear above chat to switch between them, and each link turns red if there is a post in a section that the user has not seen yet. A module used for removing annoying OOC posts from those trying to roleplay, and the same for the Grotto for business.

Two small core edits required:
REMEMBER, CORE EDITS CAN BE DANGEROUS IF YOU DON'T KNOW WHAT YOU'RE DOING!

village.php:
Replace:
Code:
modulehook("village",$texts);
//special hook for all villages... saves queries...
modulehook("village-{$session['user']['location']}",$texts);
With:
Code:
$texts = modulehook("village",$texts);
//special hook for all villages... saves queries...
$texts = modulehook("village-{$session['user']['location']}",$texts);

superuser.php:
Replace:
Code:
commentdisplay("", "superuser","Engage in idle conversation with other gods:",25);
With:
Code:
$args = modulehook("superusertop", array("section"=>"superuser"));
commentdisplay("", $args['section'],"Engage in idle conversation with other gods:",25);

Suggestions, ideas and bugs are welcome.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on February 28, 2013, 07:40:48 AM
It doesnt work when you use city generic to make the cities.  But I'm sure if you use races to make the cities it works fine.  Anyway to fix this?  I cant seem to figure out the fix.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on February 28, 2013, 01:13:13 PM
It doesnt work when you use city generic to make the cities.  But I'm sure if you use races to make the cities it works fine.  Anyway to fix this?  I cant seem to figure out the fix.

What do you mean it doesn't work? As in, the tabs don't appear? Or the same chat appears for each tab? Details, please.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on February 28, 2013, 01:23:08 PM
Same chat appears in each tab.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on February 28, 2013, 01:24:38 PM
Same chat appears in each tab.

You have done the core edits, yes?


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on February 28, 2013, 01:55:25 PM
Yes.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Nightflay on February 28, 2013, 07:03:48 PM
The problem that was being run into was that in the main city this was working fine. It was the other cities beyond our main that we were having the problem that everything was being posted into just one section of the chat. In other words even if you were showing as being in the OOC section of the chat everything still posted in the Roleplay section.

Again as I said though, the chats worked fine in the main city.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on February 28, 2013, 09:22:17 PM
Made the changes from

module_addhook("village");
case "village":

to:

module_addhook("villagetext");
case "villagetext":

That didnt work.  It just moved the buttons.  When you post in OOC its still posting it in Roleplay.  Only works properly in main city and grotto.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on February 28, 2013, 09:56:06 PM
Copy and paste your core edits for the village.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on February 28, 2013, 10:31:11 PM
I saved the village file as a txt file just so you could see it and see if you notice anything wrong.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on February 28, 2013, 10:57:33 PM
Your village file and a clean download of this module works perfectly for me on both my test server and my live server.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on February 28, 2013, 10:59:07 PM
Then I dont know whats wrong with it.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on February 28, 2013, 11:00:47 PM
I don't either. Apologies I can't be further help, there is nothing else I can do.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on February 28, 2013, 11:15:38 PM
Maybe someone else has an idea.  Thanks for your help though.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: RaynDarren on February 28, 2013, 11:26:24 PM
I'd humbly like to suggest reinstalling the cities modules as well as the section chats, with the reinstall of the cities coming first :).


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on February 28, 2013, 11:29:07 PM
We did that already.  Because of the error with the races and the cities not syncing.  The section chat was taken off in the process and put back on.  Still the same error.  So I dont know.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on March 01, 2013, 12:58:39 AM
Try this.

Change:
Code:
module_addhook("village");

To:
Code:
module_addhook_priority("village", 100);

Then reinstall the module. Might work, might not.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on March 01, 2013, 01:46:50 AM
Didnt work.  Do you think that the bit of code used to see if we're using city generic isnt right for the site?


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on March 01, 2013, 01:50:43 AM
Didnt work.  Do you think that the bit of code used to see if we're using city generic isnt right for the site?

What 'bit of code'?


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Rockie on March 23, 2014, 06:23:23 PM
Hello The Doctor,

I've searched for a way to make the OOC chat the default chat. In the module manager, there are no settings available. I tried changing line 10 that reads:

"chat_v" => "Which chat has user saved in village,enum,chat1,RP Chat,chat2,OOC Chat|chat1",

to

"chat_v" => "Which chat has user saved in village,enum,chat1,RP Chat,chat2,OOC Chat|chat2",

though this gave me call stacks. Is there a different way to go about this?


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on March 23, 2014, 07:00:12 PM
Hello The Doctor,

I've searched for a way to make the OOC chat the default chat. In the module manager, there are no settings available. I tried changing line 10 that reads:

"chat_v" => "Which chat has user saved in village,enum,chat1,RP Chat,chat2,OOC Chat|chat1",

to

"chat_v" => "Which chat has user saved in village,enum,chat1,RP Chat,chat2,OOC Chat|chat2",

though this gave me call stacks. Is there a different way to go about this?

Call stacks, really? Strange. Can you redo your edit (from chat1 to chat2), and copy-and-paste the call stacks here?


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on October 20, 2014, 04:17:48 PM
Is there a way a setting can be made for this module to only be in one village?


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on October 20, 2014, 05:03:04 PM
Is there a way a setting can be made for this module to only be in one village?

Yes. Compare the user's current location to the city that you want this module to appear in. If they match, then run the code.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on October 24, 2014, 04:16:14 PM
Can you explain a little more?


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on October 24, 2014, 06:17:33 PM
Can you explain a little more?

Not sure if I can explain it any more. Get the user's current location. Compare it to the city that you want the sectioned chats to appear in, and if (bolded and italic as a hint for which statement to use) the two match... run the code to display the tabs.

That's all there really is.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on November 11, 2014, 05:22:44 PM
I got that part figured out finally. Now my other headache is, how in the heck do I get it out of the grotto?


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on November 11, 2014, 08:47:46 PM
I got that part figured out finally. Now my other headache is, how in the heck do I get it out of the grotto?

Remove the grotto hook.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on November 11, 2014, 10:33:36 PM
Just making sure I remove the right thing. This is what I remove, correct?

Code:
module_addhook("superusertop");


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Maverick on November 12, 2014, 09:28:15 AM
Jesus.

Why don't you just comment it out (BTW commenting out can be done using //, /* */, or #, before you ask how to do that) and see if it's still in the grotto or not.  ::)


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: DarknessFalls on November 12, 2014, 10:06:49 AM
Religion has nothing to do with it, Maverick, so please play nicely.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on November 12, 2014, 11:06:29 AM
Being snotty to people who ask for help because they are trying to learn and its hard for them, wont get you anywhere. If you ever need help and keep being snotty to me, it would make me not want to help you. Seriously.

Back on topic. I know how to comment stuff out. I wanted to make sure I was commenting the right thing. So many people have broken their site from trial and error and then didnt know how to fix it. I am not going to be like that.

I also was wondering if there was a way to make the tab highlight when you click it so that the highlight means thats the tab you are on. That way players dont get confused.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Maverick on November 12, 2014, 12:47:25 PM
Religion has nothing to do with it, Maverick, so please play nicely.

I mean, at least the majority of my post had some relevance to the topic.  ::)

Back on topic. I know how to comment stuff out. I wanted to make sure I was commenting the right thing. So many people have broken their site from trial and error and then didnt know how to fix it. I am not going to be like that.

I also was wondering if there was a way to make the tab highlight when you click it so that the highlight means thats the tab you are on. That way players dont get confused.

So many people also have a live site and a test site, for things such as this; testing, debugging, trial and error, etc. Just a thought. ::)

And if you look at the code of this module, I hope you have done that, already, you will see that if the '$chat' variable is set to 'chat1' it colors or highlights one tab and sets the other to a default color.

I'm looking at this, specifically:

Code:
<?php

if ($chat0 == "chat1"){
$sql db_num_rows(db_query("SELECT commentid FROM ".db_prefix('commentary')." WHERE section = '{$args['section']}-ooc' AND postdate > '$time2'"));
$style1 "style='color:#2E2EFE;'";
if ($sql$style2 "style='color:red;'"; else $style2 "";
} else {
$sql db_num_rows(db_query("SELECT commentid FROM ".db_prefix('commentary')." WHERE section = '{$args['section']}' AND postdate > '$time1'"));
if ($sql$style1 "style='color:red;'"; else $style1 "";
$style2 "style='color:#2E2EFE;'";
}

?>


For a little more personal touch, you can look here for further information regarding HTML colors: http://www.w3schools.com/html/html_colors.asp


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on November 12, 2014, 12:50:55 PM
Being snotty to people who ask for help because they are trying to learn and its hard for them, wont get you anywhere. If you ever need help and keep being snotty to me, it would make me not want to help you. Seriously.

Back on topic. I know how to comment stuff out. I wanted to make sure I was commenting the right thing. So many people have broken their site from trial and error and then didnt know how to fix it. I am not going to be like that.

I also was wondering if there was a way to make the tab highlight when you click it so that the highlight means thats the tab you are on. That way players dont get confused.

That's what development servers are for. :D To test every module that you're going to use on your live site. That way, if you screw something up, it's not "Oops, there goes my live site!", it's "Oops, there goes my dev site, my live site is fine!", and you can fix whatever on your dev site.

The tab that a player is currently on does get highlighted (well, changed colour).

Edit: Basically, what Maverick said. xD


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on November 13, 2014, 01:50:05 PM
I changed the color of the tabs and when I did that I didnt put them in the same order the old ones were in. When Maverick made that post I saw what I did wrong and fixed it. Everything is good now. Thank you all for your help.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on April 08, 2015, 02:50:04 PM
I tried pasting part of the code in the file in the commentary file above the textarea so that the tabs are above the chat box. All that did was put [][] there. Is there any way to put it above the chat box and not above the chat? Help would be greatly appreciated.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on April 08, 2015, 06:52:18 PM
I tried pasting part of the code in the file in the commentary file above the textarea so that the tabs are above the chat box. All that did was put [][] there. Is there any way to put it above the chat box and not above the chat? Help would be greatly appreciated.

Again with the copy-pasting, no surprise.

Yes, there is a way - change the hook to one above the chatbox.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on April 08, 2015, 07:06:02 PM
I figured it was that but I dont know a list of hooks off the top of my head. I'd look it up on the DragonPedia but that thing has been broken for like 3 or 4 years.


EDIT: I replaced the village hook with the insertcomment hook and it did the same thing. It turned the split chat off and only put [][] above the chat box.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Sunday on April 08, 2015, 08:10:45 PM
I replaced the village hook with the insertcomment hook and it did the same thing. It turned the split chat off and only put [][] above the chat box.
I am going to teach you how to analyze the situation of the error. First you need to check what area is having the issue. You say it only shows displays the following
Quote
[][]

So, we need to find this section in the code which is on line 77 - pending that you did not change anything else in the module:
Code:
<?php
rawoutput("<center><big><b>[<a href='$link1$style1>{$chatnames[$h]['chat1']}</a>] [<a href='$link2$style2>{$chatnames[$h]['chat2']}</a>]</b></big></center><br />");

So, we can see that those links specifically are not showing. Let's focus on the following...
Code:
<?php
<a href='$link1' $style1>{$chatnames[$h]['chat1']}</a>

If you were to inspect the html source, you can analyze the section and see that the anchor (<a href=''></a>) is just fine. So the issue may be in the anchor's text:
Code:
<?php
{$chatnames[$h]['chat1']}

This, is $chatnames an array which is defined just a few lines above the output at line 70. This is where we must look first.
Code:
<?php
$chatnames = array(
"v" => array("chat1" => "Roleplay""chat2" => "OOC"),
"s" => array("chat1" => "Business""chat2" => "General")
);

At a glance, this looks fine - no errors are made, the array is structured properly, and as a bonus, it is easily readable. So the answer must lie further in the anchor's text. On to [$h] - let's see what is there, defined on line 44:
Code:
<?php
$h $hookname[0];

There is the issue, clearly laid out. Since you do not know, $h is set to the $hookname's first letter 0 I can tell this simply because the $hookname is a string and 0 refers to the first entity that we occur. So the issue is we are looking for the first letters ([ i ]nsertcomment, [ s ]uperusertop) inside of the $chatnames array. So let's go back a bit. We know our first letters being grabbed are i and s, since they are for two hooks.

Code:
<?php
$chatnames = array(
"v" => array("chat1" => "Roleplay""chat2" => "OOC"),
"s" => array("chat1" => "Business""chat2" => "General")
);

Ah, there it be! See, we switched the hooks from village, which would have set the $h to v for [v]illage, and $chatnames still has a declaration for v! We have no declaration for i as in [ i ]nsertcomment! Just change the $chatnames array to the following:
Code:
<?php
$chatnames = array(
"i" => array("chat1" => "Roleplay""chat2" => "OOC"),
"s" => array("chat1" => "Business""chat2" => "General")
);

That will fix the entire module as you want it. If you just copy and paste this answer without properly giving the entire post a look over to see if you can debug some on your own in the future... Then that is a shame on you.

Have a nice day.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on April 08, 2015, 08:18:51 PM
See...I didnt know thats what that [ 0 ] did at the end of hookname. I am still learning and posts like yours help me. Its hard for me to get coding. Its why I never advanced my html past basic and google everything about it. But a lot of the php sites on google arent specific to lotgd style so its hard to understand it and it just ends up confusing me over all. Thank you for explaining it to me so I can understand and learn. I appreciate it hugely.

EDIT: I changed the places I needed to change and when it worked, I clicked on each tab individually and only was displayed the Roleplay chat in both tabs. The OOC chat was gone.

EDIT 2: I believe it has something to do with this core edit:

$texts = modulehook("village",$texts);
//special hook for all villages... saves queries...
$texts = modulehook("village-{$session['user']['location']}",$texts);

I havent tried to fix it on my own cause I dont know what other modules or files use that part of the village.php file. Help on this one would be greatly appreciated.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on April 09, 2015, 11:48:26 PM
So I added module_addhook_priority("insertcomment",25); to the top with the other addhooks and kept the village one and the case "village": and changed case "superusertop": to case "insertcomment": since I didnt want it in the grotto anyway. I then changed the v in the $chatnames array to an i. The only error there is now is the [ ] [ ] still appear at the top of the chat due to the village hook. They are at the bottom above the chat box with the words Roleplay and OOC inside them. Just I cant get the blank [ ] [ ]  to disappear at the top of the chat or the [Roleplay] [OOC] to center in the insercomment case for the life of me. The centering not happening it probably due to some of the rawoutput code pulling into the village hook. I dont need the village hook for anything other than the chats appearing correctly. Stopping the village hook from pulling any of the rawoutput code would be nice. Help would be appreciated.


EDIT: My staff and I figured it out. We just copied the whole superusertop case that we changed to be the insertcomment case into the village case and then blocked the addnavs and rawoutput. That took away the [ ] [ ] above the chat. Then we went to the rawoutput code in the insertcomment case and added the &nbsp; code before the <center> code and that allowed it to be centered.

Sometimes 2 heads are better than 1.


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Megan|SaraBeth on April 11, 2015, 11:22:40 PM
Now I have come across another problem. The case "insertcomment": wont read my code to place it into one village only.

This is the code.

Code:
$place = get_module_setting('place');
$hook = get_module_setting('hook');
if (get_module_setting('hook')==0||get_module_setting('place')==$session['user']['location']&&get_module_setting('hook')==1) {

So now the links are in all the chat places. Is there a fix?

This is where I placed the code in the file.

Code:
$place = get_module_setting('place');
$hook = get_module_setting('hook');
if (get_module_setting('hook')==0||get_module_setting('place')==$session['user']['location']&&get_module_setting('hook')==1) {
$chatnames = array(
"i" => array("chat1" => "Roleplay", "chat2" => "OOC"),
"s" => array("chat1" => "Business", "chat2" => "General")
);
$chatnames = translate_inline($chatnames);

output_notl("`0`n");
rawoutput("&nbsp;<center><big><b>[<a href='$link1' $style1>{$chatnames[$h]['chat1']}</a>] [<a

href='$link2' $style2>{$chatnames[$h]['chat2']}</a>]</b></big></center><br />");


if ($chat0 == "chat2") $chatao = "-ooc"; else $chatao = "";
$args['section'] .= $chatao;
                                                      }


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Lila Dominuss on July 23, 2018, 10:52:21 PM
This discussion helped me, had my sectioned chats working in a few minutes and relatively easy to do. Thank you Aelous!


Title: Re: Sectioned Chats : File Submission/Discussion
Post by: Aeolus on July 24, 2018, 02:35:41 AM
This discussion helped me, had my sectioned chats working in a few minutes and relatively easy to do. Thank you Aelous!

No problems, glad to be of service Lila Doimnuss!

© 2018 DragonPrime - LoGD Resource Community
Email Talisman: talisman -at- gmail.com
&oeXs)2U7=V BmܲV.U e=;p\}eG )Jj} C5EH7ˤH=j } mo|*Ŋw{drV_@IV>/- TFQJ׀̀Ve}l1,V O iNYx͘$e$;
Forums: Powered by SMF 1.1.21 | SMF © 2006-2007, Simple Machines